]> git.cworth.org Git - ttt/blobdiff - kub/kub.c
Fixed kub to print deck better(still not perfect)
[ttt] / kub / kub.c
index 989277e30eccf1b1d722ea7b56385d1089f3efd2..f3126f5ff87d18fcf75bc0a980672c30f5b8fff0 100755 (executable)
--- 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;