Merge pull request #3169 from danielyxie/dev

Fix bug with hacknet api
This commit is contained in:
hydroflame 2022-03-18 11:18:55 -04:00 committed by GitHub
commit e38621cd1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 14 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -3,6 +3,7 @@ import { IPlayer } from "../PersonObjects/IPlayer";
import { Exploit } from "../Exploits/Exploit"; import { Exploit } from "../Exploits/Exploit";
import * as bcrypt from "bcryptjs"; import * as bcrypt from "bcryptjs";
import { INetscriptHelper } from "./INetscriptHelper"; import { INetscriptHelper } from "./INetscriptHelper";
import { Augmentations } from "../Augmentation/Augmentations";
export interface INetscriptExtra { export interface INetscriptExtra {
heart: { heart: {

@ -91,25 +91,25 @@ export function NetscriptHacknet(player: IPlayer, workerScript: WorkerScript, he
return res; return res;
}, },
upgradeLevel: function (_i: unknown, _n: unknown): boolean { upgradeLevel: function (_i: unknown, _n: unknown = 1): boolean {
const i = helper.number("upgradeLevel", "i", _i); const i = helper.number("upgradeLevel", "i", _i);
const n = helper.number("upgradeLevel", "n", _n); const n = helper.number("upgradeLevel", "n", _n);
const node = getHacknetNode(i, "upgradeLevel"); const node = getHacknetNode(i, "upgradeLevel");
return purchaseLevelUpgrade(player, node, n); return purchaseLevelUpgrade(player, node, n);
}, },
upgradeRam: function (_i: unknown, _n: unknown): boolean { upgradeRam: function (_i: unknown, _n: unknown = 1): boolean {
const i = helper.number("upgradeRam", "i", _i); const i = helper.number("upgradeRam", "i", _i);
const n = helper.number("upgradeRam", "n", _n); const n = helper.number("upgradeRam", "n", _n);
const node = getHacknetNode(i, "upgradeRam"); const node = getHacknetNode(i, "upgradeRam");
return purchaseRamUpgrade(player, node, n); return purchaseRamUpgrade(player, node, n);
}, },
upgradeCore: function (_i: unknown, _n: unknown): boolean { upgradeCore: function (_i: unknown, _n: unknown = 1): boolean {
const i = helper.number("upgradeCore", "i", _i); const i = helper.number("upgradeCore", "i", _i);
const n = helper.number("upgradeCore", "n", _n); const n = helper.number("upgradeCore", "n", _n);
const node = getHacknetNode(i, "upgradeCore"); const node = getHacknetNode(i, "upgradeCore");
return purchaseCoreUpgrade(player, node, n); return purchaseCoreUpgrade(player, node, n);
}, },
upgradeCache: function (_i: unknown, _n: unknown): boolean { upgradeCache: function (_i: unknown, _n: unknown = 1): boolean {
const i = helper.number("upgradeCache", "i", _i); const i = helper.number("upgradeCache", "i", _i);
const n = helper.number("upgradeCache", "n", _n); const n = helper.number("upgradeCache", "n", _n);
if (!hasHacknetServers(player)) { if (!hasHacknetServers(player)) {
@ -126,25 +126,25 @@ export function NetscriptHacknet(player: IPlayer, workerScript: WorkerScript, he
} }
return res; return res;
}, },
getLevelUpgradeCost: function (_i: unknown, _n: unknown): number { getLevelUpgradeCost: function (_i: unknown, _n: unknown = 1): number {
const i = helper.number("getLevelUpgradeCost", "i", _i); const i = helper.number("getLevelUpgradeCost", "i", _i);
const n = helper.number("getLevelUpgradeCost", "n", _n); const n = helper.number("getLevelUpgradeCost", "n", _n);
const node = getHacknetNode(i, "upgradeLevel"); const node = getHacknetNode(i, "upgradeLevel");
return node.calculateLevelUpgradeCost(n, player.hacknet_node_level_cost_mult); return node.calculateLevelUpgradeCost(n, player.hacknet_node_level_cost_mult);
}, },
getRamUpgradeCost: function (_i: unknown, _n: unknown): number { getRamUpgradeCost: function (_i: unknown, _n: unknown = 1): number {
const i = helper.number("getRamUpgradeCost", "i", _i); const i = helper.number("getRamUpgradeCost", "i", _i);
const n = helper.number("getRamUpgradeCost", "n", _n); const n = helper.number("getRamUpgradeCost", "n", _n);
const node = getHacknetNode(i, "upgradeRam"); const node = getHacknetNode(i, "upgradeRam");
return node.calculateRamUpgradeCost(n, player.hacknet_node_ram_cost_mult); return node.calculateRamUpgradeCost(n, player.hacknet_node_ram_cost_mult);
}, },
getCoreUpgradeCost: function (_i: unknown, _n: unknown): number { getCoreUpgradeCost: function (_i: unknown, _n: unknown = 1): number {
const i = helper.number("getCoreUpgradeCost", "i", _i); const i = helper.number("getCoreUpgradeCost", "i", _i);
const n = helper.number("getCoreUpgradeCost", "n", _n); const n = helper.number("getCoreUpgradeCost", "n", _n);
const node = getHacknetNode(i, "upgradeCore"); const node = getHacknetNode(i, "upgradeCore");
return node.calculateCoreUpgradeCost(n, player.hacknet_node_core_cost_mult); return node.calculateCoreUpgradeCost(n, player.hacknet_node_core_cost_mult);
}, },
getCacheUpgradeCost: function (_i: unknown, _n: unknown): number { getCacheUpgradeCost: function (_i: unknown, _n: unknown = 1): number {
const i = helper.number("getCacheUpgradeCost", "i", _i); const i = helper.number("getCacheUpgradeCost", "i", _i);
const n = helper.number("getCacheUpgradeCost", "n", _n); const n = helper.number("getCacheUpgradeCost", "n", _n);
if (!hasHacknetServers(player)) { if (!hasHacknetServers(player)) {
@ -177,10 +177,9 @@ export function NetscriptHacknet(player: IPlayer, workerScript: WorkerScript, he
return player.hashManager.getUpgradeCost(upgName); return player.hashManager.getUpgradeCost(upgName);
}, },
spendHashes: function (_upgName: unknown, _upgTarget: unknown): boolean { spendHashes: function (_upgName: unknown, _upgTarget: unknown = ""): boolean {
const upgName = helper.string("spendHashes", "upgName", _upgName); const upgName = helper.string("spendHashes", "upgName", _upgName);
let upgTarget = ""; const upgTarget = helper.string("spendHashes", "upgTarget", _upgTarget);
if (_upgTarget !== undefined) upgTarget = helper.string("spendHashes", "upgTarget", _upgTarget);
if (!hasHacknetServers(player)) { if (!hasHacknetServers(player)) {
return false; return false;
} }