mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-03 06:17:04 +02:00
extract multipliers in its own type
This commit is contained in:
+13
-88
@@ -7,6 +7,7 @@ import { CONSTANTS } from "../Constants";
|
||||
import { calculateSkill } from "./formulas/skill";
|
||||
import { calculateIntelligenceBonus } from "./formulas/intelligence";
|
||||
import { IPerson } from "./IPerson";
|
||||
import { defaultMultipliers, mergeMultipliers, Multipliers } from "./Multipliers";
|
||||
|
||||
// Base class representing a person-like object
|
||||
export abstract class Person implements IPerson {
|
||||
@@ -34,46 +35,7 @@ export abstract class Person implements IPerson {
|
||||
charisma_exp = 0;
|
||||
intelligence_exp = 0;
|
||||
|
||||
/**
|
||||
* Multipliers
|
||||
*/
|
||||
hacking_mult = 1;
|
||||
strength_mult = 1;
|
||||
defense_mult = 1;
|
||||
dexterity_mult = 1;
|
||||
agility_mult = 1;
|
||||
charisma_mult = 1;
|
||||
|
||||
hacking_exp_mult = 1;
|
||||
strength_exp_mult = 1;
|
||||
defense_exp_mult = 1;
|
||||
dexterity_exp_mult = 1;
|
||||
agility_exp_mult = 1;
|
||||
charisma_exp_mult = 1;
|
||||
|
||||
hacking_chance_mult = 1;
|
||||
hacking_speed_mult = 1;
|
||||
hacking_money_mult = 1;
|
||||
hacking_grow_mult = 1;
|
||||
|
||||
company_rep_mult = 1;
|
||||
faction_rep_mult = 1;
|
||||
|
||||
crime_money_mult = 1;
|
||||
crime_success_mult = 1;
|
||||
|
||||
work_money_mult = 1;
|
||||
|
||||
hacknet_node_money_mult = 1;
|
||||
hacknet_node_purchase_cost_mult = 1;
|
||||
hacknet_node_ram_cost_mult = 1;
|
||||
hacknet_node_core_cost_mult = 1;
|
||||
hacknet_node_level_cost_mult = 1;
|
||||
|
||||
bladeburner_max_stamina_mult = 1;
|
||||
bladeburner_stamina_gain_mult = 1;
|
||||
bladeburner_analysis_mult = 1;
|
||||
bladeburner_success_chance_mult = 1;
|
||||
mults = defaultMultipliers();
|
||||
|
||||
/**
|
||||
* Augmentations
|
||||
@@ -101,13 +63,7 @@ export abstract class Person implements IPerson {
|
||||
* Updates this object's multipliers for the given augmentation
|
||||
*/
|
||||
applyAugmentation(aug: Augmentation): void {
|
||||
for (const mult of Object.keys(aug.mults)) {
|
||||
if ((this as any)[mult] == null) {
|
||||
console.warn(`Augmentation has unrecognized multiplier property: ${mult}`);
|
||||
} else {
|
||||
(this as any)[mult] *= aug.mults[mult];
|
||||
}
|
||||
}
|
||||
this.mults = mergeMultipliers(this.mults, aug.mults);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,7 +88,7 @@ export abstract class Person implements IPerson {
|
||||
this.agility / CONSTANTS.MaxSkillLevel +
|
||||
this.charisma / CONSTANTS.MaxSkillLevel)) /
|
||||
5.5;
|
||||
return t * this.faction_rep_mult;
|
||||
return t * this.mults.faction_rep;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,7 +96,7 @@ export abstract class Person implements IPerson {
|
||||
* when doing Hacking Work for a faction
|
||||
*/
|
||||
getFactionHackingWorkRepGain(): number {
|
||||
return (this.hacking / CONSTANTS.MaxSkillLevel) * this.faction_rep_mult;
|
||||
return (this.hacking / CONSTANTS.MaxSkillLevel) * this.mults.faction_rep;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,45 +112,14 @@ export abstract class Person implements IPerson {
|
||||
this.dexterity / CONSTANTS.MaxSkillLevel +
|
||||
this.agility / CONSTANTS.MaxSkillLevel)) /
|
||||
4.5;
|
||||
return t * this.faction_rep_mult;
|
||||
return t * this.mults.faction_rep;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset all multipliers to 1
|
||||
*/
|
||||
resetMultipliers(): void {
|
||||
this.hacking_mult = 1;
|
||||
this.strength_mult = 1;
|
||||
this.defense_mult = 1;
|
||||
this.dexterity_mult = 1;
|
||||
this.agility_mult = 1;
|
||||
this.charisma_mult = 1;
|
||||
|
||||
this.hacking_exp_mult = 1;
|
||||
this.strength_exp_mult = 1;
|
||||
this.defense_exp_mult = 1;
|
||||
this.dexterity_exp_mult = 1;
|
||||
this.agility_exp_mult = 1;
|
||||
this.charisma_exp_mult = 1;
|
||||
|
||||
this.company_rep_mult = 1;
|
||||
this.faction_rep_mult = 1;
|
||||
|
||||
this.crime_money_mult = 1;
|
||||
this.crime_success_mult = 1;
|
||||
|
||||
this.work_money_mult = 1;
|
||||
|
||||
this.hacknet_node_money_mult = 1;
|
||||
this.hacknet_node_purchase_cost_mult = 1;
|
||||
this.hacknet_node_ram_cost_mult = 1;
|
||||
this.hacknet_node_core_cost_mult = 1;
|
||||
this.hacknet_node_level_cost_mult = 1;
|
||||
|
||||
this.bladeburner_max_stamina_mult = 1;
|
||||
this.bladeburner_stamina_gain_mult = 1;
|
||||
this.bladeburner_analysis_mult = 1;
|
||||
this.bladeburner_success_chance_mult = 1;
|
||||
this.mults = defaultMultipliers();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -203,32 +128,32 @@ export abstract class Person implements IPerson {
|
||||
updateStatLevels(): void {
|
||||
this.hacking = Math.max(
|
||||
1,
|
||||
Math.floor(this.calculateStat(this.hacking_exp, this.hacking_mult * BitNodeMultipliers.HackingLevelMultiplier)),
|
||||
Math.floor(this.calculateStat(this.hacking_exp, this.mults.hacking * BitNodeMultipliers.HackingLevelMultiplier)),
|
||||
);
|
||||
this.strength = Math.max(
|
||||
1,
|
||||
Math.floor(
|
||||
this.calculateStat(this.strength_exp, this.strength_mult * BitNodeMultipliers.StrengthLevelMultiplier),
|
||||
this.calculateStat(this.strength_exp, this.mults.strength * BitNodeMultipliers.StrengthLevelMultiplier),
|
||||
),
|
||||
);
|
||||
this.defense = Math.max(
|
||||
1,
|
||||
Math.floor(this.calculateStat(this.defense_exp, this.defense_mult * BitNodeMultipliers.DefenseLevelMultiplier)),
|
||||
Math.floor(this.calculateStat(this.defense_exp, this.mults.defense * BitNodeMultipliers.DefenseLevelMultiplier)),
|
||||
);
|
||||
this.dexterity = Math.max(
|
||||
1,
|
||||
Math.floor(
|
||||
this.calculateStat(this.dexterity_exp, this.dexterity_mult * BitNodeMultipliers.DexterityLevelMultiplier),
|
||||
this.calculateStat(this.dexterity_exp, this.mults.dexterity * BitNodeMultipliers.DexterityLevelMultiplier),
|
||||
),
|
||||
);
|
||||
this.agility = Math.max(
|
||||
1,
|
||||
Math.floor(this.calculateStat(this.agility_exp, this.agility_mult * BitNodeMultipliers.AgilityLevelMultiplier)),
|
||||
Math.floor(this.calculateStat(this.agility_exp, this.mults.agility * BitNodeMultipliers.AgilityLevelMultiplier)),
|
||||
);
|
||||
this.charisma = Math.max(
|
||||
1,
|
||||
Math.floor(
|
||||
this.calculateStat(this.charisma_exp, this.charisma_mult * BitNodeMultipliers.CharismaLevelMultiplier),
|
||||
this.calculateStat(this.charisma_exp, this.mults.charisma * BitNodeMultipliers.CharismaLevelMultiplier),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user