mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-18 13:43:49 +01:00
Began implementing 'hacknet nodes'
This commit is contained in:
parent
0a94026d02
commit
14fb303504
@ -48,6 +48,7 @@
|
|||||||
<script src="src/CreateProgram.js"></script>
|
<script src="src/CreateProgram.js"></script>
|
||||||
<script src="src/Augmentations.js"></script>
|
<script src="src/Augmentations.js"></script>
|
||||||
<script src="src/Perk.js"></script>
|
<script src="src/Perk.js"></script>
|
||||||
|
<script src="src/HacknetNode.js"></script>
|
||||||
|
|
||||||
<script src="src/engine.js"></script>
|
<script src="src/engine.js"></script>
|
||||||
|
|
||||||
@ -136,6 +137,11 @@
|
|||||||
<ul class="active-scripts-list" id="active-scripts-list" style="list-style: none;">
|
<ul class="active-scripts-list" id="active-scripts-list" style="list-style: none;">
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Hacknet Nodes -->
|
||||||
|
<div id="hacknet-nodes-container">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- World -->
|
<!-- World -->
|
||||||
<div id="world-container" class="world-container">
|
<div id="world-container" class="world-container">
|
||||||
|
44
src/HacknetNode.js
Normal file
44
src/HacknetNode.js
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/* HacknetNode.js */
|
||||||
|
function HacknetNode(name) {
|
||||||
|
this.level = 1;
|
||||||
|
this.ram = 0; //GB
|
||||||
|
this.numCores = 1;
|
||||||
|
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
|
this.totalMoneyGenerated = 0;
|
||||||
|
this.onlineTimeSeconds = 0;
|
||||||
|
|
||||||
|
this.moneyGainRatePerSecond = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
HacknetNode.prototype.updateMoneyGainRate = function() {
|
||||||
|
//How much extra $/s is gained per level
|
||||||
|
var gainPerLevel = 0.25;
|
||||||
|
|
||||||
|
//Each CPU core doubles the speed. Every 1GB of ram adds 10% increase
|
||||||
|
this.moneyGainRatePerSecond = (this.level * gainPerLevel) * Math.pow(1.1, ram) * this.numCores;
|
||||||
|
}
|
||||||
|
|
||||||
|
HacknetNode.prototype.calculateLevelUpgradeCost = function() {
|
||||||
|
//Upgrade cost = Base cost * multiplier ^ level
|
||||||
|
var baseCost = 10000;
|
||||||
|
var mult = 1.08;
|
||||||
|
return baseCost * Math.pow(mult, this.level);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Saving and loading HackNets */
|
||||||
|
HacknetNode.prototype.toJSON = function() {
|
||||||
|
return Generic_toJSON("HacknetNode", this);
|
||||||
|
}
|
||||||
|
|
||||||
|
HacknetNode.fromJSON = function(value) {
|
||||||
|
return Generic_fromJSON(HacknetNode, value.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
Reviver.constructors.HacknetNode = HacknetNode;
|
||||||
|
|
||||||
|
|
||||||
|
purchaseHacknet = function() {
|
||||||
|
|
||||||
|
}
|
@ -22,6 +22,7 @@ function Server() {
|
|||||||
this.scripts = [];
|
this.scripts = [];
|
||||||
this.runningScripts = []; //Names (and only names) of scripts being run
|
this.runningScripts = []; //Names (and only names) of scripts being run
|
||||||
this.programs = [];
|
this.programs = [];
|
||||||
|
this.hacknetNodes = [];
|
||||||
|
|
||||||
/* Hacking information (only valid for "foreign" aka non-purchased servers) */
|
/* Hacking information (only valid for "foreign" aka non-purchased servers) */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user