mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-27 01:53:48 +01:00
Merge pull request #958 from Daniferrito/dynamic-possibleLogs
Added dynamic generation of functionNames
This commit is contained in:
commit
bf141c7eb0
@ -179,77 +179,6 @@ import { createElement } from "../utils/uiHelpers/createElement";
|
|||||||
import { createPopup } from "../utils/uiHelpers/createPopup";
|
import { createPopup } from "../utils/uiHelpers/createPopup";
|
||||||
import { removeElementById } from "../utils/uiHelpers/removeElementById";
|
import { removeElementById } from "../utils/uiHelpers/removeElementById";
|
||||||
|
|
||||||
const possibleLogs = {
|
|
||||||
ALL: true,
|
|
||||||
scan: true,
|
|
||||||
hack: true,
|
|
||||||
sleep: true,
|
|
||||||
disableLog: true,
|
|
||||||
enableLog: true,
|
|
||||||
grow: true,
|
|
||||||
weaken: true,
|
|
||||||
nuke: true,
|
|
||||||
brutessh: true,
|
|
||||||
ftpcrack: true,
|
|
||||||
relaysmtp: true,
|
|
||||||
httpworm: true,
|
|
||||||
sqlinject: true,
|
|
||||||
run:true,
|
|
||||||
exec:true,
|
|
||||||
spawn: true,
|
|
||||||
kill: true,
|
|
||||||
killall: true,
|
|
||||||
scp: true,
|
|
||||||
getHackingLevel: true,
|
|
||||||
getServerMoneyAvailable: true,
|
|
||||||
getServerSecurityLevel: true,
|
|
||||||
getServerBaseSecurityLevel: true,
|
|
||||||
getServerMinSecurityLevel: true,
|
|
||||||
getServerRequiredHackingLevel: true,
|
|
||||||
getServerMaxMoney: true,
|
|
||||||
getServerGrowth: true,
|
|
||||||
getServerNumPortsRequired: true,
|
|
||||||
getServerRam: true,
|
|
||||||
|
|
||||||
// TIX API
|
|
||||||
buyStock: true,
|
|
||||||
sellStock: true,
|
|
||||||
shortStock: true,
|
|
||||||
sellShort: true,
|
|
||||||
purchase4SMarketData: true,
|
|
||||||
purchase4SMarketDataTixApi: true,
|
|
||||||
|
|
||||||
// Singularity Functions
|
|
||||||
purchaseServer: true,
|
|
||||||
deleteServer: true,
|
|
||||||
universityCourse: true,
|
|
||||||
gymWorkout: true,
|
|
||||||
travelToCity: true,
|
|
||||||
purchaseTor: true,
|
|
||||||
purchaseProgram: true,
|
|
||||||
stopAction: true,
|
|
||||||
upgradeHomeRam: true,
|
|
||||||
workForCompany: true,
|
|
||||||
applyToCompany: true,
|
|
||||||
joinFaction: true,
|
|
||||||
workForFaction: true,
|
|
||||||
donateToFaction: true,
|
|
||||||
createProgram: true,
|
|
||||||
commitCrime: true,
|
|
||||||
|
|
||||||
// Bladeburner API
|
|
||||||
startAction: true,
|
|
||||||
upgradeSkill: true,
|
|
||||||
setTeamSize: true,
|
|
||||||
joinBladeburnerFaction: true,
|
|
||||||
|
|
||||||
// Gang API
|
|
||||||
recruitMember: true,
|
|
||||||
setMemberTask: true,
|
|
||||||
purchaseEquipment: true,
|
|
||||||
setTerritoryWarfare: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
const defaultInterpreter = new Interpreter('', () => undefined);
|
const defaultInterpreter = new Interpreter('', () => undefined);
|
||||||
|
|
||||||
// the acorn interpreter has a bug where it doesn't convert arrays correctly.
|
// the acorn interpreter has a bug where it doesn't convert arrays correctly.
|
||||||
@ -739,7 +668,7 @@ function NetscriptFunctions(workerScript) {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
const functions = {
|
||||||
hacknet : {
|
hacknet : {
|
||||||
numNodes : function() {
|
numNodes : function() {
|
||||||
return Player.hacknetNodes.length;
|
return Player.hacknetNodes.length;
|
||||||
@ -4544,7 +4473,23 @@ function NetscriptFunctions(workerScript) {
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
} // End return
|
}
|
||||||
|
|
||||||
|
function getFunctionNames(obj) {
|
||||||
|
const functionNames = [];
|
||||||
|
for(const [key, value] of Object.entries(obj)){
|
||||||
|
if(typeof(value)=="function"){
|
||||||
|
functionNames.push(key);
|
||||||
|
}else if(typeof(value)=="object"){
|
||||||
|
functionNames.push(...getFunctionNames(value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return functionNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
const possibleLogs = Object.fromEntries(["ALL", ...getFunctionNames(functions)].map(a => [a, true]))
|
||||||
|
|
||||||
|
return functions;
|
||||||
} // End NetscriptFunction()
|
} // End NetscriptFunction()
|
||||||
|
|
||||||
export { NetscriptFunctions };
|
export { NetscriptFunctions };
|
Loading…
Reference in New Issue
Block a user