mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-16 06:18:42 +02:00
CODEBASE: Refactor duplicate code in updateSkillLevels (#1988)
This commit is contained in:
@@ -175,36 +175,19 @@ export abstract class Person implements IPerson {
|
||||
}
|
||||
|
||||
updateSkillLevels(this: Person): void {
|
||||
this.skills.hacking = Math.max(
|
||||
1,
|
||||
Math.floor(this.calculateSkill(this.exp.hacking, this.mults.hacking * currentNodeMults.HackingLevelMultiplier)),
|
||||
);
|
||||
this.skills.strength = Math.max(
|
||||
1,
|
||||
Math.floor(
|
||||
this.calculateSkill(this.exp.strength, this.mults.strength * currentNodeMults.StrengthLevelMultiplier),
|
||||
),
|
||||
);
|
||||
this.skills.defense = Math.max(
|
||||
1,
|
||||
Math.floor(this.calculateSkill(this.exp.defense, this.mults.defense * currentNodeMults.DefenseLevelMultiplier)),
|
||||
);
|
||||
this.skills.dexterity = Math.max(
|
||||
1,
|
||||
Math.floor(
|
||||
this.calculateSkill(this.exp.dexterity, this.mults.dexterity * currentNodeMults.DexterityLevelMultiplier),
|
||||
),
|
||||
);
|
||||
this.skills.agility = Math.max(
|
||||
1,
|
||||
Math.floor(this.calculateSkill(this.exp.agility, this.mults.agility * currentNodeMults.AgilityLevelMultiplier)),
|
||||
);
|
||||
this.skills.charisma = Math.max(
|
||||
1,
|
||||
Math.floor(
|
||||
this.calculateSkill(this.exp.charisma, this.mults.charisma * currentNodeMults.CharismaLevelMultiplier),
|
||||
),
|
||||
);
|
||||
for (const [skill, bnMult] of [
|
||||
["hacking", "HackingLevelMultiplier"],
|
||||
["strength", "StrengthLevelMultiplier"],
|
||||
["defense", "DefenseLevelMultiplier"],
|
||||
["dexterity", "DexterityLevelMultiplier"],
|
||||
["agility", "AgilityLevelMultiplier"],
|
||||
["charisma", "CharismaLevelMultiplier"],
|
||||
] as const) {
|
||||
this.skills[skill] = Math.max(
|
||||
1,
|
||||
Math.floor(this.calculateSkill(this.exp[skill], this.mults[skill] * currentNodeMults[bnMult])),
|
||||
);
|
||||
}
|
||||
|
||||
const ratio: number = Math.min(this.hp.current / this.hp.max, 1);
|
||||
this.hp.max = Math.floor(10 + this.skills.defense / 10);
|
||||
|
||||
Reference in New Issue
Block a user