mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-25 17:13:47 +01:00
INFILTRATION: Add HP and damage to Intro UI (#1242)
This commit is contained in:
parent
6a1691fe54
commit
6f009679ad
@ -1,6 +1,6 @@
|
|||||||
import { Button, Container, Paper, Typography } from "@mui/material";
|
import { Button, Container, Paper, Typography } from "@mui/material";
|
||||||
import React, { useCallback, useState } from "react";
|
import React, { useCallback, useState } from "react";
|
||||||
import { AugmentationName, FactionName } from "@enums";
|
import { FactionName } from "@enums";
|
||||||
import { Router } from "../../ui/GameRoot";
|
import { Router } from "../../ui/GameRoot";
|
||||||
import { Page } from "../../ui/Router";
|
import { Page } from "../../ui/Router";
|
||||||
import { Player } from "@player";
|
import { Player } from "@player";
|
||||||
@ -14,6 +14,7 @@ import { MinesweeperGame } from "./MinesweeperGame";
|
|||||||
import { SlashGame } from "./SlashGame";
|
import { SlashGame } from "./SlashGame";
|
||||||
import { Victory } from "./Victory";
|
import { Victory } from "./Victory";
|
||||||
import { WireCuttingGame } from "./WireCuttingGame";
|
import { WireCuttingGame } from "./WireCuttingGame";
|
||||||
|
import { calculateDamageAfterFailingInfiltration } from "../utils";
|
||||||
|
|
||||||
type GameProps = {
|
type GameProps = {
|
||||||
StartingDifficulty: number;
|
StartingDifficulty: number;
|
||||||
@ -94,7 +95,7 @@ export function Game(props: GameProps): React.ReactElement {
|
|||||||
// it's clear they're not meant to
|
// it's clear they're not meant to
|
||||||
const damage = options?.automated
|
const damage = options?.automated
|
||||||
? Player.hp.current
|
? Player.hp.current
|
||||||
: props.StartingDifficulty * 3 * (Player.hasAugmentation(AugmentationName.WKSharmonizer, true) ? 0.5 : 1);
|
: calculateDamageAfterFailingInfiltration(props.StartingDifficulty);
|
||||||
if (Player.takeDamage(damage)) {
|
if (Player.takeDamage(damage)) {
|
||||||
Router.toPage(Page.City);
|
Router.toPage(Page.City);
|
||||||
return;
|
return;
|
||||||
|
@ -33,6 +33,7 @@ export function InfiltrationRoot(props: IProps): React.ReactElement {
|
|||||||
) : (
|
) : (
|
||||||
<Intro
|
<Intro
|
||||||
Location={props.location}
|
Location={props.location}
|
||||||
|
StartingDifficulty={startingSecurityLevel}
|
||||||
Difficulty={difficulty}
|
Difficulty={difficulty}
|
||||||
MaxLevel={props.location.infiltrationData.maxClearanceLevel}
|
MaxLevel={props.location.infiltrationData.maxClearanceLevel}
|
||||||
start={() => setStart(true)}
|
start={() => setStart(true)}
|
||||||
|
@ -3,10 +3,13 @@ import { Box, Button, Container, Paper, Tooltip, Typography } from "@mui/materia
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { Location } from "../../Locations/Location";
|
import { Location } from "../../Locations/Location";
|
||||||
import { Settings } from "../../Settings/Settings";
|
import { Settings } from "../../Settings/Settings";
|
||||||
import { formatNumberNoSuffix } from "../../ui/formatNumber";
|
import { formatHp, formatNumberNoSuffix } from "../../ui/formatNumber";
|
||||||
|
import { Player } from "@player";
|
||||||
|
import { calculateDamageAfterFailingInfiltration } from "../utils";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
Location: Location;
|
Location: Location;
|
||||||
|
StartingDifficulty: number;
|
||||||
Difficulty: number;
|
Difficulty: number;
|
||||||
MaxLevel: number;
|
MaxLevel: number;
|
||||||
start: () => void;
|
start: () => void;
|
||||||
@ -56,6 +59,14 @@ export function Intro(props: IProps): React.ReactElement {
|
|||||||
<Typography variant="h4">
|
<Typography variant="h4">
|
||||||
Infiltrating <b>{props.Location.name}</b>
|
Infiltrating <b>{props.Location.name}</b>
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|
||||||
|
<Typography variant="h6">
|
||||||
|
<b>HP: {`${formatHp(Player.hp.current)} / ${formatHp(Player.hp.max)}`}</b>
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="h6">
|
||||||
|
<b>Lose {calculateDamageAfterFailingInfiltration(props.StartingDifficulty)} HP for each failure</b>
|
||||||
|
</Typography>
|
||||||
|
|
||||||
<Typography variant="h6">
|
<Typography variant="h6">
|
||||||
<b>Maximum Level: </b>
|
<b>Maximum Level: </b>
|
||||||
{props.MaxLevel}
|
{props.MaxLevel}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import { KEY } from "../utils/helpers/keyCodes";
|
import { KEY } from "../utils/helpers/keyCodes";
|
||||||
|
import { Player } from "@player";
|
||||||
|
import { AugmentationName } from "@enums";
|
||||||
|
|
||||||
export function random(min: number, max: number): number {
|
export function random(min: number, max: number): number {
|
||||||
return Math.random() * (max - min) + min;
|
return Math.random() * (max - min) + min;
|
||||||
@ -27,3 +29,7 @@ export function getArrow(event: KeyboardEvent): Arrow | undefined {
|
|||||||
return rightArrowSymbol;
|
return rightArrowSymbol;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function calculateDamageAfterFailingInfiltration(startingDifficulty: number): number {
|
||||||
|
return startingDifficulty * 3 * (Player.hasAugmentation(AugmentationName.WKSharmonizer, true) ? 0.5 : 1);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user