From 7f8757b536e3ae520de5b98c06107114daac54b8 Mon Sep 17 00:00:00 2001 From: gmcew <97335456+gmcew@users.noreply.github.com> Date: Thu, 23 May 2024 09:46:55 +0100 Subject: [PATCH] SLEEVE: Add funds check for sleeve travel (#1298) This makes it consistent with player behaviour. This also makes the function description more truthful in that it is now possible to return false. --- src/PersonObjects/Sleeve/Sleeve.ts | 4 ++++ src/ScriptEditor/NetscriptDefinitions.d.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/PersonObjects/Sleeve/Sleeve.ts b/src/PersonObjects/Sleeve/Sleeve.ts index cbbbdf35a..0f7ba828a 100644 --- a/src/PersonObjects/Sleeve/Sleeve.ts +++ b/src/PersonObjects/Sleeve/Sleeve.ts @@ -256,6 +256,10 @@ export class Sleeve extends Person implements SleevePerson { /** Travel to another City. Costs money from player */ travel(newCity: CityName): boolean { + if (!Player.canAfford(CONSTANTS.TravelCost)) { + return false; + } + Player.loseMoney(CONSTANTS.TravelCost, "sleeves"); this.city = newCity; diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index a5a84427f..4eb0542b9 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -4473,7 +4473,7 @@ export interface Sleeve { setToGymWorkout(sleeveNumber: number, gymName: string, stat: string): boolean; /** - * Make a sleeve travel to another city. + * Make a sleeve travel to another city. The cost for using this function is the same as for a player. * @remarks * RAM cost: 4 GB *