fix: check for purchased program before enough money (#839)

This commit is contained in:
Noah Harris 2023-10-03 02:02:28 -04:00 committed by GitHub
parent f4cd4b3362
commit e22527e7b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -450,16 +450,16 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
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) {