bitburner-src/src/RedPill.tsx

71 lines
2.1 KiB
TypeScript
Raw Normal View History

/** Implementation for what happens when you destroy a BitNode */
2021-09-30 23:02:07 +02:00
import React from "react";
import { Player } from "@player";
2021-09-13 00:03:07 +02:00
import { SourceFiles } from "./SourceFile/SourceFiles";
2021-09-25 20:42:57 +02:00
import { dialogBoxCreate } from "./ui/React/DialogBox";
2022-09-13 00:00:09 +02:00
import { Router } from "./ui/GameRoot";
2022-12-04 09:14:06 +01:00
import { Page } from "./ui/Router";
import { prestigeSourceFile } from "./Prestige";
2021-09-13 00:03:07 +02:00
2021-09-24 22:37:42 +02:00
function giveSourceFile(bitNodeNumber: number): void {
2021-09-25 07:26:03 +02:00
const sourceFileKey = "SourceFile" + bitNodeNumber.toString();
const sourceFile = SourceFiles[sourceFileKey];
if (!sourceFile) {
2021-09-13 00:03:07 +02:00
console.error(`Could not find source file for Bit node: ${bitNodeNumber}`);
return;
}
// Check if player already has this source file
let lvl = Player.sourceFileLvl(bitNodeNumber);
2021-09-13 00:03:07 +02:00
if (lvl > 0) {
if (lvl >= 3 && bitNodeNumber !== 12) {
2021-09-13 00:03:07 +02:00
dialogBoxCreate(
`The Source-File for the BitNode you just destroyed, ${sourceFile.name}, is already at max level!`,
2021-09-13 00:03:07 +02:00
);
} else {
lvl++;
Player.sourceFiles.set(bitNodeNumber, lvl);
dialogBoxCreate(`${sourceFile.name} was upgraded to level ${lvl} for destroying its corresponding BitNode!`);
2021-09-13 00:03:07 +02:00
}
} else {
Player.sourceFiles.set(bitNodeNumber, 1);
if (bitNodeNumber === 5 && Player.skills.intelligence === 0) {
Player.skills.intelligence = 1;
2021-09-13 00:03:07 +02:00
}
dialogBoxCreate(
2021-09-30 23:02:07 +02:00
<>
You received a Source-File for destroying a BitNode!
<br />
<br />
{sourceFile.name}
<br />
<br />
{sourceFile.info}
</>,
2021-09-13 00:03:07 +02:00
);
}
}
export function enterBitNode(isFlume: boolean, destroyedBitNode: number, newBitNode: number): void {
if (!isFlume) {
2021-09-13 00:03:07 +02:00
giveSourceFile(destroyedBitNode);
2022-04-14 07:22:50 +02:00
} else if (Player.sourceFileLvl(5) === 0 && newBitNode !== 5) {
Player.skills.intelligence = 0;
Player.exp.intelligence = 0;
2022-04-07 01:30:08 +02:00
}
if (newBitNode === 5 && Player.skills.intelligence === 0) {
Player.skills.intelligence = 1;
2021-09-13 00:03:07 +02:00
}
// Set new Bit Node
Player.bitNodeN = newBitNode;
2021-09-18 01:43:08 +02:00
if (newBitNode === 6) {
2022-12-04 09:14:06 +01:00
Router.toPage(Page.BladeburnerCinematic);
2021-09-18 01:43:08 +02:00
} else {
2022-12-04 09:14:06 +01:00
Router.toPage(Page.Terminal);
2021-09-18 01:43:08 +02:00
}
prestigeSourceFile(isFlume);
2021-09-13 00:03:07 +02:00
}