So I have a chess game. I'm trying to implement a method where the user can undo their last move.
I created the appropriate action listener for the menu option. The action listener sets the game's undo boolean to true.
pseudocode for my game loop:
while (!game end)
{
if (undo)
{
undo the last move
continue;
}
prompt user to input next move
user inputs move into console
model, view are updated
}
This logic doesn't work. The only time the game loop will handle undo is after a user has inputted their next move. So.. basically it just undoes the move they just put in. I need it to be so that any time a user clicks undo move on the GUI, the game loop does the stuff in the if statement.
I have a feeling there is a smarter way to handle this.