mirror of
https://github.com/HexCardGames/HexDeck.git
synced 2025-09-05 03:08:39 +02:00
fix(backend): remove card from player before calling PlayCard
This commit is contained in:
@ -248,7 +248,7 @@ func onPlayerJoin(client *socketio.Socket, room *types.Room, player *types.Playe
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
card := player.Cards[*updatePlayerRequest.CardIndex]
|
card := player.Cards[*updatePlayerRequest.CardIndex]
|
||||||
if !room.CardDeck.PlayCard(card) {
|
if !room.CardDeck.CanPlay(card) {
|
||||||
client.Emit("Status", types.S2C_Status{
|
client.Emit("Status", types.S2C_Status{
|
||||||
IsError: true,
|
IsError: true,
|
||||||
StatusCode: "card_not_playable",
|
StatusCode: "card_not_playable",
|
||||||
@ -257,6 +257,9 @@ func onPlayerJoin(client *socketio.Socket, room *types.Room, player *types.Playe
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
player.Cards = append(player.Cards[:*updatePlayerRequest.CardIndex], player.Cards[*updatePlayerRequest.CardIndex+1:]...)
|
player.Cards = append(player.Cards[:*updatePlayerRequest.CardIndex], player.Cards[*updatePlayerRequest.CardIndex+1:]...)
|
||||||
|
if !room.CardDeck.PlayCard(card) {
|
||||||
|
slog.Error("Cannot play card after checking", "roomId", room.RoomId.Hex(), "playerId", player.PlayerId.Hex())
|
||||||
|
}
|
||||||
game.OnPlayCard(room, player, *updatePlayerRequest.CardIndex, card)
|
game.OnPlayCard(room, player, *updatePlayerRequest.CardIndex, card)
|
||||||
|
|
||||||
if len(player.Cards) == 0 {
|
if len(player.Cards) == 0 {
|
||||||
|
Reference in New Issue
Block a user