Add and wire up skill specific xp formula multipliers

This commit is contained in:
nossr50 2019-05-07 00:18:50 -07:00
parent c968b9f94a
commit 0331c98c9b
4 changed files with 32 additions and 8 deletions

View File

@ -127,13 +127,6 @@ public class ExperienceConfig extends ConfigValidated {
config.set(EXPERIENCE_FORMULA, MULTIPLIER, GLOBAL, value); config.set(EXPERIENCE_FORMULA, MULTIPLIER, GLOBAL, value);
}*/ }*/
/* PVP modifier */
/* Skill modifiers */
public double getFormulaSkillModifier(PrimarySkillType skill) {
return getDoubleValue(EXPERIENCE_FORMULA, MODIFIER, StringUtils.getCapitalized(skill.toString()));
}
/* Custom XP perk */ /* Custom XP perk */
public double getCustomXpPerkBoost() { public double getCustomXpPerkBoost() {
return getDoubleValue(EXPERIENCE_FORMULA, CUSTOM_XP_PERK, BOOST); return getDoubleValue(EXPERIENCE_FORMULA, CUSTOM_XP_PERK, BOOST);

View File

@ -1,13 +1,28 @@
package com.gmail.nossr50.config.hocon.playerleveling; package com.gmail.nossr50.config.hocon.playerleveling;
import com.gmail.nossr50.datatypes.experience.FormulaType; import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import ninja.leaping.configurate.objectmapping.Setting; import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
import java.util.HashMap;
@ConfigSerializable @ConfigSerializable
public class ConfigExperienceFormula { public class ConfigExperienceFormula {
public static final boolean CUMULATIVE_CURVE_DEFAULT = false; public static final boolean CUMULATIVE_CURVE_DEFAULT = false;
private static final HashMap<PrimarySkillType, Double> SKILL_FORMULA_MODIFIER_DEFAULT;
static {
SKILL_FORMULA_MODIFIER_DEFAULT = new HashMap<>();
for(PrimarySkillType primarySkillType : PrimarySkillType.values())
{
if(primarySkillType.isChildSkill())
continue;
SKILL_FORMULA_MODIFIER_DEFAULT.put(primarySkillType, 1.0D);
}
}
@Setting(value = "Player-XP-Formula-Type", comment = "Determines which formula is used to determine XP needed to level" + @Setting(value = "Player-XP-Formula-Type", comment = "Determines which formula is used to determine XP needed to level" +
"\nDefault value: LINEAR") "\nDefault value: LINEAR")
@ -26,10 +41,18 @@ public class ConfigExperienceFormula {
"\nDefault value: " + CUMULATIVE_CURVE_DEFAULT) "\nDefault value: " + CUMULATIVE_CURVE_DEFAULT)
private boolean cumulativeCurveEnabled = CUMULATIVE_CURVE_DEFAULT; private boolean cumulativeCurveEnabled = CUMULATIVE_CURVE_DEFAULT;
@Setting(value = "Skill-Formula-Multipliers", comment = "The end result of how much XP is needed to level is determined by multiplying against this value" +
"\nHigher values will make skills take longer to level, lower values will decrease time to level instead.")
private HashMap<PrimarySkillType, Double> skillXpModifier = SKILL_FORMULA_MODIFIER_DEFAULT;
public FormulaType getFormulaType() { public FormulaType getFormulaType() {
return formulaType; return formulaType;
} }
public double getSkillXpFormulaModifier(PrimarySkillType primarySkillType) {
return skillXpModifier.get(primarySkillType);
}
public ConfigExperienceFormulaLinear getConfigExperienceFormulaLinear() { public ConfigExperienceFormulaLinear getConfigExperienceFormulaLinear() {
return configExperienceFormulaLinear; return configExperienceFormulaLinear;
} }

View File

@ -31,6 +31,14 @@ public class ConfigLeveling {
* GETTER BOILERPLATE * GETTER BOILERPLATE
*/ */
public double getSkillXpFormulaModifier(PrimarySkillType primarySkillType) {
return getConfigExperienceFormula().getSkillXpFormulaModifier(primarySkillType);
}
public boolean isCumulativeCurveEnabled() {
return getConfigExperienceFormula().isCumulativeCurveEnabled();
}
public double getEarlyGameBoostMultiplier() { public double getEarlyGameBoostMultiplier() {
return earlyGameBoost.getEarlyGameBoostMultiplier(); return earlyGameBoost.getEarlyGameBoostMultiplier();
} }

View File

@ -217,7 +217,7 @@ public enum PrimarySkillType {
} }
public double getXpModifier() { public double getXpModifier() {
return ExperienceConfig.getInstance().getFormulaSkillModifier(this); return mcMMO.getConfigManager().getConfigLeveling().getSkillXpFormulaModifier(this);
} }
// TODO: This is a little "hacky", we probably need to add something to distinguish child skills in the enum, or to use another enum for them // TODO: This is a little "hacky", we probably need to add something to distinguish child skills in the enum, or to use another enum for them