int y;
int selected;
int owned;
+ int in_hand;//Draw the tile in the hand, or elsewhere on the board?
} tile_t;
#define DECK_MAX_TILES 104
int num_tiles;
} tile_group_t;
-#define BOARD_MAX_TILE_GROUPS (DECK_MAX_TILES / 3)
+#define BOARD_MAX_TILE_GROUPS DECK_MAX_TILES
typedef struct board {
tile_group_t groups[BOARD_MAX_TILE_GROUPS];
tile->y = 0;
tile->selected = 0;
tile->owned = 0;
+ tile->in_hand = 1;
}
static void tile_set_x_y (tile_t *tile, int x, int y)
int num_tiles = game->players[player].hand.num_tiles;
for (i = 0; i < num_tiles; i++)
{
- tile_set_x_y(&game->players[player].hand.tiles[i],
- ((width/num_tiles)) * i, (height - TILE_HEIGHT - 6) );
+ if (game->players[player].hand.tiles[i].in_hand)
+ tile_set_x_y(&game->players[player].hand.tiles[i],
+ ((width/num_tiles)) * i, (height - TILE_HEIGHT - 6) );
}
for (i = 0; i < game->players[player].hand.num_tiles; i++)
{
- tile_draw(game, &game->players[player].hand.tiles[i], cr, region);
+// if (game->players[player].hand.tiles[i].in_hand)
+ tile_draw(game, &game->players[player].hand.tiles[i], cr, region);
}
}
{
game->state.board = game->board;
game->state.deck = game->deck;
- //game->state.players = game->players;
+ int i;
+ for (i=0; i < game->num_players; i++)
+ game->state.players[i] = game->players[i];
}
static void restore_state(game_t *game)
{
game->board = game->state.board;
game->deck = game->state.deck;
- //game->players = game->state.players;
+ int i;
+ for (i=0; i < game->num_players; i++)
+ game->players[i] = game->state.players[i];
}
static void game_init(game_t *game)
gtk_widget_queue_draw(widget);
}
}
+ else if (event->keyval == 115) //HIT "s"
+ save_state(game);
else if (event->keyval == 65293) //HIT ENTER
{
save_state(game);
{
int i, tile_x, tile_y;
tile_t *curr_tile;
- player_t *curr_player = &game->players[0];
+ player_t *curr_player = &game->players[game->current_player];
/*Handle tiles in player's hand */
for (i = 0; i < curr_player->hand.num_tiles; i++)
{
game->select_mode = 0;
game->current_tile = curr_tile;
+ curr_tile->in_hand = 0;
if (!curr_tile->selected)
curr_tile->selected = 1;
else