diff options
author | eug-vs <eugene@eug-vs.xyz> | 2022-03-31 21:03:38 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2022-03-31 21:03:38 +0300 |
commit | be2885fc3eb77ec33c5afe10a741ff23a21b0b5d (patch) | |
tree | f4be67d960d5f9322b3b536ab5268fbaf05d9c8c /src/main.c | |
parent | 6f4ac9571a0a6df9ec607e5a9a9b8d3e5f7bbc96 (diff) | |
download | carcassonne-engine-c-be2885fc3eb77ec33c5afe10a741ff23a21b0b5d.tar.gz |
refactor: use struct for Tile
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -46,12 +46,14 @@ int main() { char structures[BOARD_BYTES]; initialize_board(board); - place_tile("RFRCR", translate_coordinate(24), board, 1); + + Tile tile = { "FRCR", 'R' }; + place_tile(tile, translate_coordinate(24), board, 1); /* main loop */ - char tile[5]; char position[3]; while (1) { + /* prepare */ initialize_board(structures); create_structure_mask(board, structures); @@ -67,9 +69,9 @@ int main() { box(input_box, 0, 0); mvwaddstr(input_box, 0, 0, "Enter tile:"); wrefresh(input_box); - wgetstr(input_win, tile); + wgetstr(input_win, tile.edges); wclear(input_win); - if (tile[0] == 'q') break; + if (tile.edges[0] == 'q') break; box(input_box, 0, 0); mvwaddstr(input_box, 0, 0, "Enter position:"); @@ -77,8 +79,8 @@ int main() { wgetstr(input_win, position); int result = place_tile(tile, translate_coordinate(atoi(position)), board, 0); - if (result) wprintw(messages_win, "Placed tile %s at position %i\n", tile, atoi(position)); - else wprintw(messages_win, "Could not place tile %s at position %i\n", tile, atoi(position)); + if (result) wprintw(messages_win, "Placed tile %s (%c) at position %i\n", tile.edges, tile.center, atoi(position)); + else wprintw(messages_win, "Could not place tile %s (%c) at position %i\n", tile.edges, tile.center, atoi(position)); wrefresh(messages_win); } |