bitburner-src/src/RedPill.jsx

90 lines
2.6 KiB
React
Raw Normal View History

2021-09-13 00:03:07 +02:00
/**
* Implementation for what happens when you destroy a BitNode
*/
import { Player } from "./Player";
import { prestigeSourceFile } from "./Prestige";
import { PlayerOwnedSourceFile } from "./SourceFile/PlayerOwnedSourceFile";
import { SourceFileFlags } from "./SourceFile/SourceFileFlags";
import { SourceFiles } from "./SourceFile/SourceFiles";
import { dialogBoxCreate } from "../utils/DialogBox";
let redPillFlag = false;
2021-09-18 01:43:08 +02:00
function hackWorldDaemon(router, flume = false, quick = false) {
router.toBitVerse(flume, quick);
2021-09-14 20:10:59 +02:00
redPillFlag = true;
2021-09-13 00:03:07 +02:00
}
function giveSourceFile(bitNodeNumber) {
var sourceFileKey = "SourceFile" + bitNodeNumber.toString();
var sourceFile = SourceFiles[sourceFileKey];
if (sourceFile == null) {
console.error(`Could not find source file for Bit node: ${bitNodeNumber}`);
return;
}
// Check if player already has this source file
var alreadyOwned = false;
var ownedSourceFile = null;
for (var i = 0; i < Player.sourceFiles.length; ++i) {
if (Player.sourceFiles[i].n === bitNodeNumber) {
alreadyOwned = true;
ownedSourceFile = Player.sourceFiles[i];
break;
}
}
if (alreadyOwned && ownedSourceFile) {
if (ownedSourceFile.lvl >= 3 && ownedSourceFile.n !== 12) {
dialogBoxCreate(
"The Source-File for the BitNode you just destroyed, " + sourceFile.name + ", " + "is already at max level!",
);
} else {
++ownedSourceFile.lvl;
dialogBoxCreate(
sourceFile.name +
" was upgraded to level " +
ownedSourceFile.lvl +
" for " +
"destroying its corresponding BitNode!",
);
}
} else {
var playerSrcFile = new PlayerOwnedSourceFile(bitNodeNumber, 1);
Player.sourceFiles.push(playerSrcFile);
if (bitNodeNumber === 5 && Player.intelligence === 0) {
// Artificial Intelligence
Player.intelligence = 1;
}
dialogBoxCreate(
2021-09-18 01:43:08 +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
);
}
}
2021-09-18 01:43:08 +02:00
export function enterBitNode(router, flume, destroyedBitNode, newBitNode) {
2021-09-13 00:03:07 +02:00
if (!flume) {
giveSourceFile(destroyedBitNode);
} else {
if (SourceFileFlags[5] === 0 && newBitNode !== 5) {
Player.intelligence = 0;
Player.intelligence_exp = 0;
}
}
if (newBitNode === 5 && Player.intelligence === 0) {
Player.intelligence = 1;
}
redPillFlag = false;
// Set new Bit Node
Player.bitNodeN = newBitNode;
2021-09-18 01:43:08 +02:00
if (newBitNode === 6) {
router.toBladeburnerCinematic();
} else {
router.toTerminal();
}
2021-09-13 00:03:07 +02:00
prestigeSourceFile(flume);
}
export { redPillFlag, hackWorldDaemon };