BITNODE: IPvGO territory control strategy game (#934)

This commit is contained in:
Michael Ficocelli
2023-12-26 11:45:27 -05:00
committed by GitHub
parent c6141f2adf
commit 7ef12a0323
68 changed files with 7833 additions and 17 deletions
+140
View File
@@ -0,0 +1,140 @@
import React from "react";
import Typography from "@mui/material/Typography";
import { Grid, Table, TableBody, TableCell, TableRow, Tooltip } from "@mui/material";
import { opponentList, opponents } from "../boardState/goConstants";
import { getPlayerStats, getScore } from "../boardAnalysis/scoring";
import { Player } from "@player";
import { GoGameboard } from "./GoGameboard";
import { boardStyles } from "../boardState/goStyles";
import { useRerender } from "../../ui/React/hooks";
import { getBonusText, getMaxFavor } from "../effects/effect";
import { formatNumber } from "../../ui/formatNumber";
import { GoScoreSummaryTable } from "./GoScoreSummaryTable";
import { getNewBoardState } from "../boardState/boardState";
import { CorruptableText } from "../../ui/React/CorruptableText";
import { showWorldDemon } from "../boardAnalysis/goAI";
export const GoHistoryPage = (): React.ReactElement => {
useRerender(400);
const classes = boardStyles();
const priorBoard = Player.go.previousGameFinalBoardState ?? getNewBoardState(7);
const score = getScore(priorBoard);
const opponent = priorBoard.ai;
const opponentsToShow = showWorldDemon() ? [...opponentList, opponents.w0r1d_d43m0n] : opponentList;
return (
<div>
<Grid container>
<Grid item>
<div className={classes.statusPageScore}>
<Typography variant="h5">Previous Subnet:</Typography>
<GoScoreSummaryTable score={score} opponent={opponent} />
</div>
</Grid>
<Grid item>
<div className={`${classes.historyPageGameboard} ${classes.translucent}`}>
<GoGameboard
boardState={priorBoard}
traditional={false}
clickHandler={(x, y) => ({ x, y })}
hover={false}
/>
</div>
</Grid>
</Grid>
<br />
<br />
<Typography variant="h5">Faction Stats:</Typography>
<Grid container style={{ maxWidth: "1020px" }}>
{opponentsToShow.map((faction, index) => {
const data = getPlayerStats(faction);
return (
<Grid item key={opponentsToShow[index]} className={classes.factionStatus}>
<Typography>
{" "}
<strong className={classes.keyText}>
{faction === opponents.w0r1d_d43m0n ? <CorruptableText content="????????????" /> : faction}
</strong>
</Typography>
<Table sx={{ display: "table", mb: 1, width: "100%" }}>
<TableBody>
<TableRow>
<TableCell className={classes.cellNone}>Wins:</TableCell>
<TableCell className={classes.cellNone}>
{data.wins} / {data.losses + data.wins}
</TableCell>
</TableRow>
<TableRow>
<TableCell className={classes.cellNone}>Current winstreak:</TableCell>
<TableCell className={classes.cellNone}>{data.winStreak}</TableCell>
</TableRow>
<TableRow>
<TableCell className={`${classes.cellNone} ${classes.cellBottomPadding}`}>
Highest winstreak:
</TableCell>
<TableCell className={`${classes.cellNone} ${classes.cellBottomPadding}`}>
{data.highestWinStreak}
</TableCell>
</TableRow>
<Tooltip
title={
<>
The total number of empty points and routers <br /> you took control of, across all subnets
</>
}
>
<TableRow>
<TableCell className={classes.cellNone}>Captured nodes:</TableCell>
<TableCell className={classes.cellNone}>{data.nodes}</TableCell>
</TableRow>
</Tooltip>
<Tooltip
title={
<>
Node power is what stat bonuses scale from, and is gained on each completed subnet. <br />
It is calculated from the number of nodes you control, multiplied by modifiers for the <br />
opponent difficulty, if you won or lost, and your current winstreak.
</>
}
>
<TableRow>
<TableCell className={`${classes.cellNone} ${classes.cellBottomPadding}`}>Node power:</TableCell>
<TableCell className={`${classes.cellNone} ${classes.cellBottomPadding}`}>
{formatNumber(data.nodePower, 2)}
</TableCell>
</TableRow>
</Tooltip>
<Tooltip
title={
<>
Win streaks against a faction will give you +1 favor to that faction <br />
at certain numbers of wins (up to a max of 100 favor), <br />
if you are currently a member of that faction
</>
}
>
<TableRow>
<TableCell className={classes.cellNone}>Favor from winstreaks:</TableCell>
<TableCell className={classes.cellNone}>
{data.favor ?? 0} {data.favor === getMaxFavor() ? "(max)" : ""}
</TableCell>
</TableRow>
</Tooltip>
</TableBody>
</Table>
<br />
<Tooltip title={<>The total stat multiplier gained via your current node power.</>}>
<Typography>
<strong className={classes.keyText}>Bonus:</strong>
<br />
<strong className={classes.keyText}>{getBonusText(faction)}</strong>
</Typography>
</Tooltip>
</Grid>
);
})}
</Grid>
</div>
);
};