mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-18 20:25:45 +01:00
MESSAGES: Re-implement limit on Icarus messages after a bitnode is completed (#742)
This commit is contained in:
parent
93235570d0
commit
79b677973b
@ -58,7 +58,10 @@ function checkForMessagesToSend(): void {
|
|||||||
throw new Error("The world daemon is not a server???? Please un-break reality");
|
throw new Error("The world daemon is not a server???? Please un-break reality");
|
||||||
}
|
}
|
||||||
//If the daemon can be hacked, send the player icarus.msg
|
//If the daemon can be hacked, send the player icarus.msg
|
||||||
if (Player.skills.hacking >= worldDaemon.requiredHackingSkill) {
|
if (
|
||||||
|
Player.skills.hacking >= worldDaemon.requiredHackingSkill &&
|
||||||
|
(Player.sourceFiles.size === 0 || !recvd(MessageFilename.RedPill))
|
||||||
|
) {
|
||||||
sendMessage(MessageFilename.RedPill, Player.sourceFiles.size === 0);
|
sendMessage(MessageFilename.RedPill, Player.sourceFiles.size === 0);
|
||||||
}
|
}
|
||||||
//If the daemon cannot be hacked, send the player truthgazer.msg a single time.
|
//If the daemon cannot be hacked, send the player truthgazer.msg a single time.
|
||||||
|
62
test/jest/Messages/MessageHelper.test.ts
Normal file
62
test/jest/Messages/MessageHelper.test.ts
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
import { checkForMessagesToSend } from "../../../src/Message/MessageHelpers";
|
||||||
|
import * as dialogBoxCreate from "../../../src/ui/React/DialogBox";
|
||||||
|
import { Player } from "@player";
|
||||||
|
import "../../../src/ui/GameRoot";
|
||||||
|
import { AugmentationName } from "@enums";
|
||||||
|
import { AddToAllServers } from "../../../src/Server/AllServers";
|
||||||
|
import { Server } from "../../../src/Server/Server";
|
||||||
|
import { installAugmentations } from "../../../src/Augmentation/AugmentationHelpers";
|
||||||
|
import { initSourceFiles } from "../../../src/SourceFile/SourceFiles";
|
||||||
|
|
||||||
|
jest.mock("../../../src/ui/GameRoot", () => ({
|
||||||
|
Router: {
|
||||||
|
page: () => ({}),
|
||||||
|
toPage: () => ({}),
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
jest.mock("../../../src/ui/React/DialogBox", () => ({
|
||||||
|
dialogBoxCreate: jest.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
|
AddToAllServers(new Server({ hostname: "home" }));
|
||||||
|
|
||||||
|
describe("MessageHelpers tests", () => {
|
||||||
|
afterEach(() => {
|
||||||
|
jest.clearAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Should repeatedly send the Icarus message on the player's first bitnode", () => {
|
||||||
|
Player.queueAugmentation(AugmentationName.TheRedPill);
|
||||||
|
installAugmentations();
|
||||||
|
Player.gainHackingExp(2 ** 200);
|
||||||
|
|
||||||
|
const showMessageSpy = jest.spyOn(dialogBoxCreate, "dialogBoxCreate");
|
||||||
|
|
||||||
|
checkForMessagesToSend();
|
||||||
|
checkForMessagesToSend();
|
||||||
|
|
||||||
|
// Called once for installing augmentations, and once for each
|
||||||
|
// checkForMessagesToSend() sending an Icarus message
|
||||||
|
expect(showMessageSpy).toHaveBeenCalledTimes(3);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Should not repeatedly send the Icarus message after the player's first bitnode completion", () => {
|
||||||
|
initSourceFiles();
|
||||||
|
Player.sourceFiles.set(1, 1);
|
||||||
|
Player.queueAugmentation(AugmentationName.TheRedPill);
|
||||||
|
installAugmentations();
|
||||||
|
Player.gainHackingExp(2 ** 200);
|
||||||
|
|
||||||
|
const showMessageSpy = jest.spyOn(dialogBoxCreate, "dialogBoxCreate");
|
||||||
|
|
||||||
|
checkForMessagesToSend();
|
||||||
|
checkForMessagesToSend();
|
||||||
|
checkForMessagesToSend();
|
||||||
|
checkForMessagesToSend();
|
||||||
|
|
||||||
|
// Called once for installing augmentations, and only once for any number of
|
||||||
|
// checkForMessagesToSend() ( sending an Icarus message only the first time)
|
||||||
|
expect(showMessageSpy).toHaveBeenCalledTimes(2);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user