bitburner-src/src/Prestige.ts

280 lines
8.7 KiB
TypeScript
Raw Normal View History

import { Augmentations } from "./Augmentation/Augmentations";
2021-09-09 05:47:34 +02:00
import { augmentationExists, initAugmentations } from "./Augmentation/AugmentationHelpers";
import { AugmentationNames } from "./Augmentation/data/AugmentationNames";
import { initBitNodeMultipliers } from "./BitNode/BitNode";
import { Bladeburner } from "./Bladeburner/Bladeburner";
import { Companies, initCompanies } from "./Company/Companies";
import { resetIndustryResearchTrees } from "./Corporation/IndustryData";
import { Programs } from "./Programs/Programs";
import { Faction } from "./Faction/Faction";
import { Factions, initFactions } from "./Faction/Factions";
import { joinFaction } from "./Faction/FactionHelpers";
import { updateHashManagerCapacity } from "./Hacknet/HacknetHelpers";
2021-05-01 09:17:31 +02:00
import { initMessages } from "./Message/MessageHelpers";
import { prestigeWorkerScripts } from "./NetscriptWorker";
import { Player } from "./Player";
2021-09-24 23:07:53 +02:00
import { Router } from "./ui/GameRoot";
import { resetPidCounter } from "./Netscript/Pid";
2021-09-05 01:09:30 +02:00
import { LiteratureNames } from "./Literature/data/LiteratureNames";
2018-03-12 20:39:04 +01:00
2021-10-07 22:56:01 +02:00
import { GetServer, AddToAllServers, initForeignServers, prestigeAllServers } from "./Server/AllServers";
import { prestigeHomeComputer } from "./Server/ServerHelpers";
2021-09-09 05:47:34 +02:00
import { SourceFileFlags, updateSourceFileFlags } from "./SourceFile/SourceFileFlags";
2021-10-07 23:55:49 +02:00
import { SpecialServers } from "./Server/data/SpecialServers";
2021-09-09 05:47:34 +02:00
import { deleteStockMarket, initStockMarket, initSymbolToStockMap } from "./StockMarket/StockMarket";
2021-09-16 08:52:45 +02:00
import { Terminal } from "./Terminal";
2019-02-09 03:46:30 +01:00
2021-09-25 20:42:57 +02:00
import { dialogBoxCreate } from "./ui/React/DialogBox";
2017-02-20 23:06:16 +01:00
import Decimal from "decimal.js";
2021-10-23 21:22:58 +02:00
import { ProgramsSeen } from "./Programs/ui/ProgramsRoot";
import { InvitationsSeen } from "./Faction/ui/FactionsRoot";
const BitNode8StartingMoney = 250e6;
2018-06-03 03:37:56 +02:00
// Prestige by purchasing augmentation
2021-10-23 16:08:06 +02:00
export function prestigeAugmentation(): void {
2021-09-05 01:09:30 +02:00
initBitNodeMultipliers(Player);
const maintainMembership = Player.factions.filter(function (faction) {
return Factions[faction].getInfo().keep;
2021-09-13 21:39:25 +02:00
});
2021-09-05 01:09:30 +02:00
Player.prestigeAugmentation();
// Delete all Worker Scripts objects
prestigeWorkerScripts();
2021-09-24 23:07:53 +02:00
const homeComp = Player.getHomeComputer();
2021-09-05 01:09:30 +02:00
// Delete all servers except home computer
prestigeAllServers();
// Reset home computer (only the programs) and add to AllServers
AddToAllServers(homeComp);
prestigeHomeComputer(homeComp);
2021-09-09 05:47:34 +02:00
if (augmentationExists(AugmentationNames.Neurolink) && Augmentations[AugmentationNames.Neurolink].owned) {
2021-09-05 01:09:30 +02:00
homeComp.programs.push(Programs.FTPCrackProgram.name);
homeComp.programs.push(Programs.RelaySMTPProgram.name);
}
2021-09-09 05:47:34 +02:00
if (augmentationExists(AugmentationNames.CashRoot) && Augmentations[AugmentationNames.CashRoot].owned) {
2021-09-05 01:09:30 +02:00
Player.setMoney(1e6);
homeComp.programs.push(Programs.BruteSSHProgram.name);
}
2021-09-09 05:47:34 +02:00
if (augmentationExists(AugmentationNames.PCMatrix) && Augmentations[AugmentationNames.PCMatrix].owned) {
2021-09-05 01:09:30 +02:00
homeComp.programs.push(Programs.DeepscanV1.name);
homeComp.programs.push(Programs.AutoLink.name);
}
2021-10-28 05:41:47 +02:00
if (Player.sourceFileLvl(5) > 0) {
homeComp.programs.push(Programs.Formulas.name);
}
2021-09-05 01:09:30 +02:00
// Re-create foreign servers
initForeignServers(Player.getHomeComputer());
// Gain favor for Companies
2021-09-24 23:07:53 +02:00
for (const member in Companies) {
2021-09-05 01:09:30 +02:00
if (Companies.hasOwnProperty(member)) {
Companies[member].gainFavor();
}
2021-09-05 01:09:30 +02:00
}
2021-09-05 01:09:30 +02:00
// Gain favor for factions
2021-09-24 23:07:53 +02:00
for (const member in Factions) {
2021-09-05 01:09:30 +02:00
if (Factions.hasOwnProperty(member)) {
Factions[member].gainFavor();
2017-02-20 23:06:16 +01:00
}
2021-09-05 01:09:30 +02:00
}
// Stop a Terminal action if there is onerror
2021-09-25 00:29:25 +02:00
if (Terminal.action !== null) {
2021-09-24 23:07:53 +02:00
Terminal.finishAction(Router, Player, true);
2021-09-05 01:09:30 +02:00
}
2021-10-07 22:56:01 +02:00
Terminal.clear();
2021-09-05 01:09:30 +02:00
// Re-initialize things - This will update any changes
initFactions(); // Factions must be initialized before augmentations
Player.factions = Player.factions.concat(maintainMembership);
Player.factions.map((f) => (Factions[f].isMember = true));
2021-09-05 01:09:30 +02:00
initAugmentations(); // Calls reapplyAllAugmentations() and resets Player multipliers
Player.reapplyAllSourceFiles();
initCompanies();
// Messages
initMessages();
// Gang
2021-09-24 23:07:53 +02:00
const gang = Player.gang;
if (Player.inGang() && gang !== null) {
const faction = Factions[gang.facName];
2021-09-05 01:09:30 +02:00
if (faction instanceof Faction) {
joinFaction(faction);
2017-02-20 23:06:16 +01:00
}
2021-09-05 01:09:30 +02:00
}
// Cancel Bladeburner action
if (Player.bladeburner instanceof Bladeburner) {
Player.bladeburner.prestige();
}
// BitNode 8: Ghost of Wall Street
if (Player.bitNodeN === 8) {
Player.money = new Decimal(BitNode8StartingMoney);
}
if (Player.bitNodeN === 8 || SourceFileFlags[8] > 0) {
Player.hasWseAccount = true;
Player.hasTixApiAccess = true;
}
// Reset Stock market
if (Player.hasWseAccount) {
initStockMarket();
initSymbolToStockMap();
}
// Red Pill
2021-09-09 05:47:34 +02:00
if (augmentationExists(AugmentationNames.TheRedPill) && Augmentations[AugmentationNames.TheRedPill].owned) {
2021-10-07 23:55:49 +02:00
const WorldDaemon = GetServer(SpecialServers.WorldDaemon);
const DaedalusServer = GetServer(SpecialServers.DaedalusServer);
2021-09-05 01:09:30 +02:00
if (WorldDaemon && DaedalusServer) {
2021-10-07 23:55:49 +02:00
WorldDaemon.serversOnNetwork.push(DaedalusServer.hostname);
DaedalusServer.serversOnNetwork.push(WorldDaemon.hostname);
2017-07-22 00:54:55 +02:00
}
2021-09-05 01:09:30 +02:00
}
2021-09-05 01:09:30 +02:00
resetPidCounter();
2021-10-23 21:22:58 +02:00
ProgramsSeen.splice(0, ProgramsSeen.length);
InvitationsSeen.splice(0, InvitationsSeen.length);
}
2017-08-13 07:01:33 +02:00
// Prestige by destroying Bit Node and gaining a Source File
2021-10-23 16:08:06 +02:00
export function prestigeSourceFile(flume: boolean): void {
2021-09-05 01:09:30 +02:00
initBitNodeMultipliers(Player);
updateSourceFileFlags(Player);
2021-09-05 01:09:30 +02:00
Player.prestigeSourceFile();
prestigeWorkerScripts(); // Delete all Worker Scripts objects
2021-09-25 07:26:03 +02:00
const homeComp = Player.getHomeComputer();
2017-08-13 07:01:33 +02:00
2021-09-05 01:09:30 +02:00
// Delete all servers except home computer
prestigeAllServers(); // Must be done before initForeignServers()
2021-09-05 01:09:30 +02:00
// Reset home computer (only the programs) and add to AllServers
AddToAllServers(homeComp);
prestigeHomeComputer(homeComp);
2017-08-13 07:01:33 +02:00
2021-09-05 01:09:30 +02:00
// Re-create foreign servers
initForeignServers(Player.getHomeComputer());
2017-08-13 07:01:33 +02:00
2021-09-05 01:09:30 +02:00
if (SourceFileFlags[9] >= 2) {
homeComp.setMaxRam(128);
} else if (SourceFileFlags[1] > 0) {
homeComp.setMaxRam(32);
} else {
homeComp.setMaxRam(8);
}
homeComp.cpuCores = 1;
2017-08-20 03:36:19 +02:00
2021-09-05 01:09:30 +02:00
// Reset favor for Companies
2021-09-25 07:26:03 +02:00
for (const member in Companies) {
2021-09-05 01:09:30 +02:00
if (Companies.hasOwnProperty(member)) {
Companies[member].favor = 0;
}
2021-09-05 01:09:30 +02:00
}
2021-09-05 01:09:30 +02:00
// Reset favor for factions
2021-09-25 07:26:03 +02:00
for (const member in Factions) {
2021-09-05 01:09:30 +02:00
if (Factions.hasOwnProperty(member)) {
Factions[member].favor = 0;
2018-03-12 20:39:04 +01:00
}
2021-09-05 01:09:30 +02:00
}
// Stop a Terminal action if there is one
2021-09-25 00:29:25 +02:00
if (Terminal.action !== null) {
2021-09-24 23:07:53 +02:00
Terminal.finishAction(Router, Player, true);
2021-09-05 01:09:30 +02:00
}
// Delete all Augmentations
2021-09-25 07:26:03 +02:00
for (const name in Augmentations) {
2021-09-05 01:09:30 +02:00
if (Augmentations.hasOwnProperty(name)) {
delete Augmentations[name];
2018-05-02 19:38:11 +02:00
}
2021-09-05 01:09:30 +02:00
}
// Give levels of NeuroFluxGoverner for Source-File 12. Must be done here before Augmentations are recalculated
if (SourceFileFlags[12] > 0) {
Player.augmentations.push({
name: AugmentationNames.NeuroFluxGovernor,
level: SourceFileFlags[12],
});
}
// Re-initialize things - This will update any changes
initFactions(); // Factions must be initialized before augmentations
initAugmentations(); // Calls reapplyAllAugmentations() and resets Player multipliers
Player.reapplyAllSourceFiles();
initCompanies();
// Messages
initMessages();
2021-10-28 05:41:47 +02:00
if (Player.sourceFileLvl(5) > 0) {
homeComp.programs.push(Programs.Formulas.name);
}
2021-09-05 01:09:30 +02:00
// BitNode 3: Corporatocracy
if (Player.bitNodeN === 3) {
homeComp.messages.push(LiteratureNames.CorporationManagementHandbook);
dialogBoxCreate(
"You received a copy of the Corporation Management Handbook on your home computer. " +
"Read it if you need help getting started with Corporations!",
);
}
// BitNode 8: Ghost of Wall Street
if (Player.bitNodeN === 8) {
Player.money = new Decimal(BitNode8StartingMoney);
}
if (Player.bitNodeN === 8 || SourceFileFlags[8] > 0) {
Player.hasWseAccount = true;
Player.hasTixApiAccess = true;
}
// Bit Node 10: Digital Carbon
if (Player.bitNodeN === 10) {
2021-09-09 05:47:34 +02:00
dialogBoxCreate("Visit VitaLife in New Tokyo if you'd like to purchase a new sleeve!");
2021-09-05 01:09:30 +02:00
}
// Reset Stock market, gang, and corporation
if (Player.hasWseAccount) {
initStockMarket();
initSymbolToStockMap();
} else {
deleteStockMarket();
}
Player.gang = null;
Player.corporation = null;
resetIndustryResearchTrees();
Player.bladeburner = null;
// Source-File 9 (level 3) effect
if (SourceFileFlags[9] >= 3) {
const hserver = Player.createHacknetServer();
hserver.level = 100;
hserver.cores = 10;
hserver.cache = 5;
hserver.updateHashRate(Player.hacknet_node_money_mult);
hserver.updateHashCapacity();
2021-09-09 09:17:01 +02:00
updateHashManagerCapacity(Player);
2021-09-05 01:09:30 +02:00
}
// Gain int exp
if (SourceFileFlags[5] !== 0 && !flume) Player.gainIntelligenceExp(300);
resetPidCounter();
2017-08-13 07:01:33 +02:00
}