Merge branch 'dev' into wrap-api

This commit is contained in:
hydroflame
2022-05-19 01:37:06 -04:00
committed by GitHub
48 changed files with 1101 additions and 1036 deletions
+1 -1
View File
@@ -74,7 +74,7 @@ export function NetscriptCorporation(player: IPlayer, workerScript: WorkerScript
if (!player.canAccessCorporation() || player.hasCorporation()) return false;
if (!corporationName) return false;
if (player.bitNodeN !== 3 && !selfFund) throw new Error("cannot use seed funds outside of BitNode 3");
if (BitNodeMultipliers.CorporationSoftCap < 0.15)
if (BitNodeMultipliers.CorporationSoftcap < 0.15)
throw new Error(`You cannot create a corporation in Bitnode ${player.bitNodeN}`);
if (selfFund) {
+3 -2
View File
@@ -84,7 +84,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
if (script.filename === cbScript) {
const ramUsage = script.ramUsage;
const ramAvailable = home.maxRam - home.ramUsed;
if (ramUsage > ramAvailable) {
if (ramUsage > ramAvailable + 0.001) {
return; // Not enough RAM
}
const runningScriptObj = new RunningScript(script, []); // No args
@@ -123,7 +123,8 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
_ctx.helper.checkSingularityAccess();
const augName = _ctx.helper.string("augName", _augName);
const aug = getAugmentation(_ctx, augName);
return [aug.getCost(player).moneyCost, aug.getCost(player).repCost];
const costs = aug.getCost(player);
return [costs.repCost, costs.moneyCost];
},
getAugmentationPrereq: (_ctx: NetscriptContext) =>
function (_augName: unknown): string[] {
+9
View File
@@ -5,6 +5,7 @@ import { netscriptDelay } from "../NetscriptEvaluator";
import { staneksGift } from "../CotMG/Helper";
import { Fragments, FragmentById } from "../CotMG/Fragment";
import { FragmentType } from "../CotMG/FragmentType";
import {
Fragment as IFragment,
@@ -42,11 +43,19 @@ export function NetscriptStanek(
},
chargeFragment: (_ctx: NetscriptContext) =>
function (_rootX: unknown, _rootY: unknown): Promise<void> {
//Get the fragment object using the given coordinates
const rootX = _ctx.helper.number("rootX", _rootX);
const rootY = _ctx.helper.number("rootY", _rootY);
checkStanekAPIAccess("chargeFragment");
const fragment = staneksGift.findFragment(rootX, rootY);
//Check whether the selected fragment can ge charged
if (!fragment) throw _ctx.makeRuntimeErrorMsg(`No fragment with root (${rootX}, ${rootY}).`);
if (fragment.fragment().type == FragmentType.Booster) {
throw _ctx.makeRuntimeErrorMsg(
`The fragment with root (${rootX}, ${rootY}) is a Booster Fragment and thus cannot be charged.`,
);
}
//Charge the fragment
const time = staneksGift.inBonus() ? 200 : 1000;
return netscriptDelay(time, workerScript).then(function () {
const charge = staneksGift.charge(player, fragment, workerScript.scriptRef.threads);
+7
View File
@@ -11,6 +11,7 @@ import { defaultStyles } from "../Themes/Styles";
import { CONSTANTS } from "../Constants";
import { hash } from "../hash/hash";
import { InternalAPI, NetscriptContext } from "src/Netscript/APIWrapper";
import { Terminal } from "../../src/Terminal";
export function NetscriptUserInterface(): InternalAPI<IUserInterface> {
return {
@@ -96,5 +97,11 @@ export function NetscriptUserInterface(): InternalAPI<IUserInterface> {
return gameInfo;
},
clearTerminal: function (): void {
updateRam("clearTerminal");
workerScript.log("ui.clearTerminal", () => `Clearing terminal`);
Terminal.clear();
},
};
}