From b4db36a11574bb30d286f2c27ecd55e7bd050cb5 Mon Sep 17 00:00:00 2001 From: Daniel Xie <Daniel Xie> Date: Mon, 15 May 2017 14:11:40 -0500 Subject: [PATCH] Think I fixed a bug where offline progress was being calculated wrong --- src/Constants.js | 2 +- src/Player.js | 4 ++-- src/engine.js | 8 +++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Constants.js b/src/Constants.js index 8ee2175db..7dd002f36 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -1,5 +1,5 @@ CONSTANTS = { - Version: "0.7", + Version: "0.8", //Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience //and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then diff --git a/src/Player.js b/src/Player.js index c8c734a0d..2931adc4b 100644 --- a/src/Player.js +++ b/src/Player.js @@ -167,7 +167,7 @@ function PlayerObject() { this.hacknet_node_level_cost_mult = 1; //Used to store the last update time. - this.lastUpdate = new Date().getTime(); + this.lastUpdate = 0; this.totalPlaytime = 0; }; @@ -989,7 +989,7 @@ PlayerObject.prototype.takeClass = function(numCycles) { var cyclesPerSec = 1000 / Engine._idleSpeed; var txt = document.getElementById("work-in-progress-text"); - txt.innerHTML = "You have been " + className + " for " + convertTimeMsToTimeElapsedString(this.timeWorked) + ".<br><br>" + + txt.innerHTML = "You have been " + className + " for " + convertTimeMsToTimeElapsedString(this.timeWorked) + "<br><br>" + "This has cost you: <br>" + "$" + formatNumber(this.workMoneyGained, 2) + " ($" + formatNumber(this.workMoneyLossRate * cyclesPerSec, 2) + " / sec) <br><br>" + "You have gained: <br>" + diff --git a/src/engine.js b/src/engine.js index ddfaac31e..3eed12674 100644 --- a/src/engine.js +++ b/src/engine.js @@ -714,13 +714,13 @@ var Engine = { console.log("Loaded game from save"); Engine.setDisplayElements(); //Sets variables for important DOM elements Engine.init(); //Initialize buttons, work, etc. - Engine.start(); //Run main game loop and Scripts loop CompanyPositions.init(); //Calculate the number of cycles have elapsed while offline - var thisUpdate = new Date().getTime(); + Engine._lastUpdate = new Date().getTime(); var lastUpdate = Player.lastUpdate; - var numCyclesOffline = Math.floor((thisUpdate - lastUpdate) / Engine._idleSpeed); + var numCyclesOffline = Math.floor((Engine._lastUpdate - lastUpdate) / Engine._idleSpeed); + Player.lastUpdate = new Date().getTime(); /* Process offline progress */ processServerGrowth(numCyclesOffline); //Should be done before offline production for scripts @@ -751,6 +751,8 @@ var Engine = { var time = numCyclesOffline * Engine._idleSpeed; if (Player.totalPlaytime == null) {Player.totalPlaytime = 0;} Player.totalPlaytime += time; + + Engine.start(); //Run main game loop and Scripts loop } else { //No save found, start new game console.log("Initializing new game");