remove level, base cost and rep requirment from base augmentation obj

* added in place calculations for cost and level of augmentations given player context
* removed redundant logic for dynamically calculating cost,rep and level against the augmentation object
* replaced references to startingCost to baseCost as it is now always whatever it started at
This commit is contained in:
phyzical
2022-04-15 01:39:38 +08:00
parent c3a3994658
commit db97125d22
12 changed files with 102 additions and 126 deletions
+5 -5
View File
@@ -1,3 +1,4 @@
import { AugmentationCosts } from "./../Augmentation/Augmentation";
import { WorkerScript } from "../Netscript/WorkerScript";
import { IPlayer } from "../PersonObjects/IPlayer";
import { purchaseAugmentation, joinFaction, getFactionAugmentationsFiltered } from "../Faction/FactionHelpers";
@@ -122,7 +123,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
_ctx.helper.checkSingularityAccess();
const augName = _ctx.helper.string("augName", _augName);
const aug = getAugmentation(_ctx, augName);
return [aug.baseRepRequirement, aug.baseCost];
return [aug.getCost(player).moneyCost, aug.getCost(player).repCost];
},
getAugmentationPrereq: (_ctx: NetscriptContext) =>
function (_augName: unknown): string[] {
@@ -136,14 +137,14 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
_ctx.helper.checkSingularityAccess();
const augName = _ctx.helper.string("augName", _augName);
const aug = getAugmentation(_ctx, augName);
return aug.baseCost;
return aug.getCost(player).moneyCost;
},
getAugmentationRepReq: (_ctx: NetscriptContext) =>
function (_augName: unknown): number {
_ctx.helper.checkSingularityAccess();
const augName = _ctx.helper.string("augName", _augName);
const aug = getAugmentation(_ctx, augName);
return aug.baseRepRequirement;
return aug.getCost(player).repCost;
},
getAugmentationStats: (_ctx: NetscriptContext) =>
function (_augName: unknown): AugmentationStats {
@@ -186,7 +187,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
}
}
if (fac.playerReputation < aug.baseRepRequirement) {
if (fac.playerReputation < aug.getCost(player).repCost) {
workerScript.log("purchaseAugmentation", () => `You do not have enough reputation with '${fac.name}'.`);
return false;
}
@@ -1128,7 +1129,6 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
workerScript.log("workForFaction", () => `Invalid work type: '${type}`);
return false;
}
return true;
},
getFactionRep: (_ctx: NetscriptContext) =>
function (_facName: unknown): number {