From: Kevin Worth Date: Sat, 21 Jan 2006 07:38:14 +0000 (+0000) Subject: Completed _is_set and _is_run but still lacking debugging code for said functions X-Git-Url: https://git.cworth.org/git?p=ttt;a=commitdiff_plain;h=1867e42aa63255c78605b58d58db5a04c005fbfd Completed _is_set and _is_run but still lacking debugging code for said functions --- diff --git a/kub/kub.c b/kub/kub.c index f3126f5..955817c 100755 --- a/kub/kub.c +++ b/kub/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; }