bitburner-src/src/Bladeburner/ui/SuccessChance.tsx

34 lines
993 B
TypeScript
Raw Normal View History

2021-08-21 20:00:28 +02:00
import React from "react";
2021-09-25 20:42:57 +02:00
import { formatNumber } from "../../utils/StringHelperFunctions";
2021-09-27 23:09:48 +02:00
import { StealthIcon } from "./StealthIcon";
import { KillIcon } from "./KillIcon";
import { IAction } from "../IAction";
import { IBladeburner } from "../IBladeburner";
2021-08-21 20:00:28 +02:00
interface IProps {
2021-09-27 23:09:48 +02:00
bladeburner: IBladeburner;
action: IAction;
2021-08-21 20:00:28 +02:00
}
export function SuccessChance(props: IProps): React.ReactElement {
2021-09-27 23:09:48 +02:00
const estimatedSuccessChance = props.action.getEstSuccessChance(props.bladeburner);
let chance = <></>;
if (estimatedSuccessChance[0] === estimatedSuccessChance[1]) {
chance = <>{formatNumber(estimatedSuccessChance[0] * 100, 1)}%</>;
} else {
chance = (
<>
{formatNumber(estimatedSuccessChance[0] * 100, 1)}% ~ {formatNumber(estimatedSuccessChance[1] * 100, 1)}%
</>
);
2021-09-05 01:09:30 +02:00
}
2021-08-21 20:00:28 +02:00
2021-09-05 01:09:30 +02:00
return (
<>
2021-09-27 23:09:48 +02:00
Estimated success chance: {chance} {props.action.isStealth ? <StealthIcon /> : <></>}
{props.action.isKill ? <KillIcon /> : <></>}
2021-09-05 01:09:30 +02:00
</>
);
2021-08-21 20:00:28 +02:00
}