mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-17 23:08:36 +02:00
BUGFIX: Duplicated augmentation when buying after grafting (#1536)
This commit is contained in:
@@ -20,12 +20,19 @@ export function AugmentationsDev(): React.ReactElement {
|
|||||||
function setAugmentationDropdown(event: SelectChangeEvent): void {
|
function setAugmentationDropdown(event: SelectChangeEvent): void {
|
||||||
setAugmentation(event.target.value as AugmentationName);
|
setAugmentation(event.target.value as AugmentationName);
|
||||||
}
|
}
|
||||||
|
|
||||||
function queueAug(): void {
|
function queueAug(): void {
|
||||||
|
if (Player.hasAugmentation(augmentation)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Player.queueAugmentation(augmentation);
|
Player.queueAugmentation(augmentation);
|
||||||
}
|
}
|
||||||
|
|
||||||
function queueAllAugs(): void {
|
function queueAllAugs(): void {
|
||||||
for (const augName of Object.values(AugmentationName)) {
|
for (const augName of Object.values(AugmentationName)) {
|
||||||
|
if (Player.hasAugmentation(augName)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
Player.queueAugmentation(augName);
|
Player.queueAugmentation(augName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import type { Augmentation } from "../Augmentation/Augmentation";
|
|||||||
import type { Faction } from "./Faction";
|
import type { Faction } from "./Faction";
|
||||||
|
|
||||||
import { Augmentations } from "../Augmentation/Augmentations";
|
import { Augmentations } from "../Augmentation/Augmentations";
|
||||||
import { PlayerOwnedAugmentation } from "../Augmentation/PlayerOwnedAugmentation";
|
|
||||||
import { AugmentationName, FactionDiscovery } from "@enums";
|
import { AugmentationName, FactionDiscovery } from "@enums";
|
||||||
import { currentNodeMults } from "../BitNode/BitNodeMultipliers";
|
import { currentNodeMults } from "../BitNode/BitNodeMultipliers";
|
||||||
|
|
||||||
@@ -84,11 +83,7 @@ export function purchaseAugmentation(aug: Augmentation, fac: Faction, sing = fal
|
|||||||
}
|
}
|
||||||
dialogBoxCreate(txt);
|
dialogBoxCreate(txt);
|
||||||
} else if (augCosts.moneyCost === 0 || Player.money >= augCosts.moneyCost) {
|
} else if (augCosts.moneyCost === 0 || Player.money >= augCosts.moneyCost) {
|
||||||
const queuedAugmentation = new PlayerOwnedAugmentation(aug.name);
|
Player.queueAugmentation(aug.name);
|
||||||
if (aug.name == AugmentationName.NeuroFluxGovernor) {
|
|
||||||
queuedAugmentation.level = aug.getNextLevel();
|
|
||||||
}
|
|
||||||
Player.queuedAugmentations.push(queuedAugmentation);
|
|
||||||
|
|
||||||
Player.loseMoney(augCosts.moneyCost, "augmentations");
|
Player.loseMoney(augCosts.moneyCost, "augmentations");
|
||||||
|
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ export const GraftingRoot = (): React.ReactElement => {
|
|||||||
Router.toPage(Page.Work);
|
Router.toPage(Page.Work);
|
||||||
}}
|
}}
|
||||||
confirmationText={
|
confirmationText={
|
||||||
<>
|
<Typography component="div" paddingBottom="1rem">
|
||||||
Cancelling grafting will <b>not</b> save grafting progress, and the money you spend will <b>not</b>{" "}
|
Cancelling grafting will <b>not</b> save grafting progress, and the money you spend will <b>not</b>{" "}
|
||||||
be returned.
|
be returned.
|
||||||
{!Player.hasAugmentation(AugmentationName.CongruityImplant) && (
|
{!Player.hasAugmentation(AugmentationName.CongruityImplant) && (
|
||||||
@@ -166,7 +166,7 @@ export const GraftingRoot = (): React.ReactElement => {
|
|||||||
Additionally, grafting an Augmentation will increase the potency of the Entropy virus.
|
Additionally, grafting an Augmentation will increase the potency of the Entropy virus.
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</>
|
</Typography>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Box sx={{ maxHeight: 330, overflowY: "scroll" }}>
|
<Box sx={{ maxHeight: 330, overflowY: "scroll" }}>
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ import { achievements } from "../../Achievements/Achievements";
|
|||||||
import { isCompanyWork } from "../../Work/CompanyWork";
|
import { isCompanyWork } from "../../Work/CompanyWork";
|
||||||
import { isMember } from "../../utils/EnumHelper";
|
import { isMember } from "../../utils/EnumHelper";
|
||||||
import { canAccessBitNodeFeature } from "../../BitNode/BitNodeUtils";
|
import { canAccessBitNodeFeature } from "../../BitNode/BitNodeUtils";
|
||||||
|
import { AlertEvents } from "../../ui/React/AlertManager";
|
||||||
|
import { Augmentations } from "../../Augmentation/Augmentations";
|
||||||
|
|
||||||
export function init(this: PlayerObject): void {
|
export function init(this: PlayerObject): void {
|
||||||
/* Initialize Player's home computer */
|
/* 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 {
|
export function queueAugmentation(this: PlayerObject, name: AugmentationName): void {
|
||||||
for (const aug of this.queuedAugmentations) {
|
if (name !== AugmentationName.NeuroFluxGovernor) {
|
||||||
if (aug.name == name) {
|
for (const aug of this.queuedAugmentations) {
|
||||||
console.warn(`tried to queue ${name} twice, this may be a bug`);
|
if (name === aug.name) {
|
||||||
return;
|
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) {
|
const queuedAugmentation = new PlayerOwnedAugmentation(name);
|
||||||
if (aug.name == name) {
|
if (name === AugmentationName.NeuroFluxGovernor) {
|
||||||
console.warn(`tried to queue ${name} twice, this may be a bug`);
|
const augmentation = Augmentations[name];
|
||||||
return;
|
queuedAugmentation.level = augmentation.getNextLevel();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
this.queuedAugmentations.push(queuedAugmentation);
|
||||||
this.queuedAugmentations.push(new PlayerOwnedAugmentation(name));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************* Coding Contracts **************/
|
/************* Coding Contracts **************/
|
||||||
|
|||||||
@@ -59,6 +59,14 @@ export class GraftingWork extends Work {
|
|||||||
if (!cancelled) {
|
if (!cancelled) {
|
||||||
applyAugmentation({ name: augName, level: 1 });
|
applyAugmentation({ name: augName, level: 1 });
|
||||||
|
|
||||||
|
// Remove this augmentation from the list of queued augmentations.
|
||||||
|
for (let i = 0; i < Player.queuedAugmentations.length; ++i) {
|
||||||
|
if (Player.queuedAugmentations[i].name === augName) {
|
||||||
|
Player.queuedAugmentations.splice(i, 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!Player.hasAugmentation(AugmentationName.CongruityImplant, true)) {
|
if (!Player.hasAugmentation(AugmentationName.CongruityImplant, true)) {
|
||||||
Player.entropy += 1;
|
Player.entropy += 1;
|
||||||
Player.applyEntropy(Player.entropy);
|
Player.applyEntropy(Player.entropy);
|
||||||
|
|||||||
Reference in New Issue
Block a user