online multiplayer chess game (note server currently down)
Diffstat (limited to 'ui/menus/sidebarright/undobutton.gd')
-rw-r--r--ui/menus/sidebarright/undobutton.gd10
1 files changed, 9 insertions, 1 deletions
diff --git a/ui/menus/sidebarright/undobutton.gd b/ui/menus/sidebarright/undobutton.gd
index 5572135..dc44100 100644
--- a/ui/menus/sidebarright/undobutton.gd
+++ b/ui/menus/sidebarright/undobutton.gd
@@ -13,7 +13,15 @@ func _ready() -> void:
func _pressed() -> void:
if Globals.spectating:
return
- if waiting_on_answer:
+ if Globals.local:
+ var two_undos = true if Globals.grid.chess.turn == Globals.grid.team else false
+ var completed_moves = Globals.grid.chess.history().size()
+ if completed_moves == 0 or (two_undos && completed_moves == 1):
+ status.set_text("No moves to undo!")
+ return
+ Globals.local.undo(two_undos)
+
+ elif waiting_on_answer:
_confirmed(true)
else:
var two_undos = true if Globals.grid.chess.turn == Globals.grid.team else false