mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-25 10:42:51 +02:00
More work on terminal.
This commit is contained in:
+1
-51
@@ -444,16 +444,7 @@ const Engine = {
|
||||
Player.playtimeSinceLastAug += time;
|
||||
Player.playtimeSinceLastBitnode += time;
|
||||
|
||||
// Start Manual hack
|
||||
if (Terminal.actionStarted === true) {
|
||||
Engine._totalActionTime = Terminal.actionTime;
|
||||
Engine._actionTimeLeft = Terminal.actionTime;
|
||||
Engine._actionInProgress = true;
|
||||
Engine._actionProgressBarCount = 1;
|
||||
Engine._actionProgressStr = "[ ]";
|
||||
Engine._actionTimeStr = "Time left: ";
|
||||
Terminal.actionStarted = false;
|
||||
}
|
||||
Terminal.process(Player, numCycles);
|
||||
|
||||
// Working
|
||||
if (Player.isWorking) {
|
||||
@@ -519,11 +510,6 @@ const Engine = {
|
||||
Engine.decrementAllCounters(numCycles);
|
||||
Engine.checkCounters();
|
||||
|
||||
// Manual hacks
|
||||
if (Engine._actionInProgress == true) {
|
||||
Engine.updateHackProgress(numCycles);
|
||||
}
|
||||
|
||||
// Update the running time of all active scripts
|
||||
updateOnlineScriptTimes(numCycles);
|
||||
|
||||
@@ -623,42 +609,6 @@ const Engine = {
|
||||
}
|
||||
},
|
||||
|
||||
// Calculates the hack progress for a manual (non-scripted) hack and updates the progress bar/time accordingly
|
||||
// TODO Refactor this into Terminal module
|
||||
_totalActionTime: 0,
|
||||
_actionTimeLeft: 0,
|
||||
_actionTimeStr: "Time left: ",
|
||||
_actionProgressStr: "[ ]",
|
||||
_actionProgressBarCount: 1,
|
||||
_actionInProgress: false,
|
||||
updateHackProgress: function (numCycles = 1) {
|
||||
var timeElapsedMilli = numCycles * Engine._idleSpeed;
|
||||
Engine._actionTimeLeft -= timeElapsedMilli / 1000; // Substract idle speed (ms)
|
||||
Engine._actionTimeLeft = Math.max(Engine._actionTimeLeft, 0);
|
||||
|
||||
// Calculate percent filled
|
||||
var percent = Math.round((1 - Engine._actionTimeLeft / Engine._totalActionTime) * 100);
|
||||
|
||||
// Update progress bar
|
||||
while (Engine._actionProgressBarCount * 2 <= percent) {
|
||||
Engine._actionProgressStr = replaceAt(Engine._actionProgressStr, Engine._actionProgressBarCount, "|");
|
||||
Engine._actionProgressBarCount += 1;
|
||||
}
|
||||
|
||||
// Update hack time remaining
|
||||
Engine._actionTimeStr = "Time left: " + Math.max(0, Math.round(Engine._actionTimeLeft)).toString() + "s";
|
||||
document.getElementById("hack-progress").innerHTML = Engine._actionTimeStr;
|
||||
|
||||
// Dynamically update progress bar
|
||||
document.getElementById("hack-progress-bar").innerHTML = Engine._actionProgressStr.replace(/ /g, " ");
|
||||
|
||||
// Once percent is 100, the hack is completed
|
||||
if (percent >= 100) {
|
||||
Engine._actionInProgress = false;
|
||||
Terminal.finishAction();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Used in game when clicking on a main menu header (NOT used for initialization)
|
||||
* @param open {boolean} Whether header is being opened or closed
|
||||
|
||||
Reference in New Issue
Block a user