mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-20 16:22:56 +02:00
MISC: Refactor code of traveling and going to location (#1365)
This commit is contained in:
@@ -531,20 +531,23 @@ export function gainCodingContractReward(
|
||||
}
|
||||
}
|
||||
|
||||
export function travel(this: PlayerObject, to: CityName): boolean {
|
||||
if (Cities[to] == null) {
|
||||
console.warn(`Player.travel() called with invalid city: ${to}`);
|
||||
export function travel(this: PlayerObject, cityName: CityName): boolean {
|
||||
if (Cities[cityName] == null) {
|
||||
throw new Error(`Player.travel() was called with an invalid city: ${cityName}`);
|
||||
}
|
||||
if (!this.canAfford(CONSTANTS.TravelCost)) {
|
||||
return false;
|
||||
}
|
||||
this.city = to;
|
||||
|
||||
this.loseMoney(CONSTANTS.TravelCost, "other");
|
||||
this.city = cityName;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export function gotoLocation(this: PlayerObject, to: LocationName): boolean {
|
||||
if (Locations[to] == null) {
|
||||
console.warn(`Player.gotoLocation() called with invalid location: ${to}`);
|
||||
return false;
|
||||
throw new Error(`Player.gotoLocation() was called with an invalid location: ${to}`);
|
||||
}
|
||||
this.location = to;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user