autocomplete

This commit is contained in:
Olivier Gagnon 2021-10-15 13:12:18 -04:00
parent 6b0e5416c4
commit c1d4ced331
6 changed files with 24 additions and 19 deletions

@ -512,7 +512,6 @@ export function purchaseHashUpgrade(player: IPlayer, upgName: string, upgTarget:
const old = target.moneyMax;
target.changeMaximumMoney(upg.value);
console.log(target.moneyMax / old);
} catch (e) {
player.hashManager.refundUpgrade(upgName);
return false;

@ -137,15 +137,13 @@ export class WorkerScript {
if (!found) {
throw new Error(`WorkerScript constructed with invalid script filename: ${this.name}`);
}
this.scriptRef = runningScriptObj;
this.args = runningScriptObj.args.slice();
this.env = new Environment(null);
if (typeof nsFuncsGenerator === "function") {
this.env.vars = nsFuncsGenerator(this);
}
this.env.set("args", runningScriptObj.args.slice());
this.scriptRef = runningScriptObj;
this.args = runningScriptObj.args.slice();
}
/**

@ -329,9 +329,6 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
return Factions[name];
};
console.log(workerScript);
console.log(workerScript.args);
const hack = function (ip: any, manual: any, { threads: requestedThreads, stock }: any = {}): Promise<number> {
if (ip === undefined) {
throw makeRuntimeErrorMsg("hack", "Takes 1 argument.");

@ -132,7 +132,6 @@ export class Server extends BaseServer {
const aboveCap = this.moneyMax - softCap;
n = 1 + (n - 1) / Math.log(aboveCap) / Math.log(8);
}
console.log(n);
this.moneyMax *= n;
}

@ -312,16 +312,28 @@ export async function determineAllPossibilitiesForTabCompletion(
permissive: true,
argv: command.slice(2),
});
return loadedModule.autocomplete(
{
servers: GetAllServers().map((server) => server.hostname),
scripts: currServ.scripts.map((script) => script.filename),
txts: currServ.textFiles.map((txt) => txt.fn),
flags: Flags(flags._),
},
flags._,
const flagFunc = Flags(flags._);
let pos: string[] = [];
let pos2: string[] = [];
pos = pos.concat(
loadedModule.autocomplete(
{
servers: GetAllServers().map((server) => server.hostname),
scripts: currServ.scripts.map((script) => script.filename),
txts: currServ.textFiles.map((txt) => txt.fn),
flags: (schema: any) => {
pos2 = schema.map((f: any) => "--" + f[0]);
try {
return flagFunc(schema);
} catch (err) {
return undefined;
}
},
},
flags._,
),
);
return pos.concat(pos2);
}
const pos = await scriptAutocomplete();
if (pos) return pos;

@ -19,7 +19,7 @@ export function Reviver(key: string, value: IReviverValue | null): any {
// Compatibility for version v0.43.1
// TODO Remove this eventually
if (value.ctor === "AllServersMap") {
console.log("Converting AllServersMap for v0.43.1");
console.warning("Converting AllServersMap for v0.43.1");
return value.data;
}