lijim / monks-and-mages

Monks and Mages is a TCG-game built on React and socket.io
https://www.monksandmages.com
MIT License
17 stars 0 forks source link

Fix: Gracefully handle abandons in multiplayer / improve "win state" logic #409

Closed lijim closed 1 year ago

lijim commented 1 year ago

Our logic for detecting whether players won was previously very 2-player centric, which caused a number of bugs related to players leaving or losing the game in multiplayer.

Abandons

If a player abandoned a 3 player game, but was the active player, it would cause a state where neither of the remaining players could do anything (like mulligan, play the game, etc.) - see the state below:

https://user-images.githubusercontent.com/1839462/222680275-6a97c948-a012-4078-bd17-3556f5cddf4c.mov

We've fixed it so that now, if a player abandons the game, the game continues playing on until there is a winner:

https://user-images.githubusercontent.com/1839462/222678250-61529f68-df73-4516-b456-6937c048bd87.mov

Closes: #256

Self Damage / effect resolution

Any effect that causes the game to check a win state (e.g. drawing the last card in a deck, dealing damage to a player via a spell)

We've also added code that makes it so that if both players have no cards in the deck left, the last remaining player should win (as everyone else would draw out) on the passTurn function. This is covered under tests in resolveEffect.

Closes: #213