Added gang.getTaskStats which returns the stats of a gang task

This commit is contained in:
Olivier Gagnon 2021-03-07 22:12:02 -05:00
parent 84423e6309
commit 619db14622
5 changed files with 52 additions and 3 deletions

@ -0,0 +1,33 @@
getTaskStats() Netscript Function
======================================
.. js:function:: getTaskStats()
:RAM cost: 1 GB
Get the stats of a gang member stats. This is typically used to evaluate
which action should be executed next.
{
name: Terrorism,
desc: "Assign this gang member to commit acts of terrorism
Greatly increases respect - Greatly increases wanted level - Scales heavily with territory",
isHacking: false,
isCombat: true,
baseRespect: 0.01,
baseWanted: 6,
baseMoney: 0,
hackWeight: 20,
strWeight: 20,
defWeight: 20,
dexWeight: 20,
agiWeight: 0,
chaWeight: 20,
difficulty: 36,
territory: {
money: 1,
respect: 2,
wanted: 2
}
}

@ -912,7 +912,7 @@ GangMemberTask.fromJSON = function(value) {
Reviver.constructors.GangMemberTask = GangMemberTask;
const GangMemberTasks = {};
export const GangMemberTasks = {};
function addGangMemberTask(name, desc, isHacking, isCombat, params) {
GangMemberTasks[name] = new GangMemberTask(name, desc, isHacking, isCombat, params);

@ -216,6 +216,7 @@ export const RamCosts: IMap<any> = {
canRecruitMember: () => RamCostConstants.ScriptGangApiBaseRamCost / 4,
recruitMember: () => RamCostConstants.ScriptGangApiBaseRamCost / 2,
getTaskNames: () => RamCostConstants.ScriptGangApiBaseRamCost / 4,
getTaskStats: () => RamCostConstants.ScriptGangApiBaseRamCost / 4,
setMemberTask: () => RamCostConstants.ScriptGangApiBaseRamCost / 2,
getEquipmentNames: () => RamCostConstants.ScriptGangApiBaseRamCost / 4,
getEquipmentCost: () => RamCostConstants.ScriptGangApiBaseRamCost / 2,

@ -29,7 +29,11 @@ import {
calculateGrowTime,
calculateWeakenTime
} from "./Hacking";
import { AllGangs, GangMemberUpgrades } from "./Gang";
import {
AllGangs,
GangMemberUpgrades,
GangMemberTasks
} from "./Gang";
import { Faction } from "./Faction/Faction";
import { Factions, factionExists } from "./Faction/Factions";
import { joinFaction, purchaseAugmentation } from "./Faction/FactionHelpers";
@ -3712,6 +3716,17 @@ function NetscriptFunctions(workerScript) {
throw makeRuntimeRejectMsg(workerScript, nsGang.unknownGangApiExceptionMessage("setMemberTask", e));
}
},
getTaskStats: function(taskName) {
updateDynamicRam("getTaskStats", getRamCost("gang", "getTaskStats"));
nsGang.checkGangApiAccess(workerScript, "getTaskStats");
const task = GangMemberTasks[taskName];
if (!task) {
throw makeRuntimeRejectMsg(workerScript, nsGang.unknownGangApiExceptionMessage("getTaskStats", `${taskName} does not exists`));
}
const copy = Object.assign({}, task);
copy.territory = Object.assign({}, task.territory)
return copy;
},
getEquipmentNames: function() {
updateDynamicRam("getEquipmentNames", getRamCost("gang", "getEquipmentNames"));
nsGang.checkGangApiAccess(workerScript, "getEquipmentNames");

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