Added hacknet node api functions for spending hashes. Fixed several bugs with v0.46.0. Rebalanced hash upgrades. continued working on terminal directory implementation

This commit is contained in:
danielyxie
2019-04-05 02:08:41 -07:00
parent fb857642e8
commit 3241945452
30 changed files with 576 additions and 314 deletions

View File

@@ -1,8 +1,14 @@
/**
* Server and HacknetServer-related methods for the Player class (PlayerObject)
*/
import { IPlayer } from "../IPlayer";
import { CONSTANTS } from "../../Constants";
import { AllServers } from "../../Server/AllServers";
import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers";
import { HacknetServer } from "../../Hacknet/HacknetServer";
import { AddToAllServers,
AllServers } from "../../Server/AllServers";
import { SpecialServerIps } from "../../Server/SpecialServerIps";
export function hasTorRouter(this: IPlayer) {
@@ -28,3 +34,22 @@ export function getUpgradeHomeRamCost(this: IPlayer) {
var cost = currentRam * CONSTANTS.BaseCostFor1GBOfRamHome * mult * BitNodeMultipliers.HomeComputerRamCost;
return cost;
}
export function createHacknetServer(this: IPlayer): HacknetServer {
const numOwned = this.hacknetNodes.length;
const name = `hacknet-node-${numOwned}`;
const server = new HacknetServer({
adminRights: true,
hostname: name,
player: this,
});
this.hacknetNodes.push(server.ip);
// Configure the HacknetServer to actually act as a Server
AddToAllServers(server);
const homeComputer = this.getHomeComputer();
homeComputer.serversOnNetwork.push(server.ip);
server.serversOnNetwork.push(homeComputer.ip);
return server;
}