fixe some bugs

This commit is contained in:
Daniel Xie 2017-04-17 07:26:54 -05:00
parent a02663edf5
commit ffda024431
5 changed files with 16 additions and 9 deletions

@ -430,7 +430,7 @@ displayFactionContent = function(factionName) {
//The old buttons need to be replaced to clear the old event listeners //The old buttons need to be replaced to clear the old event listeners
var newHackButton = hackButton.cloneNode(true); var newHackButton = hackButton.cloneNode(true);
var newFieldWorkButton = fieldWorkButton.cloneNode(true); var newFieldWorkButton = fieldWorkButton.cloneNode(true);
var newSecurityWorkButton = securityWorkbutton.cloneNode(true); var newSecurityWorkButton = securityWorkButton.cloneNode(true);
hackButton.parentNode.replaceChild(newHackButton, hackButton); hackButton.parentNode.replaceChild(newHackButton, hackButton);
fieldWorkButton.parentNode.replaceChild(newFieldWorkButton, fieldWorkButton); fieldWorkButton.parentNode.replaceChild(newFieldWorkButton, fieldWorkButton);

@ -1243,7 +1243,7 @@ initLocationButtons = function() {
purchaseTor.addEventListener("click", function() { purchaseTor.addEventListener("click", function() {
purchaseTor(); purchaseTor();
return false; return false;
} });
travelToAevum.addEventListener("click", function() { travelToAevum.addEventListener("click", function() {
travelBoxCreate(Locations.Aevum, 1000000); travelBoxCreate(Locations.Aevum, 1000000);

@ -254,8 +254,8 @@ function evaluate(exp, workerScript) {
Player.hacking_exp += expGainedOnFailure; Player.hacking_exp += expGainedOnFailure;
workerScript.scriptRef.onlineExpGained += expGainedOnFailure; workerScript.scriptRef.onlineExpGained += expGainedOnFailure;
console.log("Script unsuccessful to hack " + server.hostname + ". Gained " + expGainedOnFailure + "exp"); console.log("Script unsuccessful to hack " + server.hostname + ". Gained " + expGainedOnFailure + " exp");
workerScript.scriptRef.log("Script unsuccessful to hack " + server.hostname + ". Gained " + expGainedOnFailure + "exp"); workerScript.scriptRef.log("Script unsuccessful to hack " + server.hostname + ". Gained " + expGainedOnFailure + " exp");
resolve("Hack failure"); resolve("Hack failure");
} }
}, hackingTime * 1000); }, hackingTime * 1000);
@ -529,7 +529,9 @@ function scriptCalculateHackingChance(server) {
var difficultyMult = (100 - server.hackDifficulty) / 100; var difficultyMult = (100 - server.hackDifficulty) / 100;
var skillMult = (Player.hacking_chance_mult * Player.hacking_skill); var skillMult = (Player.hacking_chance_mult * Player.hacking_skill);
var skillChance = (skillMult - server.requiredHackingSkill) / skillMult; var skillChance = (skillMult - server.requiredHackingSkill) / skillMult;
return (skillChance * difficultyMult); var chance = skillChance * difficultyMult;
if (chance < 0) {return 0;}
else {return chance;}
} }
//The same as Player's calculateHackingTime() function but takes in the server as an argument //The same as Player's calculateHackingTime() function but takes in the server as an argument

@ -15,8 +15,8 @@ function PlayerObject() {
//Hacking multipliers //Hacking multipliers
this.hacking_chance_mult = 2; //Increase through ascensions/augmentations this.hacking_chance_mult = 2; //Increase through ascensions/augmentations
//this.hacking_speed_mult = 5; //Decrease through ascensions/augmentations this.hacking_speed_mult = 5; //Decrease through ascensions/augmentations
this.hacking_speed_mult = 1; //Make it faster for debugging //this.hacking_speed_mult = 1; //Make it faster for debugging
this.hacking_money_mult = .001; //Increase through ascensions/augmentations. Can't go above 1 this.hacking_money_mult = .001; //Increase through ascensions/augmentations. Can't go above 1
//Note: "Lifetime" refers to current ascension, "total" refers to the entire game history //Note: "Lifetime" refers to current ascension, "total" refers to the entire game history
@ -177,7 +177,9 @@ PlayerObject.prototype.calculateHackingChance = function() {
var difficultyMult = (100 - this.getCurrentServer().hackDifficulty) / 100; var difficultyMult = (100 - this.getCurrentServer().hackDifficulty) / 100;
var skillMult = (this.hacking_chance_mult * this.hacking_skill); var skillMult = (this.hacking_chance_mult * this.hacking_skill);
var skillChance = (skillMult - this.getCurrentServer().requiredHackingSkill) / skillMult; var skillChance = (skillMult - this.getCurrentServer().requiredHackingSkill) / skillMult;
return (skillChance * difficultyMult); var chance = skillChance * difficultyMult;
if (chance < 0) {return 0;}
else {return chance;}
} }
//Calculate the time it takes to hack a server in seconds. Returns the time //Calculate the time it takes to hack a server in seconds. Returns the time

@ -40,7 +40,10 @@ factionInvitationBoxCreate = function(faction) {
//TODO Faction invitation message //TODO Faction invitation message
var yesButton = document.getElementById("faction-invitation-box-yes"); var yesButton = document.getElementById("faction-invitation-box-yes");
yesButton.addEventListener("click", function() { var newYesButton = yesButton.cloneNode(true);
yesButton.parentNode.replaceChild(newYesButton, yesButton);
newYesButton.addEventListener("click", function() {
joinFaction(faction); joinFaction(faction);
factionInvitationBoxClose(); factionInvitationBoxClose();
return false; return false;