Skip to content

Commit

Permalink
spectate game bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Await-0x committed Feb 21, 2025
1 parent 403a345 commit 3acd882
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion client/src/components/battle/draggableCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
}
Expand Down
4 changes: 3 additions & 1 deletion client/src/components/landing/startDraft.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions client/src/contexts/battleContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ export const BattleProvider = ({ children }) => {
}

const endTurn = async () => {
if (game.values.replay) {
return
}

await submitBattleActions()

if (gameEffects.heroCardHeal) {
Expand Down

0 comments on commit 3acd882

Please sign in to comment.