BUGFIX: Duplicated augmentation when buying after grafting (#1536)

This commit is contained in:
catloversg
2024-08-05 03:11:00 +07:00
committed by GitHub
parent e5a63b4116
commit eeac3f7dd1
5 changed files with 40 additions and 19 deletions
@@ -50,6 +50,8 @@ import { achievements } from "../../Achievements/Achievements";
import { isCompanyWork } from "../../Work/CompanyWork";
import { isMember } from "../../utils/EnumHelper";
import { canAccessBitNodeFeature } from "../../BitNode/BitNodeUtils";
import { AlertEvents } from "../../ui/React/AlertManager";
import { Augmentations } from "../../Augmentation/Augmentations";
export function init(this: PlayerObject): void {
/* Initialize Player's home computer */
@@ -455,21 +457,30 @@ export function setBitNodeNumber(this: PlayerObject, n: number): void {
}
export function queueAugmentation(this: PlayerObject, name: AugmentationName): void {
for (const aug of this.queuedAugmentations) {
if (aug.name == name) {
console.warn(`tried to queue ${name} twice, this may be a bug`);
return;
if (name !== AugmentationName.NeuroFluxGovernor) {
for (const aug of this.queuedAugmentations) {
if (name === aug.name) {
AlertEvents.emit(`Tried to queue ${name} twice. This is a bug. Please contact developers.`);
return;
}
}
for (const aug of this.augmentations) {
if (aug.name === name) {
AlertEvents.emit(
`Tried to queue ${name}, but this augmentation was installed. This is a bug. Please contact developers.`,
);
return;
}
}
}
for (const aug of this.augmentations) {
if (aug.name == name) {
console.warn(`tried to queue ${name} twice, this may be a bug`);
return;
}
const queuedAugmentation = new PlayerOwnedAugmentation(name);
if (name === AugmentationName.NeuroFluxGovernor) {
const augmentation = Augmentations[name];
queuedAugmentation.level = augmentation.getNextLevel();
}
this.queuedAugmentations.push(new PlayerOwnedAugmentation(name));
this.queuedAugmentations.push(queuedAugmentation);
}
/************* Coding Contracts **************/