UNPKG

tmemory

Version:

A terminal-based Memory card game built with React Ink. Features multiple grid sizes, AI opponent, and high scores.

26 lines (25 loc) 1.41 kB
import { Box, Text } from 'ink'; import React from 'react'; import { COLORS } from "../../../constants/colors.js"; import { useGame } from "../../../context/GameContext/index.js"; export const GameControls = () => { const { state } = useGame(); const { gameMode, currentPlayer } = state; return (React.createElement(Box, { flexDirection: "column", marginTop: 1 }, React.createElement(Box, { justifyContent: "space-between", marginBottom: 1 }, gameMode !== 'single' && (React.createElement(Text, { color: COLORS.info }, "Current Player:", ' ', React.createElement(Text, { bold: true, color: currentPlayer === 'ai' ? COLORS.ai : currentPlayer === 'p1' ? COLORS.p1 : COLORS.p2 }, currentPlayer === 'ai' ? 'AI' : currentPlayer.toUpperCase())))), (currentPlayer === 'p1' || currentPlayer === 'p2') && (React.createElement(Box, { flexDirection: "column" }, React.createElement(Text, { bold: true, color: COLORS.warn }, "Controls:"), React.createElement(Text, null, "\u2190/\u2192/\u2191/\u2193 ", React.createElement(Text, { dimColor: true }, "Move")), React.createElement(Text, null, "Space ", React.createElement(Text, { dimColor: true }, "Flip card")))))); };