mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-28 08:57:32 +01:00
40 lines
1023 B
TypeScript
40 lines
1023 B
TypeScript
/**
|
|
* Augmentation-related methods for the Player class (PlayerObject)
|
|
*/
|
|
import { IPlayer } from "../IPlayer";
|
|
|
|
import { Augmentation } from "../../Augmentation/Augmentation";
|
|
|
|
import { calculateEntropy } from "../Grafting/EntropyAccumulation";
|
|
|
|
export function hasAugmentation(this: IPlayer, aug: string | Augmentation, ignoreQueued = false): boolean {
|
|
const augName: string = aug instanceof Augmentation ? aug.name : aug;
|
|
|
|
for (const owned of this.augmentations) {
|
|
if (owned.name === augName) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
if (!ignoreQueued) {
|
|
for (const owned of this.queuedAugmentations) {
|
|
if (owned.name === augName) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
export function applyEntropy(this: IPlayer, stacks = 1): void {
|
|
// Re-apply all multipliers
|
|
this.reapplyAllAugmentations();
|
|
this.reapplyAllSourceFiles();
|
|
|
|
const newMultipliers = calculateEntropy(this, stacks);
|
|
for (const [mult, val] of Object.entries(newMultipliers)) {
|
|
this.setMult(mult, val);
|
|
}
|
|
}
|