/** * This file is part of the SplendidBear Websites' projects. * * Copyright (c) 2026 @ www.splendidbear.org * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ import React, { Fragment, useState } from 'react'; import { useGame } from '@mine-contexts'; import User from './User'; import BonusStatsDialog from '../BonusStatsDialog'; import { func } from 'prop-types'; const UserControl = ({ resign }) => { const { webPlayer, activePlayer, foundMines, red, blue, onBombToggle } = useGame(); const [bonusDialogOpen, setBonusDialogOpen] = useState(false); const activeColor = activePlayer ? 'blue' : 'red'; const resignClass = 'resign' + (activeColor !== webPlayer ? ' disabled' : ''); const minesClass = 'active-mines' + (foundMines ? ' found-mine' : ''); const remainingMines = 51 - red.mines - blue.mines; const handleBombClick = (color, player) => { const p = 'red' === color ? red : blue; if (p.haveBomb && p.enabledBomb && activePlayer === player) { onBombToggle(); } }; const handleBonusClick = () => { setBonusDialogOpen(true); }; return (
handleBombClick('blue', 1)} onBonusClick={handleBonusClick} />
{remainingMines}
handleBombClick('red', 0)} onBonusClick={handleBonusClick} />
setBonusDialogOpen(false)} red={red} blue={blue} /> ); } export default UserControl; UserControl.propTypes = { resign: func.isRequired, };