diff --git a/src/Work/CreateProgramWork.ts b/src/Work/CreateProgramWork.ts index c4b3d1e6e..56a25d9c7 100644 --- a/src/Work/CreateProgramWork.ts +++ b/src/Work/CreateProgramWork.ts @@ -21,10 +21,11 @@ export class CreateProgramWork extends Work { programName: CompletedProgramName; // amount of effective work completed on the program (time boosted by skills). unitCompleted: number; - + unitRate: number; constructor(params?: CreateProgramWorkParams) { super(WorkType.CREATE_PROGRAM, params?.singularity ?? true); this.unitCompleted = 0; + this.unitRate = 0; this.programName = params?.programName ?? CompletedProgramName.bruteSsh; if (params) { @@ -63,7 +64,8 @@ export class CreateProgramWork extends Work { skillMult *= focusBonus; //Skill multiplier directly applied to "time worked" this.cyclesWorked += cycles; - this.unitCompleted += CONSTANTS.MilliPerCycle * cycles * skillMult; + this.unitRate = CONSTANTS.MilliPerCycle * cycles * skillMult; + this.unitCompleted += this.unitRate; if (this.unitCompleted >= this.unitNeeded()) { return true; diff --git a/src/Work/GraftingWork.tsx b/src/Work/GraftingWork.tsx index cd2f8eea9..3ee202015 100644 --- a/src/Work/GraftingWork.tsx +++ b/src/Work/GraftingWork.tsx @@ -21,10 +21,12 @@ interface GraftingWorkParams { export class GraftingWork extends Work { augmentation: AugmentationName; unitCompleted: number; + unitRate: number; constructor(params?: GraftingWorkParams) { super(WorkType.GRAFTING, params?.singularity ?? true); this.unitCompleted = 0; + this.unitRate = 0; this.augmentation = params?.augmentation ?? AugmentationName.Targeting1; const gAugs = GraftableAugmentations(); if (params) Player.loseMoney(gAugs[this.augmentation].cost, "augmentations"); @@ -37,8 +39,8 @@ export class GraftingWork extends Work { process(cycles: number): boolean { const focusBonus = Player.focusPenalty(); this.cyclesWorked += cycles; - this.unitCompleted += CONSTANTS.MilliPerCycle * cycles * graftingIntBonus() * focusBonus; - + this.unitRate = CONSTANTS.MilliPerCycle * cycles * graftingIntBonus() * focusBonus; + this.unitCompleted += this.unitRate; return this.unitCompleted >= this.unitNeeded(); } diff --git a/src/ui/WorkInProgressRoot.tsx b/src/ui/WorkInProgressRoot.tsx index 25b7fb222..586d1acc6 100644 --- a/src/ui/WorkInProgressRoot.tsx +++ b/src/ui/WorkInProgressRoot.tsx @@ -286,7 +286,7 @@ export function WorkInProgressRoot(): React.ReactElement { if (isCreateProgramWork(Player.currentWork)) { const create = Player.currentWork; const completion = (create.unitCompleted / create.unitNeeded()) * 100; - + const remainingTime = ((create.unitNeeded() - create.unitCompleted) / create.unitRate) * CONSTANTS.MilliPerCycle; workInfo = { buttons: { cancel: () => { @@ -305,7 +305,7 @@ export function WorkInProgressRoot(): React.ReactElement { ), progress: { - elapsed: create.cyclesWorked * CONSTANTS.MilliPerCycle, + remaining: remainingTime, percentage: completion, }, @@ -316,7 +316,8 @@ export function WorkInProgressRoot(): React.ReactElement { if (isGraftingWork(Player.currentWork)) { const graftWork = Player.currentWork; - + const remainingTime = + ((graftWork.unitNeeded() - graftWork.unitCompleted) / graftWork.unitRate) * CONSTANTS.MilliPerCycle; workInfo = { buttons: { cancel: () => { @@ -335,7 +336,7 @@ export function WorkInProgressRoot(): React.ReactElement { ), progress: { - elapsed: graftWork.cyclesWorked * CONSTANTS.MilliPerCycle, + remaining: remainingTime, percentage: (graftWork.unitCompleted / graftWork.unitNeeded()) * 100, },