aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/main.c b/src/main.c
index f9d35b8..4f60ba1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -15,22 +15,30 @@ int main() {
WINDOW* board_win = create_framed_window("Board", BOARD_ROW_UNITS + 2, BOARD_ROW_UNITS + 2, 0, 0);
WINDOW* messages_win = create_framed_window("Log", BOARD_ROW_UNITS + 2, 80, 0, BOARD_ROW_UNITS + 3);
+ scrollok(messages_win, 1);
- int meeple_map[MAX_STRUCTURES * PLAYERS];
BoardUnit board[BOARD_UNITS];
- initialize_board(board);
+ int available_meeples[PLAYERS];
+ int meeple_map[MAX_STRUCTURES * PLAYERS];
+ Tile tile;
- Tile tile = { "FRCR", 'R', 0 };
- place_tile(tile, translate_coordinate(BOARD_WIDTH * BOARD_WIDTH / 2), board, 1);
+ initialize_board(board);
+ initialize_available_meeples(available_meeples);
+ place_tile((Tile){ "FRCR", 'R', 0 }, translate_coordinate(BOARD_WIDTH * BOARD_WIDTH / 2), board, 1);
/* main loop */
char input_key;
for (int move = 0; ; move++) {
+ int player = (move % PLAYERS) + 1;
/* board */
refresh_structure_groups(board);
refresh_meeple_map(board, meeple_map);
draw_board(board, meeple_map, board_win);
+ wattron(messages_win, get_player_color(player));
+ wprintw(messages_win, "Move %i, (player #%i, %i meeples available)\n", move, player, available_meeples[player - 1]);
+ wrefresh(messages_win);
+
/* tile placement */
tile = TILESET[rand() % 19];
int position = 0;
@@ -79,12 +87,12 @@ int main() {
else if (input_key == 'k') meeple_index -= BOARD_ROW_UNITS;
else if (input_key != 10) meeple_index = -1;
- if (meeple_index >= 0) {
- int meeple = (move % PLAYERS) + 1;
- if (is_allowed_meeple(meeple, meeple_index, board, meeple_map)) {
- board[meeple_index].meeple = meeple;
- wprintw(messages_win, "Placed meeple #%i at index %i\n", meeple, meeple_index);
- } else wprintw(messages_win, "Could not place meeple #%i at index %i\n", meeple, meeple_index);
+ if (meeple_index >= 0 && available_meeples[player - 1] > 0) {
+ if (is_allowed_meeple(player, meeple_index, board, meeple_map)) {
+ board[meeple_index].meeple = player;
+ available_meeples[player - 1]--;
+ wprintw(messages_win, "Placed meeple at %c\n", board[meeple_index].feature);
+ } else wprintw(messages_win, "Could not place meeple at %c\n", board[meeple_index].feature);
}
wrefresh(messages_win);