From e22527e7b74ffa421229da041098123281c848f0 Mon Sep 17 00:00:00 2001 From: Noah Harris <38120002+ncharris93@users.noreply.github.com> Date: Tue, 3 Oct 2023 02:02:28 -0400 Subject: [PATCH] fix: check for purchased program before enough money (#839) --- src/NetscriptFunctions/Singularity.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/NetscriptFunctions/Singularity.ts b/src/NetscriptFunctions/Singularity.ts index a0d1aa523..1335017f8 100644 --- a/src/NetscriptFunctions/Singularity.ts +++ b/src/NetscriptFunctions/Singularity.ts @@ -450,16 +450,16 @@ export function NetscriptSingularity(): InternalAPI { return false; } - if (Player.money < item.price) { - helpers.log(ctx, () => `Not enough money to purchase '${item.program}'. Need ${formatMoney(item.price)}`); - return false; - } - if (Player.hasProgram(item.program)) { helpers.log(ctx, () => `You already have the '${item.program}' program`); return true; } + if (Player.money < item.price) { + helpers.log(ctx, () => `Not enough money to purchase '${item.program}'. Need ${formatMoney(item.price)}`); + return false; + } + Player.getHomeComputer().pushProgram(item.program); // Cancel if the program is in progress of writing if (isCreateProgramWork(Player.currentWork) && Player.currentWork.programName === item.program) {