chg: usr: add share button to the overlay when the game ends #4
This commit is contained in:
@@ -41,6 +41,8 @@ export const GameProvider = ({ children }) => {
|
||||
connectionLost, setConnectionLost,
|
||||
} = useGameState();
|
||||
|
||||
const [gameUuid, setGameUuid] = React.useState(null);
|
||||
|
||||
const sounds = useRef({
|
||||
click: new Howl({ src: ['/sound/click.mp3'] }),
|
||||
bomb: new Howl({ src: ['/sound/bomb.mp3'] }),
|
||||
@@ -202,8 +204,11 @@ export const GameProvider = ({ children }) => {
|
||||
}
|
||||
};
|
||||
|
||||
const resignProcess = color => {
|
||||
const resignProcess = (color, uuid = null) => {
|
||||
const wp = webPlayerRef.current;
|
||||
if (uuid) {
|
||||
setGameUuid(uuid);
|
||||
}
|
||||
showOverlay(
|
||||
color === wp ? 'You have been give up' : 'Your opponent has been resigned',
|
||||
color === wp ? 'You LOSE!' : 'You WIN!',
|
||||
@@ -225,9 +230,9 @@ export const GameProvider = ({ children }) => {
|
||||
value={{
|
||||
// State (for rendering)
|
||||
webPlayer, activePlayer, overlay, overlayTitle, overlaySubTitle,
|
||||
mines, bombSelected, foundMines, red, blue, cells, gridReady, connectionLost,
|
||||
mines, bombSelected, foundMines, red, blue, cells, gridReady, connectionLost, gameUuid,
|
||||
// Setters needed by useServerComm
|
||||
setCells, setGridReady,
|
||||
setCells, setGridReady, setGameUuid,
|
||||
// Refs (needed by useServerComm for async-safe reads)
|
||||
webPlayerRef, activePlayerRef, bombSelectedRef, connectionLostRef, endRef,
|
||||
// Sync helpers
|
||||
|
||||
Reference in New Issue
Block a user