mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-18 05:33:54 +01:00
Trying to get hack progress bar to work
This commit is contained in:
parent
d268ea09f8
commit
0a13496984
@ -8,7 +8,8 @@ var Player = {
|
||||
dexterity: 1,
|
||||
agility: 1,
|
||||
hacking_chance_multiplier: 2, //Increase through ascensions/augmentations
|
||||
hacking_speed_multiplier: 5, //Decrease through ascensions/augmentations
|
||||
//hacking_speed_multiplier: 5, //Decrease through ascensions/augmentations
|
||||
hacking_speed_multiplier: 1, //Make it faster for debugging
|
||||
|
||||
//Note: "Lifetime" refers to current ascension, "total" refers to the entire game history
|
||||
//Accumulative stats and skills
|
||||
@ -95,10 +96,8 @@ var Player = {
|
||||
// ------------------------------- * hacking_speed_multiplier
|
||||
// hacking_skill
|
||||
calculateHackingTime: function() {
|
||||
var difficultyMult = Player.currentServer.requiredHackingSkill * Player.currentServer.difficulty;
|
||||
console.log("difficultyMult: " + difficultyMult);
|
||||
var difficultyMult = Player.currentServer.requiredHackingSkill * Player.currentServer.hackDifficulty;
|
||||
var skillFactor = difficultyMult / Player.hacking_skill;
|
||||
console.log("skillFactor: " + skillFactor);
|
||||
console.log("Player.hacking_speed_multiplier: " + Player.hacking_speed_multiplier);
|
||||
return skillFactor * Player.hacking_speed_multiplier;
|
||||
},
|
||||
@ -112,11 +111,6 @@ var Player = {
|
||||
//Set the startHack flag so the engine starts the hacking process
|
||||
Player.startHack = true;
|
||||
|
||||
while (Player.finishHack == false) {
|
||||
//Waiting for hack to complete
|
||||
}
|
||||
Player.finishHack = false;
|
||||
|
||||
//DEBUG
|
||||
return 5;
|
||||
}
|
||||
|
@ -4,6 +4,17 @@ var post = function(input) {
|
||||
window.scrollTo(0, document.body.scrollHeight);
|
||||
}
|
||||
|
||||
//Same thing as post but the td cells have ids so they can be animated for the hack progress bar
|
||||
var hackProgressBarPost = function(input) {
|
||||
$("#terminal-input").before('<tr class="posted"><td id="hack-progress-bar" style="color: #66ff33;">' + input + '</td></tr>');
|
||||
window.scrollTo(0, document.body.scrollHeight);
|
||||
}
|
||||
|
||||
var hackProgressPost = function(input) {
|
||||
$("#terminal-input").before('<tr class="posted"><td id="hack-progress" style="color: #66ff33;">' + input + '</td></tr>');
|
||||
window.scrollTo(0, document.body.scrollHeight);
|
||||
}
|
||||
|
||||
var postNetburnerText = function() {
|
||||
post("Netburner v1.0");
|
||||
}
|
||||
@ -77,8 +88,8 @@ var Terminal = {
|
||||
} else if (Player.currentServer.requiredHackingSkill > Player.hacking_skill) {
|
||||
post("Your hacking skill is not high enough to attempt hacking this machine. Try analyzing the machine to determine the required hacking skill");
|
||||
} else {
|
||||
post("<p id='hacking-progress'> Time left: </p>");
|
||||
post("<p id='hacking-progress-bar'> | </p>");
|
||||
hackProgressPost("Time left:");
|
||||
hackProgressBarPost("[");
|
||||
var hackResult = Player.hack();
|
||||
}
|
||||
break;
|
||||
|
@ -87,7 +87,6 @@ var Engine = {
|
||||
loadTerminalContent: function() {
|
||||
Engine.hideAllContent();
|
||||
Engine.Display.terminalContent.style.visibility = "visible";
|
||||
postNetburnerText();
|
||||
},
|
||||
|
||||
loadCharacterContent: function() {
|
||||
@ -132,7 +131,8 @@ var Engine = {
|
||||
var idleTime = Engine._idleSpeed - timeDifference;
|
||||
|
||||
//Manual hack
|
||||
if (Player.startHack = true) {
|
||||
if (Player.startHack == true) {
|
||||
console.log("Player.startHack flag was set to true");
|
||||
Engine._totalHackTime = Player.hackingTime;
|
||||
Engine._hackTimeLeft = Player.hackingTime;
|
||||
Engine._manualHackInProgress = true;
|
||||
@ -159,25 +159,26 @@ var Engine = {
|
||||
_hackProgressBarCount: 0,
|
||||
_manualHackInProgress: false,
|
||||
updateHackProgress: function() {
|
||||
if (Engine.manualHackInProgress) {
|
||||
Engine._hackTimeLeft -= (_idleSpeed/ 1000); //Substract idle speed (ms)
|
||||
if (Engine._manualHackInProgress == true) {
|
||||
console.log("Manual Hack in Progress");
|
||||
Engine._hackTimeLeft -= (Engine._idleSpeed/ 1000); //Substract idle speed (ms)
|
||||
|
||||
//Calculate percent filled
|
||||
var percent = Math.floor((1 - Engine._hackTimeLeft / Engine.totalhackTime) * 100);
|
||||
console.log("Hack progress percent: " + percent);
|
||||
|
||||
//Update progress bar
|
||||
if (Engine._hackProgressBarCount * 2 < percent) {
|
||||
Engine._hackProgressStr += '|';
|
||||
Engine._ProgressBarCount += 1;
|
||||
$('#hacking-progress-bar').html(Engine._hackProgressStr);
|
||||
document.getElementbyId("hack-progress-bar").innerHTML = Engine._hackProgressStr;
|
||||
}
|
||||
|
||||
//Update hack time remaining
|
||||
Engine._hackTimeStr = "Time left: " + Engine._hackTimeLeft.asString();
|
||||
$('#hacking-progress').html(Engine._hackTimeStr);
|
||||
//Engine._hackTimeStr = "Time left: " + Engine._hackTimeLeft.asString();
|
||||
|
||||
//Once percent is 100, the hack is completed
|
||||
if (percent == 100) {
|
||||
if (percent >= 100) {
|
||||
Engine.manualHackInProgress = false;
|
||||
Player.finishHack = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user