2026-04-10 21:53:50 +02:00
|
|
|
/**
|
2026-04-10 17:57:26 +02:00
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2026-04-19 21:31:08 +02:00
|
|
|
import React, { useState } from 'react';
|
2026-04-10 21:53:50 +02:00
|
|
|
import { useGame } from '@mine-contexts';
|
|
|
|
|
import { useServerCommunication } from '@mine-hooks';
|
2026-04-19 21:31:08 +02:00
|
|
|
import CaptchaOverlay from './CaptchaOverlay';
|
2026-04-10 17:57:26 +02:00
|
|
|
import GridControl from './grid/GridControl';
|
2026-04-21 11:30:07 +02:00
|
|
|
import { bool, string } from 'prop-types';
|
2026-04-10 17:57:26 +02:00
|
|
|
|
2026-04-19 18:04:01 +02:00
|
|
|
export const GameBoard = ({ gameAssoc, gameInherited, opponentName = '', isEnvDev }) => {
|
2026-04-10 17:57:26 +02:00
|
|
|
const { gridReady } = useGame();
|
2026-04-19 18:04:01 +02:00
|
|
|
const { onClick, resign } = useServerCommunication(gameAssoc, gameInherited, opponentName, isEnvDev);
|
2026-04-19 21:31:08 +02:00
|
|
|
const [captchaVerified, setCaptchaVerified] = useState(false);
|
|
|
|
|
|
|
|
|
|
const siteKey = document.getElementById('mine-wrapper')?.dataset.recaptchaSiteKey;
|
2026-04-10 17:57:26 +02:00
|
|
|
|
|
|
|
|
if (!gridReady) {
|
|
|
|
|
return (
|
|
|
|
|
<div className="game-overlay">
|
|
|
|
|
<div className="game-overlay-window"><h1>Loading…</h1></div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-19 21:31:08 +02:00
|
|
|
if (!captchaVerified && siteKey) {
|
|
|
|
|
return (
|
|
|
|
|
<CaptchaOverlay siteKey={siteKey} onVerified={() => setCaptchaVerified(true)} />
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-10 19:09:05 +02:00
|
|
|
return (
|
|
|
|
|
<GridControl
|
2026-04-14 19:37:42 +02:00
|
|
|
gameAssoc={gameAssoc}
|
2026-04-10 19:09:05 +02:00
|
|
|
onClick={onClick}
|
|
|
|
|
resign={resign}
|
|
|
|
|
/>
|
|
|
|
|
);
|
2026-04-10 17:57:26 +02:00
|
|
|
};
|
2026-04-21 11:30:07 +02:00
|
|
|
|
|
|
|
|
GameBoard.propTypes = {
|
|
|
|
|
gameAssoc: string.isRequired,
|
|
|
|
|
gameInherited: bool.isRequired,
|
|
|
|
|
opponentName: string,
|
|
|
|
|
isEnvDev: bool,
|
|
|
|
|
};
|