gang.getEquipmentStats added, returns equipment multipliers

This commit is contained in:
Olivier Gagnon 2021-03-07 22:01:31 -05:00
parent 1d2136da4b
commit 84423e6309
6 changed files with 35 additions and 4 deletions

@ -0,0 +1,17 @@
getEquipmentStats() Netscript Function
=====================================
.. js:function:: getEquipmentStats(equipName)
:RAM cost: 2 GB
:param string equipName: Name of equipment
:returns: A dictionary containing the stats of the equipment.
Get the specified equipment stats.
{
"str":1.04,
"def":1.04
}

@ -6,7 +6,7 @@
import { IMap } from "./types"; import { IMap } from "./types";
export let CONSTANTS: IMap<any> = { export let CONSTANTS: IMap<any> = {
Version: "0.48.0", Version: "0.49.0",
/** Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience /** Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience
* and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then * and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then
@ -231,6 +231,9 @@ export let CONSTANTS: IMap<any> = {
v0.49.0 v0.49.0
------- -------
Netscript
* 'gang.getEquipmentStats' returns the stats of the equipment.
Misc. Misc.
* Minor formatting under Hacking>Active Scripts * Minor formatting under Hacking>Active Scripts
` `

@ -981,7 +981,7 @@ GangMemberUpgrade.fromJSON = function(value) {
Reviver.constructors.GangMemberUpgrade = GangMemberUpgrade; Reviver.constructors.GangMemberUpgrade = GangMemberUpgrade;
// Initialize Gang Member Upgrades // Initialize Gang Member Upgrades
const GangMemberUpgrades = {} export const GangMemberUpgrades = {}
function addGangMemberUpgrade(name, cost, type, mults) { function addGangMemberUpgrade(name, cost, type, mults) {
GangMemberUpgrades[name] = new GangMemberUpgrade(name, cost, type, mults); GangMemberUpgrades[name] = new GangMemberUpgrade(name, cost, type, mults);

@ -220,6 +220,7 @@ export const RamCosts: IMap<any> = {
getEquipmentNames: () => RamCostConstants.ScriptGangApiBaseRamCost / 4, getEquipmentNames: () => RamCostConstants.ScriptGangApiBaseRamCost / 4,
getEquipmentCost: () => RamCostConstants.ScriptGangApiBaseRamCost / 2, getEquipmentCost: () => RamCostConstants.ScriptGangApiBaseRamCost / 2,
getEquipmentType: () => RamCostConstants.ScriptGangApiBaseRamCost / 2, getEquipmentType: () => RamCostConstants.ScriptGangApiBaseRamCost / 2,
getEquipmentStats: () => RamCostConstants.ScriptGangApiBaseRamCost / 2,
purchaseEquipment: () => RamCostConstants.ScriptGangApiBaseRamCost, purchaseEquipment: () => RamCostConstants.ScriptGangApiBaseRamCost,
ascendMember: () => RamCostConstants.ScriptGangApiBaseRamCost, ascendMember: () => RamCostConstants.ScriptGangApiBaseRamCost,
setTerritoryWarfare: () => RamCostConstants.ScriptGangApiBaseRamCost / 2, setTerritoryWarfare: () => RamCostConstants.ScriptGangApiBaseRamCost / 2,

@ -29,7 +29,7 @@ import {
calculateGrowTime, calculateGrowTime,
calculateWeakenTime calculateWeakenTime
} from "./Hacking"; } from "./Hacking";
import { AllGangs } from "./Gang"; import { AllGangs, GangMemberUpgrades } from "./Gang";
import { Faction } from "./Faction/Faction"; import { Faction } from "./Faction/Faction";
import { Factions, factionExists } from "./Faction/Factions"; import { Factions, factionExists } from "./Faction/Factions";
import { joinFaction, purchaseAugmentation } from "./Faction/FactionHelpers"; import { joinFaction, purchaseAugmentation } from "./Faction/FactionHelpers";
@ -3742,6 +3742,16 @@ function NetscriptFunctions(workerScript) {
throw makeRuntimeRejectMsg(workerScript, nsGang.unknownGangApiExceptionMessage("getEquipmentType", e)); throw makeRuntimeRejectMsg(workerScript, nsGang.unknownGangApiExceptionMessage("getEquipmentType", e));
} }
}, },
getEquipmentStats: function(equipName) {
updateDynamicRam("getEquipmentStats", getRamCost("gang", "getEquipmentStats"));
nsGang.checkGangApiAccess(workerScript, "getEquipmentStats");
const equipment = GangMemberUpgrades[equipName];
if (!equipment) {
throw makeRuntimeRejectMsg(workerScript, nsGang.unknownGangApiExceptionMessage("getEquipmentStats", `${equipName} does not exists`));
}
return Object.assign({}, equipment.mults);
},
purchaseEquipment: function(memberName, equipName) { purchaseEquipment: function(memberName, equipName) {
updateDynamicRam("purchaseEquipment", getRamCost("gang", "purchaseEquipment")); updateDynamicRam("purchaseEquipment", getRamCost("gang", "purchaseEquipment"));
nsGang.checkGangApiAccess(workerScript, "purchaseEquipment"); nsGang.checkGangApiAccess(workerScript, "purchaseEquipment");

@ -110,7 +110,7 @@ let NetscriptFunctions =
"getMemberNames|getGangInformation|getMemberInformation|canRecruitMember|" + "getMemberNames|getGangInformation|getMemberInformation|canRecruitMember|" +
"recruitMember|getTaskNames|setMemberTask|getEquipmentNames|" + "recruitMember|getTaskNames|setMemberTask|getEquipmentNames|" +
"getEquipmentCost|getEquipmentType|purchaseEquipment|ascendMember|" + "getEquipmentCost|getEquipmentType|purchaseEquipment|ascendMember|" +
"setTerritoryWarfare|" + "setTerritoryWarfare|getEquipmentStats|" +
"getChanceToWinClash|getBonusTime|" + "getChanceToWinClash|getBonusTime|" +
// Bladeburner API // Bladeburner API