made travel cost a constant and prevent travelToCity from traveling if the player doesn't have enough money

This commit is contained in:
Olivier Gagnon 2018-06-03 21:09:12 -04:00
parent 5caa247c89
commit 4b6dbee628
3 changed files with 13 additions and 7 deletions

@ -14,6 +14,8 @@ let CONSTANTS = {
BaseCostFor1GBOfRamServer: 55000, //1 GB of RAM BaseCostFor1GBOfRamServer: 55000, //1 GB of RAM
BaseCostFor1GBOfRamHacknetNode: 30000, BaseCostFor1GBOfRamHacknetNode: 30000,
TravelCost: 200000,
BaseCostForHacknetNode: 1000, BaseCostForHacknetNode: 1000,
BaseCostForHacknetNodeCore: 500000, BaseCostForHacknetNodeCore: 500000,

@ -1834,32 +1834,32 @@ function initLocationButtons() {
}); });
travelToAevum.addEventListener("click", function() { travelToAevum.addEventListener("click", function() {
travelBoxCreate(Locations.Aevum, 200000); travelBoxCreate(Locations.Aevum, CONSTANTS.TravelCost);
return false; return false;
}); });
travelToChongqing.addEventListener("click", function() { travelToChongqing.addEventListener("click", function() {
travelBoxCreate(Locations.Chongqing, 200000); travelBoxCreate(Locations.Chongqing, CONSTANTS.TravelCost);
return false; return false;
}); });
travelToSector12.addEventListener("click", function() { travelToSector12.addEventListener("click", function() {
travelBoxCreate(Locations.Sector12, 200000); travelBoxCreate(Locations.Sector12, CONSTANTS.TravelCost);
return false; return false;
}); });
travelToNewTokyo.addEventListener("click", function() { travelToNewTokyo.addEventListener("click", function() {
travelBoxCreate(Locations.NewTokyo, 200000); travelBoxCreate(Locations.NewTokyo, CONSTANTS.TravelCost);
return false; return false;
}); });
travelToIshima.addEventListener("click", function() { travelToIshima.addEventListener("click", function() {
travelBoxCreate(Locations.Ishima, 200000); travelBoxCreate(Locations.Ishima, CONSTANTS.TravelCost);
return false; return false;
}); });
travelToVolhaven.addEventListener("click", function() { travelToVolhaven.addEventListener("click", function() {
travelBoxCreate(Locations.Volhaven, 200000); travelBoxCreate(Locations.Volhaven, CONSTANTS.TravelCost);
return false; return false;
}); });

@ -2484,7 +2484,11 @@ function NetscriptFunctions(workerScript) {
case Locations.NewTokyo: case Locations.NewTokyo:
case Locations.Ishima: case Locations.Ishima:
case Locations.Volhaven: 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.city = cityname;
Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain); Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.travelToCity == null) { if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.travelToCity == null) {