Initial v0.46.0 changes - Fixed BN9 bugs. Rebalanced BN11 and Corporations. Added memory to Dup sleeves. Various bug fixes

This commit is contained in:
danielyxie
2019-03-27 01:36:14 -07:00
parent 83fc4d81b2
commit c4cb7daac5
38 changed files with 579 additions and 209 deletions
+21 -4
View File
@@ -11,6 +11,7 @@ import { HashUpgrades } from "./HashUpgrades";
import { IMap } from "../types";
import { IPlayer } from "../PersonObjects/IPlayer";
import { AllServers } from "../Server/AllServers";
import { Generic_fromJSON,
Generic_toJSON,
Reviver } from "../../utils/JSONReviver";
@@ -106,13 +107,29 @@ export class HashManager {
}
updateCapacity(p: IPlayer): void {
if (p.hacknetNodes.length <= 0) { this.capacity = 0; }
if (!(p.hacknetNodes[0] instanceof HacknetServer)) { this.capacity = 0; }
if (p.hacknetNodes.length <= 0) {
this.capacity = 0;
return;
}
// Make sure the Player's `hacknetNodes` property actually holds Hacknet Servers
const ip: string = <string>p.hacknetNodes[0];
if (typeof ip !== "string") {
this.capacity = 0;
return;
}
const hserver = <HacknetServer>AllServers[ip];
if (!(hserver instanceof HacknetServer)) {
this.capacity = 0;
return;
}
let total: number = 0;
for (let i = 0; i < p.hacknetNodes.length; ++i) {
const hacknetServer = <HacknetServer>(p.hacknetNodes[i]);
total += hacknetServer.hashCapacity;
const h = <HacknetServer>AllServers[<string>p.hacknetNodes[i]];
total += h.hashCapacity;
}
this.capacity = total;