diff --git a/backend/MemeBE/Models/Deck.cs b/backend/MemeBE/Models/Deck.cs index f97a8fd..063b218 100644 --- a/backend/MemeBE/Models/Deck.cs +++ b/backend/MemeBE/Models/Deck.cs @@ -27,6 +27,10 @@ private Queue PrepareDeckCards(List cards) return result; } + public int GetCount() + { + return deckCards.Count(); + } public Card? DrawCard() { return deckCards.Dequeue(); diff --git a/backend/MemeBE/Models/Room.cs b/backend/MemeBE/Models/Room.cs index d5945e6..853a0d3 100644 --- a/backend/MemeBE/Models/Room.cs +++ b/backend/MemeBE/Models/Room.cs @@ -52,7 +52,13 @@ public Result AddPlayer(Player player) public Result DrawCard(out Card cardDrawn) { + if (Deck.GetCount() < 1) + { + cardDrawn = null; + return Result.Fail("No more cards in deck"); + } cardDrawn = Deck.DrawCard(); + if (cardDrawn == null) { return Result.Fail("No more cards in deck"); diff --git a/backend/MemeBE/hubs/GameHub.cs b/backend/MemeBE/hubs/GameHub.cs index 5681aac..1075b77 100644 --- a/backend/MemeBE/hubs/GameHub.cs +++ b/backend/MemeBE/hubs/GameHub.cs @@ -209,6 +209,15 @@ public async Task EndTurn(Room room) await Clients.Client(room.ActivePlayer.ConnectionID).SendAsync("TurnEnd"); // await Clients.Group(room.RoomId) // .SendAsync("ReceiveServerRoomMessage", room.ActivePlayer.Nick + " - turn Ended"); + + foreach (var player in room.Players.Values) + { + if (player.LaughPoints > 14) + { + room.GameStarted = false; + } + } + if (room.GameStarted) {