]> git.cworth.org Git - kub/commitdiff
Completed _is_set and _is_run but still lacking debugging code for said functions
authorKevin Worth <kevin@theworths.org>
Sat, 21 Jan 2006 07:38:14 +0000 (23:38 -0800)
committerCarl Worth <carl@theworths.org>
Sat, 27 Jan 2007 14:32:10 +0000 (06:32 -0800)
kub.c

diff --git a/kub.c b/kub.c
index 099e8963a8dd60a258edbf0dbbc42028565e53a6..cb2b8d9dbb0f2c19ab9425b173856c9b23e9c319 100644 (file)
--- a/kub.c
+++ b/kub.c
@@ -71,6 +71,36 @@ static void player_init(player_t *player)
     card_group_init(&player->hand);
 }
 
+static int card_group_is_run(card_group_t *card_group)
+{
+    int i;
+    int lowest = 14, highest = 0;
+    if (card_group->num_cards > 13 || card_group->num_cards < 3)
+    {
+       return 0;
+    }
+    for (i = 0; i < card_group->num_cards - 1; ++i)
+    {
+       if (card_group->cards[i].color != card_group->cards[i + 1].color)
+       {
+           return 0;
+       }
+       if (card_group->cards[i].number > highest)
+       {
+           highest = card_group->cards[i].number;
+       }
+       if (card_group->cards[i].number < lowest)
+       {
+           lowest = card_group->cards[i].number;
+       }
+    }
+    if (highest - lowest = card_group->num_cards - 1)
+    {
+       return 1;
+    }
+}
+
+
 static int card_group_is_set(card_group_t *card_group)
 {
     int i;
@@ -90,8 +120,11 @@ static int card_group_is_set(card_group_t *card_group)
     seen_color[i] = card_group->cards[i].color;
     for (i = 0; i < card_group->num_cards; ++i)
     {
-       
        seen_color[card_group->cards[i].color]++;
+       if (seen_color[card_group->cards[i].color] > 1)
+       {
+           return 0;
+       }
     }
     return 1;
 }