Some work on milestones is done

This commit is contained in:
nossr50
2018-12-31 10:10:00 -08:00
parent b9c8743ee3
commit bec088c969
15 changed files with 412 additions and 55 deletions

View File

@ -21,7 +21,14 @@ public class FormulaManager {
private FormulaType previousFormula;
//Used for XP formula scaling
private boolean classicModeEnabled;
private int classicModeXPFormulaFactor;
public FormulaManager() {
/* Setting for Classic Mode (Scales a lot of stuff up by * 10) */
classicModeEnabled = Config.getInstance().getClassicMode();
classicModeXPFormulaFactor = Config.getInstance().getClassicModeXPFormulaFactor();
loadFormula();
}
@ -105,6 +112,9 @@ public class FormulaManager {
public int getCachedXpToLevel(int level, FormulaType formulaType) {
int experience;
//If we're in classic we use the XP factor from config settings
int skillSystemMultiplier = classicModeEnabled ? classicModeXPFormulaFactor : 10;
if (formulaType == FormulaType.UNKNOWN) {
formulaType = FormulaType.LINEAR;
}
@ -116,7 +126,7 @@ public class FormulaManager {
switch (formulaType) {
case LINEAR:
if (!experienceNeededLinear.containsKey(level)) {
experience = (int) Math.floor( 10 * (base + level * multiplier));
experience = (int) Math.floor( skillSystemMultiplier * (base + level * multiplier));
experienceNeededLinear.put(level, experience);
}
@ -124,7 +134,7 @@ public class FormulaManager {
case EXPONENTIAL:
if (!experienceNeededExponential.containsKey(level)) {
experience = (int) Math.floor( 10 * multiplier * Math.pow(level, exponent) + base);
experience = (int) Math.floor( skillSystemMultiplier * (multiplier * Math.pow(level, exponent) + base));
experienceNeededExponential.put(level, experience);
}

View File

@ -0,0 +1,55 @@
package com.gmail.nossr50.util.skills;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.skills.SkillMilestone;
import com.gmail.nossr50.datatypes.skills.SubSkill;
import java.util.HashMap;
/**
* This Factory class builds SkillMilestone chains as needed
* SkillMilestones are stored in a hash map
*/
public class SkillMilestoneFactory {
private static HashMap<SubSkill, SkillMilestone> skillMilestoneMap;
/**
* Gets a the SkillMilestone chain for this subskill
* Builds that chain if it doesn't exist before returning the parent node
* @param subSkill The SubSkill to get the SkillMilestone chain for
* @return The parent node of the SkillMilestone chain for the target subskill
*/
public static SkillMilestone getSkillMilestone(SubSkill subSkill)
{
//Init the map
if(skillMilestoneMap == null)
skillMilestoneMap = new HashMap<>();
if(skillMilestoneMap.get(subSkill) == null)
return buildSkillMilestone(subSkill);
else
return skillMilestoneMap.get(subSkill);
}
/**
* Constructs a SkillMilestone chain for a given subskill
* @param subSkill The subskill to build the SkillMilestone chain for
* @return The base node of the SkillMilestone chain
*/
private static SkillMilestone buildSkillMilestone(SubSkill subSkill)
{
//Init our parent node
SkillMilestone newSkillMilestone = new SkillMilestone(subSkill, AdvancedConfig.getInstance().getSubSkillUnlockLevel(subSkill, 1));
//There's probably a better way to do this
for(int x = 0; x < subSkill.getNumRanks()-1; x++)
{
newSkillMilestone.addChildMilestone();
}
//DEBUG
System.out.println("Milestone constructed for "+subSkill);
return skillMilestoneMap.put(subSkill, newSkillMilestone);
}
}