]> git.cworth.org Git - kub/commitdiff
Kub compiles with no errors but still plenty of bugs
authorKevin Worth <kevin@theworths.org>
Sat, 14 Jan 2006 18:50:49 +0000 (10:50 -0800)
committerCarl Worth <carl@theworths.org>
Sat, 27 Jan 2007 14:30:49 +0000 (06:30 -0800)
kub.c

diff --git a/kub.c b/kub.c
index 3afca0006486b8c1636e3e6630f3c793ffef17e8..7f4b5ad1fd26c0f86329ee6e653178d53d48bd3b 100644 (file)
--- a/kub.c
+++ b/kub.c
@@ -18,10 +18,10 @@ typedef struct deck {
     int num_cards;
 } deck_t;
 
-#define CARD_GROUP_MAX_CARDS 14
+#define CARD_GROUP_MAX_CARDS DECK_MAX_CARDS
 
 typedef struct card_group {
-    card_t cards[HAND_MAX_CARDS];
+    card_t cards[CARD_GROUP_MAX_CARDS];
     int num_cards;
 } card_group_t;
 
@@ -30,7 +30,7 @@ typedef struct card_group {
 typedef struct board {
     card_group_t groups[BOARD_MAX_CARD_GROUPS];
     int num_groups;
-} board_t
+} board_t;
 
 typedef struct player {
     card_group_t hand;
@@ -45,17 +45,17 @@ typedef struct game {
     deck_t deck;
 } game_t;
 
-void card_print(card_t card)
+static void card_print(card_t card)
 {
     printf("%6s %2d\n", colors[card.color], card.number + 1);
 }
 
-void card_group_init(card_group_t *card_group)
+static void card_group_init(card_group_t *card_group)
 {
     card_group->num_cards = 0;
 }
 
-void board_init(board_t *board)
+static void board_init(board_t *board)
 {
     int i;
     board->num_groups = 0;
@@ -66,36 +66,20 @@ void board_init(board_t *board)
     }
 }
 
-void player_init(player_t *player)
+static void player_init(player_t *player)
 {
     card_group_init(&player->hand);
 }
 
-void game_init(game_t *game)
+static int card_group_is_set(card_group_t *card_group)
 {
     int i;
-    game->num_players = 0
-       
-       for (i = 0; i < GAME_MAX_PLAYERS; ++i)
-       {
-           player_init(&game->players[i]);
-           game->num_players += 1;
-       }
+    color_t seen_color[card_group->num_cards];
     
-    board_init(&game->board);
-    deck_init(&game->deck);
-    deck_shuffle(&game->deck);
-}
-
-int card_group_is_set(card_group_t *card_group)
-{
-    int i, j;
-    color_t seen_color[card_group->num_cards]
-       
-       if (card_group->num_cards > 4 || card_group->num_cards < 3)
-       {
-           return 0;
-       }
+    if (card_group->num_cards > 4 || card_group->num_cards < 3)
+    {
+       return 0;
+    }
     for (i = 0; i < card_group->num_cards - 1; ++i) 
     {
        if (card_group->cards[i].number != card_group->cards[i + 1].number)
@@ -106,14 +90,14 @@ 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)
     {
-       color_t color;
        
        seen_color[card_group->cards[i].color]++;
     }
     return 1;
 }
 
-void deck_deal(deck_t *deck)
+#if 0
+static void deck_deal(deck_t *deck)
 {
     card_t temp;
     int rand_card;
@@ -126,9 +110,9 @@ void deck_deal(deck_t *deck)
        deck->cards[last] = temp;
     }
 }
+#endif
 
-
-void deck_init(deck_t *deck)
+static void deck_init(deck_t *deck)
 {
     int h, i, j;  
     deck->num_cards = 0;
@@ -146,7 +130,7 @@ void deck_init(deck_t *deck)
     }
 } 
 
-void deck_shuffle(deck_t *deck)
+static void deck_shuffle(deck_t *deck)
 {
     card_t temp;
     int rand_card;
@@ -160,7 +144,7 @@ void deck_shuffle(deck_t *deck)
     }
 }
 
-void deck_print(deck_t *deck)
+static void deck_print(deck_t *deck)
 {
     int h, i, j;  
     for (h = 0; h <= 1; ++h)
@@ -175,13 +159,26 @@ void deck_print(deck_t *deck)
     }
 }
 
-int main()
+static void game_init(game_t *game)
 {
-#define MAX_PLAYERS 4
-#define HANDSIZE 14
-#define PLAYERS 4
+    int i;
+    game->num_players = 0;
     
+    for (i = 0; i < GAME_MAX_PLAYERS; ++i)
+    {
+       player_init(&game->players[i]);
+       game->num_players += 1;
+    }
+    
+    board_init(&game->board);
+    deck_init(&game->deck);
+    deck_shuffle(&game->deck);
+}
+
+int main(void)
+{
     deck_t deck;
+    game_t game;
     
     srand(time(NULL));
     
@@ -190,3 +187,4 @@ int main()
     
     return 0;
     
+}