Merge pull request #13 from danielyxie/dev

Dev v0.8
This commit is contained in:
danielyxie 2017-05-15 15:12:47 -05:00 committed by GitHub
commit dbade4e555
3 changed files with 10 additions and 7 deletions

@ -1,5 +1,5 @@
CONSTANTS = { CONSTANTS = {
Version: "0.7", Version: "0.8",
//Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience //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 //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; this.hacknet_node_level_cost_mult = 1;
//Used to store the last update time. //Used to store the last update time.
this.lastUpdate = new Date().getTime(); this.lastUpdate = 0;
this.totalPlaytime = 0; this.totalPlaytime = 0;
}; };
@ -989,7 +989,7 @@ PlayerObject.prototype.takeClass = function(numCycles) {
var cyclesPerSec = 1000 / Engine._idleSpeed; var cyclesPerSec = 1000 / Engine._idleSpeed;
var txt = document.getElementById("work-in-progress-text"); 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>" + "This has cost you: <br>" +
"$" + formatNumber(this.workMoneyGained, 2) + " ($" + formatNumber(this.workMoneyLossRate * cyclesPerSec, 2) + " / sec) <br><br>" + "$" + formatNumber(this.workMoneyGained, 2) + " ($" + formatNumber(this.workMoneyLossRate * cyclesPerSec, 2) + " / sec) <br><br>" +
"You have gained: <br>" + "You have gained: <br>" +

@ -516,9 +516,9 @@ var Engine = {
if (diff > 0) { if (diff > 0) {
//Update the game engine by the calculated number of cycles //Update the game engine by the calculated number of cycles
Engine.updateGame(diff);
Engine._lastUpdate = _thisUpdate - offset; Engine._lastUpdate = _thisUpdate - offset;
Player.lastUpdate = _thisUpdate - offset; Player.lastUpdate = _thisUpdate - offset;
Engine.updateGame(diff);
} }
window.requestAnimationFrame(Engine.idleTimer); window.requestAnimationFrame(Engine.idleTimer);
@ -714,18 +714,18 @@ var Engine = {
console.log("Loaded game from save"); console.log("Loaded game from save");
Engine.setDisplayElements(); //Sets variables for important DOM elements Engine.setDisplayElements(); //Sets variables for important DOM elements
Engine.init(); //Initialize buttons, work, etc. Engine.init(); //Initialize buttons, work, etc.
Engine.start(); //Run main game loop and Scripts loop
CompanyPositions.init(); CompanyPositions.init();
//Calculate the number of cycles have elapsed while offline //Calculate the number of cycles have elapsed while offline
var thisUpdate = new Date().getTime(); Engine._lastUpdate = new Date().getTime();
var lastUpdate = Player.lastUpdate; var lastUpdate = Player.lastUpdate;
var numCyclesOffline = Math.floor((thisUpdate - lastUpdate) / Engine._idleSpeed); var numCyclesOffline = Math.floor((Engine._lastUpdate - lastUpdate) / Engine._idleSpeed);
/* Process offline progress */ /* Process offline progress */
processServerGrowth(numCyclesOffline); //Should be done before offline production for scripts processServerGrowth(numCyclesOffline); //Should be done before offline production for scripts
loadAllRunningScripts(); //This also takes care of offline production for those scripts loadAllRunningScripts(); //This also takes care of offline production for those scripts
if (Player.isWorking) { if (Player.isWorking) {
console.log("work() called in load() for " + numCyclesOffline * Engine._idleSpeed + " milliseconds");
if (Player.workType == CONSTANTS.WorkTypeFaction) { if (Player.workType == CONSTANTS.WorkTypeFaction) {
Player.workForFaction(numCyclesOffline); Player.workForFaction(numCyclesOffline);
} else if (Player.workType == CONSTANTS.WorkTypeCreateProgram) { } else if (Player.workType == CONSTANTS.WorkTypeCreateProgram) {
@ -751,6 +751,9 @@ var Engine = {
var time = numCyclesOffline * Engine._idleSpeed; var time = numCyclesOffline * Engine._idleSpeed;
if (Player.totalPlaytime == null) {Player.totalPlaytime = 0;} if (Player.totalPlaytime == null) {Player.totalPlaytime = 0;}
Player.totalPlaytime += time; Player.totalPlaytime += time;
Player.lastUpdate = Engine._lastUpdate;
Engine.start(); //Run main game loop and Scripts loop
} else { } else {
//No save found, start new game //No save found, start new game
console.log("Initializing new game"); console.log("Initializing new game");