From 51d927462699c65b98eb4dc9a04be7e3c701541b Mon Sep 17 00:00:00 2001 From: danielyxie Date: Fri, 29 Mar 2019 20:01:34 -0700 Subject: [PATCH] Added effects for Source-File 9 --- src/BitNode/BitNode.ts | 22 ++++++++++-- src/Hacknet/HacknetHelpers.jsx | 37 ++++++++++--------- src/NetscriptFunctions.js | 9 +++-- src/Player.js | 7 ++-- src/Prestige.js | 40 ++++++++++++--------- src/ScriptEditor/AceNetscriptMode.js | 4 +-- src/ScriptEditor/CodeMirrorNetscriptMode.js | 2 ++ src/SourceFile.js | 30 ++++++++++------ 8 files changed, 97 insertions(+), 54 deletions(-) diff --git a/src/BitNode/BitNode.ts b/src/BitNode/BitNode.ts index 5ea5e01f1..e90ed9157 100644 --- a/src/BitNode/BitNode.ts +++ b/src/BitNode/BitNode.ts @@ -176,7 +176,21 @@ export function initBitNodes() { BitNodes["BitNode9"] = new BitNode(9, "Hacktocracy", "Hacknet Unleashed", "When Fulcrum Technologies released their open-source Linux distro Chapeau, it quickly " + "became the OS of choice for the underground hacking community. Chapeau became especially notorious for " + - "powering the Hacknet, "); + "powering the Hacknet, a global, decentralized network used for nefarious purposes. Fulcrum quickly " + + "abandoned the project and dissociated themselves from it.

" + + "This BitNode unlocks the Hacknet Server, an upgraded version of the Hacknet Node. Hacknet Servers generate " + + "hashes, which can be spent on a variety of different upgrades.

" + + "In this BitNode:

" + + "Your stats are significantly decreased
" + + "You cannnot purchase additional servers
" + + "Hacking is significantly less profitable

" + + "Destroying this BitNode will give you Source-File 9, or if you already have this Source-File it will " + + "upgrade its level up to a maximum of 3. This Source-File grants the following benefits:

" + + "Level 1: Permanently unlocks the Hacknet Server in other BitNodes
" + + "Level 2: You start with 128GB of RAM on your home computer when entering a new BitNode
" + + "Level 3: Grants a highly-upgraded Hacknet Server when entering a new BitNode

" + + "(Note that the Level 3 effect of this Source-File only applies when entering a new BitNode, NOT " + + "when installing Augmentations)"); BitNodes["BitNode10"] = new BitNode(10, "Digital Carbon", "Your body is not who you are", "In 2084, VitaLife unveiled to the world the Persona Core, a technology that allowed people " + "to digitize their consciousness. Their consciousness could then be transferred into Synthoids " + @@ -186,7 +200,7 @@ export function initBitNodes() { "1. Re-sleeve: Purchase and transfer your consciousness into a new body
" + "2. Duplicate Sleeves: Duplicate your consciousness into Synthoids, allowing you to perform different tasks synchronously

" + "In this BitNode:

" + - "Your stats are significantly decreased.
" + + "Your stats are significantly decreased
" + "All methods of gaining money are half as profitable (except Stock Market)
" + "Purchased servers are more expensive, have less max RAM, and a lower maximum limit
" + "Augmentations are 5x as expensive and require twice as much reputation

" + @@ -360,13 +374,15 @@ export function initBitNodeMultipliers(p: IPlayer) { BitNodeMultipliers.HomeComputerRamCost = 5; BitNodeMultipliers.CrimeMoney = 0.5; BitNodeMultipliers.ScriptHackMoney = 0.1; - BitNodeMultipliers.HackExpGain = 0.1; + BitNodeMultipliers.HackExpGain = 0.05; BitNodeMultipliers.ServerStartingMoney = 0.1; BitNodeMultipliers.ServerMaxMoney = 0.1; BitNodeMultipliers.ServerStartingSecurity = 2.5; BitNodeMultipliers.CorporationValuation = 0.5; BitNodeMultipliers.FourSigmaMarketDataCost = 5; BitNodeMultipliers.FourSigmaMarketDataApiCost = 4; + BitNodeMultipliers.BladeburnerRank = 0.9; + BitNodeMultipliers.BladeburnerSkillCost = 1.2; break; case 10: // Digital Carbon BitNodeMultipliers.HackingLevelMultiplier = 0.2; diff --git a/src/Hacknet/HacknetHelpers.jsx b/src/Hacknet/HacknetHelpers.jsx index 9a24e3afc..29f85a8a1 100644 --- a/src/Hacknet/HacknetHelpers.jsx +++ b/src/Hacknet/HacknetHelpers.jsx @@ -45,6 +45,25 @@ export function hasHacknetServers() { return (Player.bitNodeN === 9 || SourceFileFlags[9] > 0); } +export function createHacknetServer() { + const numOwned = Player.hacknetNodes.length; + const name = `hacknet-node-${numOwned}`; + const server = new HacknetServer({ + adminRights: true, + hostname: name, + player: Player, + }); + Player.hacknetNodes.push(server.ip); + + // Configure the HacknetServer to actually act as a Server + AddToAllServers(server); + const homeComputer = Player.getHomeComputer(); + homeComputer.serversOnNetwork.push(server.ip); + server.serversOnNetwork.push(homeComputer.ip); + + return server; +} + export function purchaseHacknet() { /* INTERACTIVE TUTORIAL */ if (ITutorial.isRunning) { @@ -63,24 +82,8 @@ export function purchaseHacknet() { } if (!Player.canAfford(cost)) { return -1; } - - // Auto generate a hostname for this Server - const numOwned = Player.hacknetNodes.length; - const name = `hacknet-node-${numOwned}`; - const server = new HacknetServer({ - adminRights: true, - hostname: name, - player: Player, - }); - Player.loseMoney(cost); - Player.hacknetNodes.push(server.ip); - - // Configure the HacknetServer to actually act as a Server - AddToAllServers(server); - const homeComputer = Player.getHomeComputer(); - homeComputer.serversOnNetwork.push(server.ip); - server.serversOnNetwork.push(homeComputer.ip); + const server = createHacknetServer(); return numOwned; } else { diff --git a/src/NetscriptFunctions.js b/src/NetscriptFunctions.js index b6d5fa3da..afed96696 100644 --- a/src/NetscriptFunctions.js +++ b/src/NetscriptFunctions.js @@ -32,10 +32,11 @@ import { FactionWorkType } from "./Faction/FactionWorkT import { netscriptCanGrow, netscriptCanHack, netscriptCanWeaken } from "./Hacking/netscriptCanHack"; + import { getCostOfNextHacknetNode, getCostOfNextHacknetServer, hasHacknetServers, - purchaseHacknet } from "./Hacknet/HacknetNode"; + purchaseHacknet } from "./Hacknet/HacknetHelpers"; import {Locations} from "./Locations"; import { Message } from "./Message/Message"; import { Messages } from "./Message/MessageHelpers"; @@ -318,7 +319,11 @@ function NetscriptFunctions(workerScript) { upgradeCache : function(i, n) { if (!hasHacknetServers()) { return false; } const node = getHacknetNode(i); - return node.purchaseCacheUpgrade(n, Player); + const res = node.purchaseCacheUpgrade(n, Player); + if (res) { + Player.hashManager.updateCapacity(Player); + } + return res; }, getLevelUpgradeCost : function(i, n) { const node = getHacknetNode(i); diff --git a/src/Player.js b/src/Player.js index 6ad8978d2..96920e193 100644 --- a/src/Player.js +++ b/src/Player.js @@ -420,20 +420,21 @@ PlayerObject.prototype.prestigeSourceFile = function() { this.lastUpdate = new Date().getTime(); + // Hacknet Nodes this.hacknetNodes.length = 0; this.hashManager.prestige(this); - //Gang + // Gang this.gang = null; resetGangs(); - //Reset Stock market + // Reset Stock market this.hasWseAccount = false; this.hasTixApiAccess = false; this.has4SData = false; this.has4SDataTixApi = false; - //BitNode 3: Corporatocracy + // Corporation this.corporation = 0; // Statistics trackers diff --git a/src/Prestige.js b/src/Prestige.js index c764c5a37..4ee7cb9ad 100755 --- a/src/Prestige.js +++ b/src/Prestige.js @@ -14,6 +14,7 @@ import { Faction } from "./Faction/Faction"; import { Factions, initFactions } from "./Faction/Factions"; import { joinFaction } from "./Faction/FactionHelpers"; +import { createHacknetServer } from "./Hacknet/HacknetHelpers"; import {deleteGangDisplayContent} from "./Gang"; import {Locations} from "./Location"; import { Message } from "./Message/Message"; @@ -30,7 +31,8 @@ import { AllServers, prestigeAllServers } from "./Server/AllServers"; import { Server } from "./Server/Server" import { prestigeHomeComputer } from "./Server/ServerHelpers"; -import { updateSourceFileFlags } from "./SourceFile/SourceFileFlags"; +import { SourceFileFlags, + updateSourceFileFlags } from "./SourceFile/SourceFileFlags"; import { SpecialServerIps, SpecialServerIpsMap, prestigeSpecialServerIps, @@ -201,49 +203,45 @@ function prestigeSourceFile() { //Re-create foreign servers initForeignServers(Player.getHomeComputer()); - var srcFile1Owned = false; - for (var i = 0; i < Player.sourceFiles.length; ++i) { - if (Player.sourceFiles[i].n == 1) { - srcFile1Owned = true; - } - } - if (srcFile1Owned) { + if (SourceFileFlags[9] >= 2) { + homeComp.setMaxRam(128); + } else if (SourceFileFlags[1] > 0) { homeComp.setMaxRam(32); } else { homeComp.setMaxRam(8); } homeComp.cpuCores = 1; - //Reset favor for Companies + // Reset favor for Companies for (var member in Companies) { if (Companies.hasOwnProperty(member)) { Companies[member].favor = 0; } } - //Reset favor for factions + // Reset favor for factions for (var member in Factions) { if (Factions.hasOwnProperty(member)) { Factions[member].favor = 0; } } - //Stop a Terminal action if there is one + // Stop a Terminal action if there is one if (Engine._actionInProgress) { Engine._actionInProgress = false; Terminal.finishAction(true); } - //Delete all Augmentations + // Delete all Augmentations for (var name in Augmentations) { if (Augmentations.hasOwnProperty(name)) { delete Augmentations[name]; } } - //Re-initialize things - This will update any changes - initFactions(); //Factions must be initialized before augmentations - initAugmentations(); //Calls reapplyAllAugmentations() and resets Player multipliers + // 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(); @@ -325,7 +323,7 @@ function prestigeSourceFile() { dialogBoxCreate("Visit VitaLife in New Tokyo if you'd like to purchase a new sleeve!"); } - //Reset Stock market, gang, and corporation + // Reset Stock market, gang, and corporation if (Player.hasWseAccount) { initStockMarket(); initSymbolToStockMap(); @@ -341,6 +339,16 @@ function prestigeSourceFile() { Player.corporation = null; resetIndustryResearchTrees(); Player.bladeburner = null; + // Source-File 9 (level 3) effect + if (SourceFileFlags[9] >= 3) { + const hserver = createHacknetServer(); + hserver.level = 100; + hserver.cores = 10; + hserver.cache = 5; + hserver.updateHashRate(Player); + hserver.updateHashCapacity(); + Player.hashManager.updateCapacity(Player); + } // Refresh Main Menu (the 'World' menu, specifically) document.getElementById("world-menu-header").click(); diff --git a/src/ScriptEditor/AceNetscriptMode.js b/src/ScriptEditor/AceNetscriptMode.js index 15873e07c..9061f45f1 100644 --- a/src/ScriptEditor/AceNetscriptMode.js +++ b/src/ScriptEditor/AceNetscriptMode.js @@ -101,8 +101,8 @@ let NetscriptFunctions = // Hacknet Node API "hacknet|numNodes|purchaseNode|getPurchaseNodeCost|getNodeStats|" + - "upgradeLevel|upgradeRam|upgradeCore|getLevelUpgradeCost|" + - "getRamUpgradeCost|getCoreUpgradeCost|" + + "upgradeLevel|upgradeRam|upgradeCore|upgradeCache|getLevelUpgradeCost|" + + "getRamUpgradeCost|getCoreUpgradeCost|getCacheUpgradeCost|" + // Gang API "gang|" + diff --git a/src/ScriptEditor/CodeMirrorNetscriptMode.js b/src/ScriptEditor/CodeMirrorNetscriptMode.js index fed212ac8..a240edf1e 100644 --- a/src/ScriptEditor/CodeMirrorNetscriptMode.js +++ b/src/ScriptEditor/CodeMirrorNetscriptMode.js @@ -177,9 +177,11 @@ CodeMirror.defineMode("netscript", function(config, parserConfig) { "upgradeLevel": atom, "upgradeRam": atom, "upgradeCore": atom, + "upgradeCache": atom, "getLevelUpgradeCost": atom, "getRamUpgradeCost": atom, "getCoreUpgradeCost": atom, + "getCacheUpgradeCost": atom, // Netscript Gang API "gang": atom, diff --git a/src/SourceFile.js b/src/SourceFile.js index 63a9f0a02..168087800 100644 --- a/src/SourceFile.js +++ b/src/SourceFile.js @@ -62,7 +62,12 @@ function initSourceFiles() { "Level 3: Ability to use limit/stop orders in other BitNodes

" + "This Source-File also increases your hacking growth multipliers by: " + "
Level 1: 12%
Level 2: 18%
Level 3: 21%"); - SourceFiles["SourceFile9"] = new SourceFile(9); + SourceFiles["SourceFile9"] = new SourceFile(9, "This Source-File grants the following benefits:

" + + "Level 1: Permanently unlocks the Hacknet Server in other BitNodes
" + + "Level 2: You start with 128GB of RAM on your home computer when entering a new BitNode
" + + "Level 3: Grants a highly-upgraded Hacknet Server when entering a new BitNode

" + + "(Note that the Level 3 effect of this Source-File only applies when entering a new BitNode, NOT " + + "when installing Augmentations)"); SourceFiles["SourceFile10"] = new SourceFile(10, "This Source-File unlocks Sleeve technology in other BitNodes. Each level of this " + "Source-File also grants you a Duplicate Sleeve"); SourceFiles["SourceFile11"] = new SourceFile(11, "This Source-File makes it so that company favor increases BOTH the player's salary and reputation gain rate " + @@ -119,7 +124,7 @@ function applySourceFile(srcFile) { Player.hacknet_node_level_cost_mult *= decMult; Player.work_money_mult *= incMult; break; - case 2: //Rise of the Underworld + case 2: // Rise of the Underworld var mult = 0; for (var i = 0; i < srcFile.lvl; ++i) { mult += (24 / (Math.pow(2, i))); @@ -129,7 +134,7 @@ function applySourceFile(srcFile) { Player.crime_success_mult *= incMult; Player.charisma_mult *= incMult; break; - case 3: //Corporatocracy + case 3: // Corporatocracy var mult = 0; for (var i = 0; i < srcFile.lvl; ++i) { mult += (8 / (Math.pow(2, i))); @@ -138,10 +143,10 @@ function applySourceFile(srcFile) { Player.charisma_mult *= incMult; Player.work_money_mult *= incMult; break; - case 4: //The Singularity - //No effects, just gives access to Singularity functions + case 4: // The Singularity + // No effects, just gives access to Singularity functions break; - case 5: //Artificial Intelligence + case 5: // Artificial Intelligence var mult = 0; for (var i = 0; i < srcFile.lvl; ++i) { mult += (8 / (Math.pow(2, i))); @@ -154,7 +159,7 @@ function applySourceFile(srcFile) { Player.hacking_mult *= incMult; Player.hacking_exp_mult *= incMult; break; - case 6: //Bladeburner + case 6: // Bladeburner var mult = 0; for (var i = 0; i < srcFile.lvl; ++i) { mult += (8 / (Math.pow(2, i))); @@ -169,7 +174,7 @@ function applySourceFile(srcFile) { Player.dexterity_mult *= incMult; Player.agility_mult *= incMult; break; - case 7: //Bladeburner 2079 + case 7: // Bladeburner 2079 var mult = 0; for (var i = 0; i < srcFile.lvl; ++i) { mult += (8 / (Math.pow(2, i))); @@ -180,7 +185,7 @@ function applySourceFile(srcFile) { Player.bladeburner_analysis_mult *= incMult; Player.bladeburner_success_chance_mult *= incMult; break; - case 8: //Ghost of Wall Street + case 8: // Ghost of Wall Street var mult = 0; for (var i = 0; i < srcFile.lvl; ++i) { mult += (12 / (Math.pow(2, i))); @@ -188,10 +193,13 @@ function applySourceFile(srcFile) { var incMult = 1 + (mult / 100); Player.hacking_grow_mult *= incMult; break; + case 9: // Hacktocracy + // This has non-multiplier effects + break; case 10: // Digital Carbon // No effects, just grants sleeves break; - case 11: //The Big Crash + case 11: // The Big Crash var mult = 0; for (var i = 0; i < srcFile.lvl; ++i) { mult += (32 / (Math.pow(2, i))); @@ -200,7 +208,7 @@ function applySourceFile(srcFile) { Player.work_money_mult *= incMult; Player.company_rep_mult *= incMult; break; - case 12: //The Recursion + case 12: // The Recursion var inc = Math.pow(1.01, srcFile.lvl); var dec = Math.pow(0.99, srcFile.lvl);