INFILTRATION: Add HP and damage to Intro UI (#1242)

This commit is contained in:
catloversg 2024-05-09 07:10:20 +07:00 committed by GitHub
parent 6a1691fe54
commit 6f009679ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 22 additions and 3 deletions

@ -1,6 +1,6 @@
import { Button, Container, Paper, Typography } from "@mui/material";
import React, { useCallback, useState } from "react";
import { AugmentationName, FactionName } from "@enums";
import { FactionName } from "@enums";
import { Router } from "../../ui/GameRoot";
import { Page } from "../../ui/Router";
import { Player } from "@player";
@ -14,6 +14,7 @@ import { MinesweeperGame } from "./MinesweeperGame";
import { SlashGame } from "./SlashGame";
import { Victory } from "./Victory";
import { WireCuttingGame } from "./WireCuttingGame";
import { calculateDamageAfterFailingInfiltration } from "../utils";
type GameProps = {
StartingDifficulty: number;
@ -94,7 +95,7 @@ export function Game(props: GameProps): React.ReactElement {
// it's clear they're not meant to
const damage = options?.automated
? Player.hp.current
: props.StartingDifficulty * 3 * (Player.hasAugmentation(AugmentationName.WKSharmonizer, true) ? 0.5 : 1);
: calculateDamageAfterFailingInfiltration(props.StartingDifficulty);
if (Player.takeDamage(damage)) {
Router.toPage(Page.City);
return;

@ -33,6 +33,7 @@ export function InfiltrationRoot(props: IProps): React.ReactElement {
) : (
<Intro
Location={props.location}
StartingDifficulty={startingSecurityLevel}
Difficulty={difficulty}
MaxLevel={props.location.infiltrationData.maxClearanceLevel}
start={() => setStart(true)}

@ -3,10 +3,13 @@ import { Box, Button, Container, Paper, Tooltip, Typography } from "@mui/materia
import React from "react";
import { Location } from "../../Locations/Location";
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 {
Location: Location;
StartingDifficulty: number;
Difficulty: number;
MaxLevel: number;
start: () => void;
@ -56,6 +59,14 @@ export function Intro(props: IProps): React.ReactElement {
<Typography variant="h4">
Infiltrating <b>{props.Location.name}</b>
</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">
<b>Maximum Level: </b>
{props.MaxLevel}

@ -1,4 +1,6 @@
import { KEY } from "../utils/helpers/keyCodes";
import { Player } from "@player";
import { AugmentationName } from "@enums";
export function random(min: number, max: number): number {
return Math.random() * (max - min) + min;
@ -27,3 +29,7 @@ export function getArrow(event: KeyboardEvent): Arrow | undefined {
return rightArrowSymbol;
}
}
export function calculateDamageAfterFailingInfiltration(startingDifficulty: number): number {
return startingDifficulty * 3 * (Player.hasAugmentation(AugmentationName.WKSharmonizer, true) ? 0.5 : 1);
}