From 3acd882beb32370e6cd5a83f5997d29d16c4f621 Mon Sep 17 00:00:00 2001 From: Await-0x <146035814+Await-0x@users.noreply.github.com> Date: Fri, 21 Feb 2025 13:14:20 +0100 Subject: [PATCH] spectate game bug fixes --- client/src/components/battle/draggableCard.jsx | 4 +++- client/src/components/landing/startDraft.jsx | 4 +++- client/src/contexts/battleContext.jsx | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/client/src/components/battle/draggableCard.jsx b/client/src/components/battle/draggableCard.jsx index 8791b7f..3897bde 100644 --- a/client/src/components/battle/draggableCard.jsx +++ b/client/src/components/battle/draggableCard.jsx @@ -5,6 +5,7 @@ import { BattleContext } from '../../contexts/battleContext' import { CardSize, types } from '../../helpers/cards' import SmallCard from '../smallCard' import { useEffect } from 'react' +import { GameContext } from '../../contexts/gameContext' function DraggableCard(props) { const { values, dragEnd } = props @@ -18,6 +19,7 @@ function DraggableCard(props) { const controls = useAnimationControls() const ref = useRef() + const game = useContext(GameContext) const battle = useContext(BattleContext) const playable = battle.utils.getCardCost(values.card) <= battle.state.values.heroEnergy @@ -31,7 +33,7 @@ function DraggableCard(props) { document.removeEventListener('mouseup', mouseUpHandler); event.preventDefault(); - if (event.button !== 0 || event.pageY > play_threshold) { + if (event.button !== 0 || event.pageY > play_threshold || game.values.replay) { returnCard(event) return } diff --git a/client/src/components/landing/startDraft.jsx b/client/src/components/landing/startDraft.jsx index 461062a..90968a8 100644 --- a/client/src/components/landing/startDraft.jsx +++ b/client/src/components/landing/startDraft.jsx @@ -9,7 +9,7 @@ import logo from '../../assets/images/logo.svg' import { BattleContext } from '../../contexts/battleContext' import { DojoContext } from '../../contexts/dojoContext' import { DraftContext } from '../../contexts/draftContext' -import { GameContext } from '../../contexts/gameContext' +import { GAME_STATES, GameContext } from '../../contexts/gameContext' import { useReplay } from '../../contexts/replayContext' import { useTournament } from '../../contexts/tournamentContext' import { generateMapNodes } from '../../helpers/map' @@ -70,6 +70,8 @@ function StartDraft() { try { let data = await getActiveGame(game.id) + data.state = GAME_STATES[data.state] + let settings = await getSettings(game.settingsId) gameState.setGameSettings(settings) diff --git a/client/src/contexts/battleContext.jsx b/client/src/contexts/battleContext.jsx index 7807112..a9cbec6 100644 --- a/client/src/contexts/battleContext.jsx +++ b/client/src/contexts/battleContext.jsx @@ -153,6 +153,10 @@ export const BattleProvider = ({ children }) => { } const endTurn = async () => { + if (game.values.replay) { + return + } + await submitBattleActions() if (gameEffects.heroCardHeal) {