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;
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;
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;
}
}
-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)
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;
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;
}
}
-void deck_shuffle(deck_t *deck)
+static void deck_shuffle(deck_t *deck)
{
card_t temp;
int rand_card;
}
}
-void deck_print(deck_t *deck)
+static void deck_print(deck_t *deck)
{
int h, i, j;
for (h = 0; h <= 1; ++h)
}
}
-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));
return 0;
+}