diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 27 |
1 files changed, 22 insertions, 5 deletions
@@ -56,14 +56,10 @@ int main() { /* main loop */ char input_key; - while (1) { + for (int move = 0; ; move++) { /* board */ refresh_structure_groups(board); draw_board(board, board_win); - if (wgetch(board_win) == 'q') { - endwin(); - return 0; - } /* tile placement */ tile = tileset[rand() % 5]; @@ -90,11 +86,32 @@ int main() { else if (input_key == 'j') position += BOARD_WIDTH; else if (input_key == 'k') position -= BOARD_WIDTH; else if (input_key == 'r') rotate_tile(&tile, 3); + else if (input_key == 'q') { + endwin(); + return 0; + } } int result = place_tile(tile, translate_coordinate(position), board, 0); if (result) wprintw(messages_win, "Placed tile %s (%c) at position %i\n", tile.edges, tile.center, position); else wprintw(messages_win, "Could not place tile %s (%c) at position %i\n", tile.edges, tile.center, position); + + + /* meeple placement */ + input_key = wgetch(board_win); + int meeple_index = translate_coordinate(position); + + if (input_key == 'l') meeple_index += 1; + else if (input_key == 'h') meeple_index -= 1; + else if (input_key == 'j') meeple_index += BOARD_ROW_UNITS; + else if (input_key == 'k') meeple_index -= BOARD_ROW_UNITS; + else if (input_key != 10) meeple_index = -1; + + if (meeple_index >= 0) { + board[meeple_index].meeple = move % PLAYERS; + wprintw(messages_win, "Placed meeple #%i at index %i\n", move % PLAYERS, meeple_index); + } + wrefresh(messages_win); } |