From: Kevin Worth Date: Sun, 15 Jan 2006 07:50:42 +0000 (+0000) Subject: Fixed kub to print deck better(still not perfect) X-Git-Url: https://git.cworth.org/git?p=ttt;a=commitdiff_plain;h=75ca69e4854cfe8c575391bdc55b4a47d5295fd6 Fixed kub to print deck better(still not perfect) --- diff --git a/kub/kub.c b/kub/kub.c index 989277e..f3126f5 100755 --- a/kub/kub.c +++ b/kub/kub.c @@ -97,17 +97,20 @@ static int card_group_is_set(card_group_t *card_group) } #if 0 -static void deck_deal(deck_t *deck) +static void deck_deal(deck_t *deck, game_t *game) { card_t temp; int rand_card; - int i; - for (i = 0; i < Players ) + int i, j; + for (i = 0; i < PLAYERS; ++i) { - rand_card = ((last + 1.0) * rand()) / (RAND_MAX + 1.0); - temp = deck->cards[rand_card]; - deck->cards[rand_card] = deck->cards[last]; - deck->cards[last] = temp; + for (j = 0; j < 13; ++j) + { + rand_card = ((last + 1.0) * rand()) / (RAND_MAX + 1.0); + temp = deck->cards[rand_card]; + deck->cards[rand_card] = deck->cards[last]; + game->players[i]->hand->cards[j] = temp; + } } } #endif @@ -125,6 +128,7 @@ static void deck_init(deck_t *deck) deck->cards[j + (i * 13) + (h * 52)].color = i; deck->cards[j + (i * 13) + (h * 52)].number = j; deck->num_cards += 1; + printf ("There are %d tiles in the deck\n", deck->num_cards); } } } @@ -157,6 +161,7 @@ static void deck_print(deck_t *deck) } } } + printf ("There are %d tiles in the deck\n" , deck->num_cards); } static void game_init(game_t *game) @@ -177,13 +182,12 @@ static void game_init(game_t *game) int main(void) { - deck_t deck; game_t game; srand(time(NULL)); game_init(&game); - deck_print(&deck); + deck_print(&game.deck); return 0;