Adds getAugmentationPrice() and getAugmentationReqRep() Netscript Singularity functions. Deprecates getAugmentationCost() Netscript singularity function.

This commit is contained in:
vmesecher 2021-09-07 20:33:34 -07:00
parent 1c9542d102
commit 6979082be7
10 changed files with 91 additions and 16 deletions

@ -55,8 +55,10 @@ The player has access to all of these functions while in BitNode-4. Completing B
getOwnedAugmentations() <singularityfunctions/getOwnedAugmentations>
getOwnedSourceFiles() <singularityfunctions/getOwnedSourceFiles>
getAugmentationsFromFaction() <singularityfunctions/getAugmentationsFromFaction>
getAugmentationPrereq() <singularityfunctions/getAugmentationPrereq>
getAugmentationCost() <singularityfunctions/getAugmentationCost>
getAugmentationPrereq() <singularityfunctions/getAugmentationPrereq>
getAugmentationPrice() <singularityfunctions/getAugmentationPrice>
getAugmentationRepReq() <singularityfunctions/getAugmentationRepReq>
getAugmentationStats() <singularityfunctions/getAugmentationStats>
purchaseAugmentation() <singularityfunctions/purchaseAugmentation>
installAugmentations() <singularityfunctions/installAugmentations>

@ -3,12 +3,15 @@ getAugmentationCost() Netscript Function
.. js:function:: getAugmentationCost(augName)
.. warning:: This function is deprecated.
:RAM cost: 5 GB
:param string augName: Name of Augmentation. case-sensitive.
:param string augName: Name of Augmentation. CASE-SENSITIVE
If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to use this function.
This function returns an array with two elements that gives the cost for the specified Augmentation.
The first element in the returned array is the reputation requirement of the Augmentation, and the second element is the money cost.
If an invalid Augmentation name is passed in for the ``augName`` argument, this function will return the array [-1, -1].
If an invalid Augmentation name is passed in for the ``augName`` argument, this function will throw a runtime error.

@ -12,4 +12,4 @@ getAugmentationPrereq() Netscript Function
This function returns an array with the names of the prerequisite Augmentation(s) for the specified Augmentation.
If there are no prerequisites, a blank array is returned.
If an invalid Augmentation name is passed in for the *augName* argument, this function will return a blank array.
If an invalid Augmentation name is passed in for the *augName* argument, this function will throw a runtime error.

@ -0,0 +1,14 @@
getAugmentationPrice() Netscript Function
==========================================
.. js:function:: getAugmentationPrice(augName)
:RAM cost: 2.5 GB
:param string augName: Name of Augmentation. CASE-SENSITIVE
If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to use this function.
This function returns the money cost for the specified Augmentation.
If an invalid Augmentation name is passed in for the *augName* argument, this function will throw a runtime error.

@ -0,0 +1,14 @@
getAugmentationRepReq() Netscript Function
==========================================
.. js:function:: getAugmentationRepReq(augName)
:RAM cost: 2.5 GB
:param string augName: Name of Augmentation. CASE-SENSITIVE
If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to use this function.
This function returns the reputation requirement for the specified Augmentation.
If an invalid Augmentation name is passed in for the *augName* argument, this function will throw a runtime error.

