Merge pull request #2790 from SlyCedix/travelToCity-money-fix

Make travelToCity throw on invalid city name and return false on no money
This commit is contained in:
hydroflame 2022-01-26 00:32:25 -05:00 committed by GitHub
commit 0dd339bb4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -474,7 +474,8 @@ export function NetscriptSingularity(
case CityName.Ishima:
case CityName.Volhaven:
if (player.money < CONSTANTS.TravelCost) {
throw helper.makeRuntimeErrorMsg("travelToCity", "Not enough money to travel.");
workerScript.log("travelToCity", () => "Not enough money to travel.");
return false
}
player.loseMoney(CONSTANTS.TravelCost, "other");
player.city = cityname;
@ -482,8 +483,7 @@ export function NetscriptSingularity(
player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain / 50000);
return true;
default:
workerScript.log("travelToCity", () => `Invalid city name: '${cityname}'.`);
return false;
throw helper.makeRuntimeErrorMsg("travelToCity", `Invalid city name: '${cityname}'.`);
}
},