Private
Public Access
1
0

chg: dev: use namespaces for front-end #4

This commit is contained in:
2026-04-10 21:53:50 +02:00
parent c660c13ea2
commit 5b55a6ce73
18 changed files with 208 additions and 34 deletions

View File

@@ -1,9 +1,17 @@
/**
* 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, { useRef } from 'react';
import { Howl } from 'howler';
import GameContext from './GameContext';
import useGameRefs from '../hooks/useGameRefs';
import useGameState from '../hooks/useGameState';
import { DESC, IMAGES, patchCells } from '../utils/constants';
import { useGameRefs, useGameState } from '@mine-hooks';
import { DESC, IMAGES, patchCells } from '@mine-utils';
export const GameProvider = ({ children }) => {
const {
@@ -41,7 +49,8 @@ export const GameProvider = ({ children }) => {
won: new Howl({ src: ['/sound/won.mp3'] }),
});
// ── Sync helpers (keep ref + state in lockstep) ──────────────────────────
/** Sync helpers (keep ref + state in lockstep) */
const syncWebPlayer = v => {
webPlayerRef.current = v;
setWebPlayer(v);
@@ -69,7 +78,8 @@ export const GameProvider = ({ children }) => {
setBlue(n);
};
// ── Overlay ───────────────────────────────────────────────────────────────
/** Overlay */
const showOverlay = (title, sub) => {
setOverlay(true);
setOverlayTitle(title);
@@ -78,7 +88,8 @@ export const GameProvider = ({ children }) => {
const hideOverlay = () => setOverlay(false);
// ── Cell helpers ──────────────────────────────────────────────────────────
/** Cell helpers */
const applyRevealedCell = (cell, player, isMainCell = false) => {
const { row, col, value } = cell;
setCells(prev => {
@@ -105,7 +116,8 @@ export const GameProvider = ({ children }) => {
});
};
// ── Game logic ────────────────────────────────────────────────────────────
/** Game logic */
const changePlayer = () => {
const wasColor = activePlayerRef.current ? 'blue' : 'red';
const nextColor = activePlayerRef.current ? 'red' : 'blue';