@ -214,8 +214,10 @@ export const RamCosts: IMap<any> = {
getOwnedAugmentations: () => RamCostConstants.ScriptSingularityFn3RamCost,
getOwnedSourceFiles: () => RamCostConstants.ScriptSingularityFn3RamCost,
getAugmentationsFromFaction: () => RamCostConstants.ScriptSingularityFn3RamCost,
getAugmentationPrereq: () => RamCostConstants.ScriptSingularityFn3RamCost,
getAugmentationCost: () => RamCostConstants.ScriptSingularityFn3RamCost,
getAugmentationPrereq: () => RamCostConstants.ScriptSingularityFn3RamCost,
getAugmentationPrice: () => RamCostConstants.ScriptSingularityFn3RamCost / 2,
getAugmentationRepReq: () => RamCostConstants.ScriptSingularityFn3RamCost / 2,
getAugmentationStats: () => RamCostConstants.ScriptSingularityFn3RamCost,
purchaseAugmentation: () => RamCostConstants.ScriptSingularityFn3RamCost,
softReset: () => RamCostConstants.ScriptSingularityFn3RamCost,

@ -4598,6 +4598,15 @@ function NetscriptFunctions(workerScript) {
return faction.augmentations.slice();
},
getAugmentationCost: function (name) {
updateDynamicRam(
"getAugmentationCost",
getRamCost("getAugmentationCost"),
);
checkSingularityAccess("getAugmentationCost", 3);
const aug = getAugmentation("getAugmentationCost", name);
return [aug.baseRepRequirement, aug.baseCost];
},
getAugmentationPrereq: function (name) {
updateDynamicRam(
"getAugmentationPrereq",
@ -4607,14 +4616,23 @@ function NetscriptFunctions(workerScript) {
const aug = getAugmentation("getAugmentationPrereq", name);
return aug.prereqs.slice();
},
getAugmentationCost: function (name) {
getAugmentationPrice: function (name) {
updateDynamicRam(
"getAugmentationCost",
getRamCost("getAugmentationCost"),
"getAugmentationPrice",
getRamCost("getAugmentationPrice"),
);
checkSingularityAccess("getAugmentationCost", 3);
const aug = getAugmentation("getAugmentationCost", name);
return [aug.baseRepRequirement, aug.baseCost];
checkSingularityAccess("getAugmentationPrice", 3);
const aug = getAugmentation("getAugmentationPrice", name);
return aug.baseCost;
},
getAugmentationRepReq: function (name) {
updateDynamicRam(
"getAugmentationRepReq",
getRamCost("getAugmentationRepReq"),
);
checkSingularityAccess("getAugmentationRepReq", 3);
const aug = getAugmentation("getAugmentationRepReq", name);
return aug.baseRepRequirement;
},
getAugmentationStats: function (name) {
updateDynamicRam(

@ -146,8 +146,10 @@ export const libSource = `interface NS {
getOwnedAugmentations(purchased: boolean): string[];
getOwnedSourceFiles(): any; // complex type
getAugmentationsFromFaction(facname: string): string[];
getAugmentationPrereq(name: string): string[];
getAugmentationCost(name: string): number;
getAugmentationPrereq(name: string): string[];
getAugmentationPrice(name: string): number;
getAugmentationRepReq(name: string): number;
getAugmentationStats(name: string): any; // complex type
purchaseAugmentation(faction: string, name: string): boolean;
softReset(cbScript: string): void;

@ -812,13 +812,23 @@ describe("Netscript Dynamic RAM Calculation/Generation Tests", function () {
await testNonzeroDynamicRamCost(f);
});
it("getAugmentationCost()", async function () {
const f = ["getAugmentationCost"];
await testNonzeroDynamicRamCost(f);
});
it("getAugmentationPrereq()", async function () {
const f = ["getAugmentationPrereq"];
await testNonzeroDynamicRamCost(f);
});
it("getAugmentationCost()", async function () {
const f = ["getAugmentationCost"];
it("getAugmentationPrice()", async function () {
const f = ["getAugmentationPrice"];
await testNonzeroDynamicRamCost(f);
});
it("getAugmentationRepReq()", async function () {
const f = ["getAugmentationRepReq"];
await testNonzeroDynamicRamCost(f);
});

@ -756,13 +756,23 @@ describe("Netscript Static RAM Calculation/Generation Tests", function () {
await expectNonZeroRamCost(f);
});
it("getAugmentationCost()", async function () {
const f = ["getAugmentationCost"];
await expectNonZeroRamCost(f);
});
it("getAugmentationPrereq()", async function () {
const f = ["getAugmentationPrereq"];
await expectNonZeroRamCost(f);
});
it("getAugmentationCost()", async function () {
const f = ["getAugmentationCost"];
it("getAugmentationPrice()", async function () {
const f = ["getAugmentationPrice"];
await expectNonZeroRamCost(f);
});
it("getAugmentationRepReq()", async function () {
const f = ["getAugmentationRepReq"];
await expectNonZeroRamCost(f);
});