From 4b6dbee6287c356ede99c347c1bbc6ebc2be03e1 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Sun, 3 Jun 2018 21:09:12 -0400 Subject: [PATCH] made travel cost a constant and prevent travelToCity from traveling if the player doesn't have enough money --- src/Constants.js | 2 ++ src/Location.js | 12 ++++++------ src/NetscriptFunctions.js | 6 +++++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Constants.js b/src/Constants.js index 3e665a663..78c79a63d 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -14,6 +14,8 @@ let CONSTANTS = { BaseCostFor1GBOfRamServer: 55000, //1 GB of RAM BaseCostFor1GBOfRamHacknetNode: 30000, + TravelCost: 200000, + BaseCostForHacknetNode: 1000, BaseCostForHacknetNodeCore: 500000, diff --git a/src/Location.js b/src/Location.js index 30e8bdf1c..65652174e 100644 --- a/src/Location.js +++ b/src/Location.js @@ -1834,32 +1834,32 @@ function initLocationButtons() { }); travelToAevum.addEventListener("click", function() { - travelBoxCreate(Locations.Aevum, 200000); + travelBoxCreate(Locations.Aevum, CONSTANTS.TravelCost); return false; }); travelToChongqing.addEventListener("click", function() { - travelBoxCreate(Locations.Chongqing, 200000); + travelBoxCreate(Locations.Chongqing, CONSTANTS.TravelCost); return false; }); travelToSector12.addEventListener("click", function() { - travelBoxCreate(Locations.Sector12, 200000); + travelBoxCreate(Locations.Sector12, CONSTANTS.TravelCost); return false; }); travelToNewTokyo.addEventListener("click", function() { - travelBoxCreate(Locations.NewTokyo, 200000); + travelBoxCreate(Locations.NewTokyo, CONSTANTS.TravelCost); return false; }); travelToIshima.addEventListener("click", function() { - travelBoxCreate(Locations.Ishima, 200000); + travelBoxCreate(Locations.Ishima, CONSTANTS.TravelCost); return false; }); travelToVolhaven.addEventListener("click", function() { - travelBoxCreate(Locations.Volhaven, 200000); + travelBoxCreate(Locations.Volhaven, CONSTANTS.TravelCost); return false; }); diff --git a/src/NetscriptFunctions.js b/src/NetscriptFunctions.js index 6e40dddbb..93c9bd051 100644 --- a/src/NetscriptFunctions.js +++ b/src/NetscriptFunctions.js @@ -2484,7 +2484,11 @@ function NetscriptFunctions(workerScript) { case Locations.NewTokyo: case Locations.Ishima: case Locations.Volhaven: - Player.loseMoney(200000); + if(Player.money.lt(CONSTANTS.TravelCost)) { + workerScript.scriptRef.log("ERROR: not enough money to travel with travelToCity()."); + throw makeRuntimeRejectMsg(workerScript, "ERROR: not enough money to travel with travelToCity()."); + } + Player.loseMoney(CONSTANTS.TravelCost); Player.city = cityname; Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain); if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.travelToCity == null) {