mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-03-22 18:22:31 +01:00
Think I fixed a bug where offline progress was being calculated wrong
This commit is contained in:
@ -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
|
||||
|
@ -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>" +
|
||||
|
@ -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");
|
||||
|
Reference in New Issue
Block a user