From 437cd66ffe48bbf7ae2fbfa86e1a5e3bbf4014b0 Mon Sep 17 00:00:00 2001 From: nickofolas Date: Sat, 30 Apr 2022 00:27:49 -0500 Subject: [PATCH] Update Minesweeper game UI --- src/Infiltration/ui/MinesweeperGame.tsx | 76 ++++++++++++++++++------- 1 file changed, 56 insertions(+), 20 deletions(-) diff --git a/src/Infiltration/ui/MinesweeperGame.tsx b/src/Infiltration/ui/MinesweeperGame.tsx index 1ec2538b9..9e8faa6de 100644 --- a/src/Infiltration/ui/MinesweeperGame.tsx +++ b/src/Infiltration/ui/MinesweeperGame.tsx @@ -1,7 +1,10 @@ -import { Paper, Typography } from "@mui/material"; +import { Close, Flag, Report } from "@mui/icons-material"; +import { Box, Paper, Typography } from "@mui/material"; +import { uniqueId } from "lodash"; import React, { useEffect, useState } from "react"; import { AugmentationNames } from "../../Augmentation/data/AugmentationNames"; import { Player } from "../../Player"; +import { Settings } from "../../Settings/Settings"; import { KEY } from "../../utils/helpers/keyCodes"; import { downArrowSymbol, getArrow, leftArrowSymbol, rightArrowSymbol, upArrowSymbol } from "../utils"; import { interpolate } from "./Difficulty"; @@ -80,29 +83,62 @@ export function MinesweeperGame(props: IMinigameProps): React.ReactElement { return () => clearInterval(id); }, []); + const flatGrid: { flagged?: boolean; current?: boolean; marked?: boolean }[] = []; + + minefield.map((line, y) => + line.map((cell, x) => { + if (memoryPhase) { + flatGrid.push({ flagged: Boolean(minefield[y][x]) }); + return; + } else if (x === pos[0] && y === pos[1]) { + flatGrid.push({ current: true }); + } else if (answer[y][x]) { + flatGrid.push({ marked: true }); + } else if (hasAugment && minefield[y][x]) { + flatGrid.push({ flagged: true }); + } else { + flatGrid.push({}); + } + }), + ); + return ( <> - + {memoryPhase ? "Remember all the mines!" : "Mark all the mines!"} - {minefield.map((line, y) => ( -
- - {line.map((cell, x) => { - if (memoryPhase) { - if (minefield[y][x]) return [?] ; - return [ ] ; - } else { - if (x == pos[0] && y == pos[1]) return [X] ; - if (answer[y][x]) return [.] ; - if (hasAugment && minefield[y][x]) return [?] ; - return [ ] ; - } - })} - -
-
- ))} + + {flatGrid.map((item) => { + const color = item.current + ? Settings.theme.infolight + : item.marked + ? Settings.theme.warning + : Settings.theme.error; + return ( + + {item.current ? : item.flagged ? : item.marked ? : <>} + + ); + })} +