bitburner-src/src/PersonObjects/Player/PlayerObjectAugmentationMethods.ts

40 lines
1023 B
TypeScript
Raw Normal View History

/**
* Augmentation-related methods for the Player class (PlayerObject)
*/
import { IPlayer } from "../IPlayer";
import { Augmentation } from "../../Augmentation/Augmentation";
2022-03-21 20:30:03 +01:00
import { calculateEntropy } from "../Grafting/EntropyAccumulation";
2022-03-19 19:15:31 +01:00
2022-04-22 21:30:49 +02:00
export function hasAugmentation(this: IPlayer, aug: string | Augmentation, ignoreQueued = false): boolean {
2021-09-05 01:09:30 +02:00
const augName: string = aug instanceof Augmentation ? aug.name : aug;
2021-09-05 01:09:30 +02:00
for (const owned of this.augmentations) {
if (owned.name === augName) {
return true;
}
2021-09-05 01:09:30 +02:00
}
2022-04-22 21:30:49 +02:00
if (!ignoreQueued) {
2021-11-12 22:54:34 +01:00
for (const owned of this.queuedAugmentations) {
if (owned.name === augName) {
return true;
}
}
2021-09-05 01:09:30 +02:00
}
2021-09-05 01:09:30 +02:00
return false;
}
2022-03-19 19:15:31 +01:00
export function applyEntropy(this: IPlayer, stacks = 1): void {
// Re-apply all multipliers
this.reapplyAllAugmentations();
this.reapplyAllSourceFiles();
2022-03-19 19:15:31 +01:00
const newMultipliers = calculateEntropy(this, stacks);
for (const [mult, val] of Object.entries(newMultipliers)) {
this.setMult(mult, val);
}
}