2022-10-04 12:40:10 +02:00
|
|
|
/** Implementation for what happens when you destroy a BitNode */
|
2021-09-30 23:02:07 +02:00
|
|
|
import React from "react";
|
2022-10-10 00:42:14 +02:00
|
|
|
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";
|
2023-06-04 00:04:45 +02:00
|
|
|
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];
|
2023-04-18 09:19:45 +02:00
|
|
|
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
|
2023-04-18 09:19:45 +02:00
|
|
|
let lvl = Player.sourceFileLvl(bitNodeNumber);
|
2021-09-13 00:03:07 +02:00
|
|
|
|
2023-04-18 09:19:45 +02:00
|
|
|
if (lvl > 0) {
|
|
|
|
if (lvl >= 3 && bitNodeNumber !== 12) {
|
2021-09-13 00:03:07 +02:00
|
|
|
dialogBoxCreate(
|
2022-03-16 20:43:04 +01:00
|
|
|
`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 {
|
2023-04-18 09:19:45 +02:00
|
|
|
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 {
|
2023-04-18 09:19:45 +02:00
|
|
|
Player.sourceFiles.set(bitNodeNumber, 1);
|
2022-07-27 05:54:17 +02:00
|
|
|
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
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-04 00:04:45 +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) {
|
2022-07-27 05:54:17 +02:00
|
|
|
Player.skills.intelligence = 0;
|
|
|
|
Player.exp.intelligence = 0;
|
2022-04-07 01:30:08 +02:00
|
|
|
}
|
2022-07-27 05:54:17 +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
|
|
|
}
|
2023-06-04 00:04:45 +02:00
|
|
|
prestigeSourceFile(isFlume);
|
2021-09-13 00:03:07 +02:00
|
|
|
}
|