aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2022-03-31 21:03:38 +0300
committereug-vs <eugene@eug-vs.xyz>2022-03-31 21:03:38 +0300
commitbe2885fc3eb77ec33c5afe10a741ff23a21b0b5d (patch)
treef4be67d960d5f9322b3b536ab5268fbaf05d9c8c /src/main.c
parent6f4ac9571a0a6df9ec607e5a9a9b8d3e5f7bbc96 (diff)
downloadcarcassonne-engine-c-be2885fc3eb77ec33c5afe10a741ff23a21b0b5d.tar.gz
refactor: use struct for Tile
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/main.c b/src/main.c
index 70aaec7..fff4b78 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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);
}