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

35 lines
1.0 KiB
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 { Action } from "../Action";
import { Bladeburner } from "../Bladeburner";
import { Player } from "@player";
2021-08-21 20:00:28 +02:00
interface IProps {
bladeburner: Bladeburner;
action: Action;
2021-08-21 20:00:28 +02:00
}
export function SuccessChance(props: IProps): React.ReactElement {
const estimatedSuccessChance = props.action.getEstSuccessChance(props.bladeburner, Player);
2021-09-27 23:09:48 +02:00
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
}