mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-20 21:25:47 +01:00
BLADEBURNER: Add remaining time for actions (#1391)
This commit is contained in:
parent
bec6e82d7f
commit
a12056a898
@ -11,18 +11,51 @@ import { TeamSizeButton } from "./TeamSizeButton";
|
|||||||
|
|
||||||
import { formatNumberNoSuffix } from "../../ui/formatNumber";
|
import { formatNumberNoSuffix } from "../../ui/formatNumber";
|
||||||
import { BlackOperation, Operation } from "../Actions";
|
import { BlackOperation, Operation } from "../Actions";
|
||||||
|
import { BladeburnerConstants } from "../data/Constants";
|
||||||
|
import { convertTimeMsToTimeElapsedString } from "../../utils/StringHelperFunctions";
|
||||||
|
|
||||||
interface ActionHeaderProps {
|
interface ActionHeaderProps {
|
||||||
bladeburner: Bladeburner;
|
bladeburner: Bladeburner;
|
||||||
action: Action;
|
action: Action;
|
||||||
rerender: () => void;
|
rerender: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ActionHeader({ bladeburner, action, rerender }: ActionHeaderProps): React.ReactElement {
|
export function ActionHeader({ bladeburner, action, rerender }: ActionHeaderProps): React.ReactElement {
|
||||||
const isActive = action.name === bladeburner.action?.name;
|
const isActive = action.name === bladeburner.action?.name;
|
||||||
const computedActionTimeCurrent = Math.min(
|
const computedActionTimeCurrent = Math.min(
|
||||||
bladeburner.actionTimeCurrent + bladeburner.actionTimeOverflow,
|
bladeburner.actionTimeCurrent + bladeburner.actionTimeOverflow,
|
||||||
bladeburner.actionTimeToComplete,
|
bladeburner.actionTimeToComplete,
|
||||||
);
|
);
|
||||||
|
const remainingSeconds = Math.max(
|
||||||
|
bladeburner.actionTimeToComplete - bladeburner.actionTimeCurrent + bladeburner.actionTimeOverflow,
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
const remainingBonusSeconds = Math.floor(bladeburner.storedCycles / BladeburnerConstants.CyclesPerSecond);
|
||||||
|
/**
|
||||||
|
* Bladeburner is processed every second. Each time it's processed, we use (up to) 4 bonus seconds and process it as
|
||||||
|
* if (up to) 5 seconds passed.
|
||||||
|
* For example, with 20 bonus seconds, we need 5 seconds to use up all those bonus seconds. After 5 seconds, we used
|
||||||
|
* up 20 bonus seconds and processed Bladeburner as if 25 seconds had passed.
|
||||||
|
*/
|
||||||
|
const effectiveBonusSeconds = (remainingBonusSeconds / 4) * 5;
|
||||||
|
let eta;
|
||||||
|
if (remainingSeconds <= effectiveBonusSeconds) {
|
||||||
|
// If we have enough effectiveBonusSeconds, ETA is (remainingSeconds / 5).
|
||||||
|
eta = Math.floor(remainingSeconds / 5);
|
||||||
|
} else {
|
||||||
|
/**
|
||||||
|
* For example, let's say we start the "Training" action with 20 bonus seconds: remainingSeconds=30;remainingBonusSeconds=20.
|
||||||
|
* After 5 seconds (remainingBonusSeconds / 4), we processed Bladeburner as if 25 seconds (effectiveBonusSeconds)
|
||||||
|
* had passed. We still need 5 more seconds (30 - 25 = remainingTime - effectiveBonusSeconds) to complete the action
|
||||||
|
* at normal speed.
|
||||||
|
*
|
||||||
|
* ETA = remainingBonusSeconds / 4 + remainingTime - effectiveBonusSeconds
|
||||||
|
* = remainingBonusSeconds / 4 + remainingTime - ((remainingBonusSeconds / 4) * 5)
|
||||||
|
* = remainingTime - remainingBonusSeconds
|
||||||
|
*/
|
||||||
|
eta = remainingSeconds - remainingBonusSeconds;
|
||||||
|
}
|
||||||
|
|
||||||
const allowTeam = action instanceof Operation || action instanceof BlackOperation;
|
const allowTeam = action instanceof Operation || action instanceof BlackOperation;
|
||||||
|
|
||||||
if (isActive) {
|
if (isActive) {
|
||||||
@ -36,11 +69,14 @@ export function ActionHeader({ bladeburner, action, rerender }: ActionHeaderProp
|
|||||||
(IN PROGRESS - {formatNumberNoSuffix(computedActionTimeCurrent, 0)} /{" "}
|
(IN PROGRESS - {formatNumberNoSuffix(computedActionTimeCurrent, 0)} /{" "}
|
||||||
{formatNumberNoSuffix(bladeburner.actionTimeToComplete, 0)})
|
{formatNumberNoSuffix(bladeburner.actionTimeToComplete, 0)})
|
||||||
</Typography>
|
</Typography>
|
||||||
|
<Box display="flex" flexDirection="row" alignItems="center">
|
||||||
<Typography>
|
<Typography>
|
||||||
{createProgressBarText({
|
{createProgressBarText({
|
||||||
progress: computedActionTimeCurrent / bladeburner.actionTimeToComplete,
|
progress: computedActionTimeCurrent / bladeburner.actionTimeToComplete,
|
||||||
})}
|
})}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
<Typography marginLeft="1rem">Remaining time: {convertTimeMsToTimeElapsedString(eta * 1000)}</Typography>
|
||||||
|
</Box>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ export function Stats({ bladeburner }: StatsProps): React.ReactElement {
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
</Box>
|
</Box>
|
||||||
<br />
|
<br />
|
||||||
{(bladeburner.storedCycles / BladeburnerConstants.CyclesPerSecond) * 1000 > 15000 && (
|
{bladeburner.storedCycles / BladeburnerConstants.CyclesPerSecond > 3 && (
|
||||||
<>
|
<>
|
||||||
<Box display="flex">
|
<Box display="flex">
|
||||||
<Tooltip
|
<Tooltip
|
||||||
|
@ -148,7 +148,7 @@ const Engine: {
|
|||||||
checkFactionInvitations: 100,
|
checkFactionInvitations: 100,
|
||||||
passiveFactionGrowth: 5,
|
passiveFactionGrowth: 5,
|
||||||
messages: 150,
|
messages: 150,
|
||||||
mechanicProcess: 5, // Processes certain mechanics (Corporation, Bladeburner)
|
mechanicProcess: 5, // Process Bladeburner
|
||||||
contractGeneration: 3000, // Generate Coding Contracts
|
contractGeneration: 3000, // Generate Coding Contracts
|
||||||
achievementsCounter: 60, // Check if we have new achievements
|
achievementsCounter: 60, // Check if we have new achievements
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user