summaryrefslogtreecommitdiff
path: root/extra/cluedo_test.go
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2025-02-26 16:02:48 +0300
committerGrail Finder <wohilas@gmail.com>2025-02-26 16:02:48 +0300
commit49409f5d94437fbd8e5ca059c6c71998408c8efa (patch)
tree7ed462468c83a2510654f2e43ecf9bf013667563 /extra/cluedo_test.go
parent97a1fc507e69b9594d44023f7a85b479b0c34285 (diff)
Feat: add extra/cluedo [WIP]
Diffstat (limited to 'extra/cluedo_test.go')
-rw-r--r--extra/cluedo_test.go50
1 files changed, 50 insertions, 0 deletions
diff --git a/extra/cluedo_test.go b/extra/cluedo_test.go
new file mode 100644
index 0000000..e7a53b1
--- /dev/null
+++ b/extra/cluedo_test.go
@@ -0,0 +1,50 @@
+package extra
+
+import (
+ "testing"
+)
+
+func TestPrepCards(t *testing.T) {
+ // Run the function to get the murder combination and player cards
+ roundInfo := CluedoPrepCards([]string{"{{user}}", "{{char}}", "{{char2}}"})
+ // Create a map to track all distributed cards
+ distributedCards := make(map[string]bool)
+ // Check that the murder combination cards are not distributed to players
+ murderCards := []string{roundInfo.Answer.Murderer, roundInfo.Answer.Weapon, roundInfo.Answer.Room}
+ for _, card := range murderCards {
+ if distributedCards[card] {
+ t.Errorf("Murder card %s was distributed to a player", card)
+ }
+ }
+ // Check each player's cards
+ for player, cards := range roundInfo.PlayersCards {
+ for _, card := range cards {
+ // Ensure the card is not part of the murder combination
+ for _, murderCard := range murderCards {
+ if card == murderCard {
+ t.Errorf("Player %s has a murder card: %s", player, card)
+ }
+ }
+ // Ensure the card is unique and not already distributed
+ if distributedCards[card] {
+ t.Errorf("Card %s is duplicated in player %s's hand", card, player)
+ }
+ distributedCards[card] = true
+ }
+ }
+ // Verify that all non-murder cards are distributed
+ allCards := append(append([]string{}, rooms...), weapons...)
+ allCards = append(allCards, people...)
+ for _, card := range allCards {
+ isMurderCard := false
+ for _, murderCard := range murderCards {
+ if card == murderCard {
+ isMurderCard = true
+ break
+ }
+ }
+ if !isMurderCard && !distributedCards[card] {
+ t.Errorf("Card %s was not distributed to any player", card)
+ }
+ }
+}