CODEBASE: Add Jsonable Map and Set types, move player.sourceFiles to a map (#473)

This commit is contained in:
Snarling
2023-04-18 03:19:45 -04:00
committed by GitHub
parent c44bdc1018
commit 0df984eea0
55 changed files with 439 additions and 532 deletions
+2 -5
View File
@@ -50,7 +50,6 @@ import { canGetBonus, onExport } from "../ExportBonus";
import { saveObject } from "../SaveObject";
import { calculateCrimeWorkStats } from "../Work/Formulas";
import { findEnumMember } from "../utils/helpers/enum";
import { areFilesEqual } from "../Terminal/DirectoryHelpers";
import { Engine } from "../engine";
import { checkEnum } from "../utils/helpers/enum";
@@ -81,7 +80,7 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
//Run a script after reset
if (!cbScript) return;
const home = Player.getHomeComputer();
const script = home.scripts.find((serverScript) => areFilesEqual(serverScript.filename, cbScript));
const script = home.scripts.get(cbScript);
if (!script) return;
const ramUsage = script.getRamUsage(home.scripts);
if (!ramUsage) {
@@ -110,9 +109,7 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
return res;
},
getOwnedSourceFiles: () => () => {
return Player.sourceFiles.map((sf) => {
return { n: sf.n, lvl: sf.lvl };
});
return [...Player.sourceFiles].map(([n, lvl]) => ({ n, lvl }));
},
getAugmentationsFromFaction: (ctx) => (_facName) => {
helpers.checkSingularityAccess(ctx);