ACCESSIBILITY: Wire cutting infil now prints colours of wire along the wire (#1380)

This commit is contained in:
muesli4brekkies 2024-06-10 00:49:34 +01:00 committed by GitHub
parent 9a2bb16548
commit 7b3265346d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -4,7 +4,6 @@ import { Box, Paper, Typography } from "@mui/material";
import { AugmentationName } from "@enums"; import { AugmentationName } from "@enums";
import { Player } from "@player"; import { Player } from "@player";
import { Settings } from "../../Settings/Settings"; import { Settings } from "../../Settings/Settings";
import { KEY } from "../../utils/helpers/keyCodes";
import { random } from "../utils"; import { random } from "../utils";
import { interpolate } from "./Difficulty"; import { interpolate } from "./Difficulty";
import { GameTimer } from "./GameTimer"; import { GameTimer } from "./GameTimer";
@ -32,19 +31,17 @@ const difficulties: {
Impossible: { timer: 4000, wiresmin: 9, wiresmax: 9, rules: 4 }, Impossible: { timer: 4000, wiresmin: 9, wiresmax: 9, rules: 4 },
}; };
const types = [KEY.PIPE, KEY.DOT, KEY.FORWARD_SLASH, KEY.HYPHEN, "█", KEY.HASH];
const colors = ["red", "#FFC107", "blue", "white"]; const colors = ["red", "#FFC107", "blue", "white"];
const colorNames: Record<string, string> = { const colorNames: Record<string, string> = {
red: "red", red: "RED",
"#FFC107": "yellow", "#FFC107": "YELLOW",
blue: "blue", blue: "BLUE",
white: "white", white: "WHITE",
}; };
interface Wire { interface Wire {
wireType: string; wireType: string[];
colors: string[]; colors: string[];
} }
@ -142,7 +139,7 @@ export function WireCuttingGame({ onSuccess, onFailure, difficulty }: IMinigameP
</Typography> </Typography>
); );
})} })}
{new Array(8).fill(0).map((_, i) => ( {new Array(11).fill(0).map((_, i) => (
<React.Fragment key={i}> <React.Fragment key={i}>
{wires.map((wire, j) => { {wires.map((wire, j) => {
if ((i === 3 || i === 4) && cutWires[j]) { if ((i === 3 || i === 4) && cutWires[j]) {
@ -153,7 +150,7 @@ export function WireCuttingGame({ onSuccess, onFailure, difficulty }: IMinigameP
hasAugment && !isCorrectWire ? Settings.theme.disabled : wire.colors[i % wire.colors.length]; hasAugment && !isCorrectWire ? Settings.theme.disabled : wire.colors[i % wire.colors.length];
return ( return (
<Typography key={j} style={{ color: wireColor }}> <Typography key={j} style={{ color: wireColor }}>
|{wire.wireType}| |{wire.wireType[i % wire.wireType.length]}|
</Typography> </Typography>
); );
})} })}
@ -172,7 +169,7 @@ function randomPositionQuestion(wires: Wire[]): Question {
toString: (): string => { toString: (): string => {
return `Cut wires number ${index + 1}.`; return `Cut wires number ${index + 1}.`;
}, },
shouldCut: (wire: Wire, i: number): boolean => { shouldCut: (_wire: Wire, i: number): boolean => {
return index === i; return index === i;
}, },
}; };
@ -209,8 +206,9 @@ function generateWires(difficulty: Difficulty): Wire[] {
if (Math.random() < 0.15) { if (Math.random() < 0.15) {
wireColors.push(colors[Math.floor(Math.random() * colors.length)]); wireColors.push(colors[Math.floor(Math.random() * colors.length)]);
} }
const wireType = [...wireColors.map((color) => colorNames[color]).join("")];
wires.push({ wires.push({
wireType: types[Math.floor(Math.random() * types.length)], wireType,
colors: wireColors, colors: wireColors,
}); });
} }