diff options
| author | Adam T. Carpenter <Commodore@chunkybluegiant> | 2025-04-28 19:05:31 -0400 |
|---|---|---|
| committer | Adam T. Carpenter <Commodore@chunkybluegiant> | 2025-04-28 19:05:31 -0400 |
| commit | a29cbeb61004d53a0afb1b7fe2339bf591a21007 (patch) | |
| tree | d0ad017d180f1a95fb769b6f4e72d0e74219acf9 /src/main.c | |
| parent | d770b616f4ee72e4ef5ab0e6b8bed205c7ac4429 (diff) | |
| download | ttt-c64-master.tar.xz ttt-c64-master.zip | |
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 17 |
1 files changed, 9 insertions, 8 deletions
@@ -96,14 +96,15 @@ void player_move(BOARD board) { char move_x = EMPTY; char move_y = EMPTY; - printf("Enter a move..."); - - move = cgetc() - '0' - 1; - // if move is not a number then bail - // if (move < 1 || move > 8) { invalid! } - move_x = move % 3; - move_y = move / 3; - // if move not already taken + do { + printf("\nEnter a valid move..."); + + move = cgetc() - '0' - 1; + printf("%d\n", move); + move_x = move % 3; + move_y = move / 3; + } while (0 <= move_x <= move_y <= 2 && board[move_y][move_x] != EMPTY); + board[move_y][move_x] = X; } |