From c5315c8aac2b57c3e56cf40bfb356035db0be8c4 Mon Sep 17 00:00:00 2001 From: Daithi Hearn Date: Fri, 2 Feb 2024 00:27:03 +0100 Subject: [PATCH] fix: must follow on cold card --- pkg/game/game-utils.go | 2 +- pkg/game/game-utils_test.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/game/game-utils.go b/pkg/game/game-utils.go index 3eba370..65b58a0 100644 --- a/pkg/game/game-utils.go +++ b/pkg/game/game-utils.go @@ -252,7 +252,7 @@ func isFollowing(myCard CardName, myCards []CardName, currentHand Hand, suit Sui var mySuitedCards []Card for _, card := range myCards { - if mySuit == leadOut.Suit { + if card.Card().Suit == leadOut.Suit { mySuitedCards = append(mySuitedCards, card.Card()) } } diff --git a/pkg/game/game-utils_test.go b/pkg/game/game-utils_test.go index 74b9185..dd13f0f 100644 --- a/pkg/game/game-utils_test.go +++ b/pkg/game/game-utils_test.go @@ -349,6 +349,14 @@ func TestGameUtils_isFollowing(t *testing.T) { suit: Diamonds, expectedResult: true, }, + { + name: "Must follow a cold card", + myCard: JACK_HEARTS, + myCards: []CardName{JACK_HEARTS, FIVE_HEARTS, TWO_SPADES}, + currentHand: Hand{LeadOut: FIVE_SPADES}, + suit: Clubs, + expectedResult: false, + }, { name: "Following", myCard: THREE_CLUBS,