@@ 590,18 590,21 @@ void game_main() {
"| SHIFT+Q .................. EXIT |\n"
"+------------------------------------------+\n";
+ const char backspace = 127;
+
while (1) {
render(game);
puts(controls);
char c;
+
switch (game.state) {
case CHOOSING_PIECE:
printf("Pick piece [a-c]: ");
c = getc(stdin);
switch (c) {
- case /* backspace */ 127: {
+ case backspace: {
struct Game t = game;
game = prev;
prev = t;
@@ 631,7 634,7 @@ void game_main() {
c = getc(stdin);
switch (c) {
- case /* backspace */ 127:
+ case backspace:
game.state = CHOOSING_PIECE;
continue;
@@ 648,13 651,13 @@ void game_main() {
game.state = CHOOSING_ROW;
break;
- case CHOOSING_ROW:
+ case CHOOSING_ROW: {
printf("Pick row [1-9]: ");
c = getc(stdin);
switch (c) {
- case /* backspace */ 127:
+ case backspace:
game.state = CHOOSING_COLUMN;
continue;
@@ 713,7 716,8 @@ void game_main() {
return;
}
- printf("\n%d\n", game.active_piece);
+ printf("\n%d\n", game.active_piece);
+ }
}
}