fix sleeve consuming too much time at once.

This commit is contained in:
Olivier Gagnon 2021-10-09 14:31:06 -04:00
parent 752534bc4d
commit 2bf47c60df
5 changed files with 20 additions and 19 deletions

24
dist/vendor.bundle.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -189,7 +189,8 @@ function startNetscript1Script(workerScript: WorkerScript): Promise<WorkerScript
cb(res); cb(res);
}) })
.catch(function (err: any) { .catch(function (err: any) {
console.error(err); // workerscript is when you cancel a delay
if (!(err instanceof WorkerScript)) console.error(err);
}); });
}; };
int.setProperty(scope, name, int.createAsyncFunction(tempWrapper)); int.setProperty(scope, name, int.createAsyncFunction(tempWrapper));

@ -476,9 +476,9 @@ export class Sleeve extends Person {
return null; return null;
} }
let time = this.storedCycles * CONSTANTS.MilliPerCycle;
let cyclesUsed = this.storedCycles; let cyclesUsed = this.storedCycles;
cyclesUsed = Math.min(cyclesUsed, 15); cyclesUsed = Math.min(cyclesUsed, 15);
let time = cyclesUsed * CONSTANTS.MilliPerCycle;
if (this.currentTaskMaxTime !== 0 && this.currentTaskTime + time > this.currentTaskMaxTime) { if (this.currentTaskMaxTime !== 0 && this.currentTaskTime + time > this.currentTaskMaxTime) {
time = this.currentTaskMaxTime - this.currentTaskTime; time = this.currentTaskMaxTime - this.currentTaskTime;
cyclesUsed = Math.floor(time / CONSTANTS.MilliPerCycle); cyclesUsed = Math.floor(time / CONSTANTS.MilliPerCycle);
@ -489,6 +489,7 @@ export class Sleeve extends Person {
cyclesUsed = 0; cyclesUsed = 0;
} }
} }
console.log(cyclesUsed);
this.currentTaskTime += time; this.currentTaskTime += time;
// Shock gradually goes towards 100 // Shock gradually goes towards 100
@ -562,6 +563,7 @@ export class Sleeve extends Person {
* Resets all parameters used to keep information about the current task * Resets all parameters used to keep information about the current task
*/ */
resetTaskStatus(): void { resetTaskStatus(): void {
console.error("");
this.earningsForTask = createTaskTracker(); this.earningsForTask = createTaskTracker();
this.gainRatesForTask = createTaskTracker(); this.gainRatesForTask = createTaskTracker();
this.currentTask = SleeveTaskType.Idle; this.currentTask = SleeveTaskType.Idle;
@ -846,7 +848,6 @@ export class Sleeve extends Person {
this.currentTaskLocation = companyName; this.currentTaskLocation = companyName;
this.currentTask = SleeveTaskType.Company; this.currentTask = SleeveTaskType.Company;
this.currentTaskMaxTime = CONSTANTS.MillisecondsPer8Hours;
return true; return true;
} }
@ -906,7 +907,6 @@ export class Sleeve extends Person {
this.currentTaskLocation = factionName; this.currentTaskLocation = factionName;
this.currentTask = SleeveTaskType.Faction; this.currentTask = SleeveTaskType.Faction;
this.currentTaskMaxTime = CONSTANTS.MillisecondsPer20Hours;
return true; return true;
} }