TRAVEL: Unify implementation for Player and Sleeves (and some followup for #1365) (#1439)

This commit is contained in:
Snarling
2024-06-26 16:46:50 -08:00
committed by GitHub
parent abdf5f52cd
commit b597746343
6 changed files with 21 additions and 43 deletions
@@ -28,8 +28,6 @@ import { Faction } from "../../Faction/Faction";
import { Factions } from "../../Faction/Factions";
import { FactionInvitationEvents } from "../../Faction/ui/FactionInvitationManager";
import { resetGangs } from "../../Gang/AllGangs";
import { Cities } from "../../Locations/Cities";
import { Locations } from "../../Locations/Locations";
import { Sleeve } from "../Sleeve/Sleeve";
import { SleeveWorkType } from "../Sleeve/Work/Work";
import { calculateSkillProgress as calculateSkillProgressF, ISkillProgress } from "../formulas/skill";
@@ -532,26 +530,8 @@ export function gainCodingContractReward(
}
}
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.loseMoney(CONSTANTS.TravelCost, "other");
this.city = cityName;
return true;
}
export function gotoLocation(this: PlayerObject, to: LocationName): boolean {
if (Locations[to] == null) {
throw new Error(`Player.gotoLocation() was called with an invalid location: ${to}`);
}
this.location = to;
return true;
}