mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Fixed manual undo causing false stuck notifications.
This commit is contained in:
parent
1dd012d7d9
commit
3cd6b6ecb2
2 changed files with 25 additions and 1 deletions
|
@ -3029,6 +3029,19 @@ class Game(object):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
redo = 1
|
redo = 1
|
||||||
|
# try to detect an undo move for stuck-checking
|
||||||
|
undo = 0
|
||||||
|
if len(moves.history) > 0:
|
||||||
|
mylen, m = len(current), moves.history[moves.index - 1]
|
||||||
|
if mylen == len(m):
|
||||||
|
for i in range(mylen):
|
||||||
|
a1 = current[i]
|
||||||
|
a2 = m[i]
|
||||||
|
if a1.__class__ is not a2.__class__ or \
|
||||||
|
a1.cmpForUndo(a2) != 0:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
undo = 1
|
||||||
# add current move to history (which is a list of lists)
|
# add current move to history (which is a list of lists)
|
||||||
if redo:
|
if redo:
|
||||||
# print "detected redo:", current
|
# print "detected redo:", current
|
||||||
|
@ -3049,7 +3062,8 @@ class Game(object):
|
||||||
self.updateStatus(moves=(moves.index, self.stats.total_moves))
|
self.updateStatus(moves=(moves.index, self.stats.total_moves))
|
||||||
self.updateMenus()
|
self.updateMenus()
|
||||||
self.updatePlayTime(do_after=0)
|
self.updatePlayTime(do_after=0)
|
||||||
self.updateStuck()
|
if not undo:
|
||||||
|
self.updateStuck()
|
||||||
reset_solver_dialog()
|
reset_solver_dialog()
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -58,6 +58,11 @@ class AtomicMove:
|
||||||
def cmpForRedo(self, other):
|
def cmpForRedo(self, other):
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
|
# Custom comparison for detecting manual undoing.
|
||||||
|
# Override only for move types where this is possible.
|
||||||
|
def cmpForUndo(self, other):
|
||||||
|
return -1
|
||||||
|
|
||||||
|
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
# * Move the top N cards from a stack to another stack.
|
# * Move the top N cards from a stack to another stack.
|
||||||
|
@ -107,6 +112,11 @@ class AMoveMove(AtomicMove):
|
||||||
cmp(self.from_stack_id, other.from_stack_id) or
|
cmp(self.from_stack_id, other.from_stack_id) or
|
||||||
cmp(self.to_stack_id, other.to_stack_id))
|
cmp(self.to_stack_id, other.to_stack_id))
|
||||||
|
|
||||||
|
def cmpForUndo(self, other):
|
||||||
|
return (cmp(self.ncards, other.ncards) or
|
||||||
|
cmp(self.from_stack_id, other.to_stack_id) or
|
||||||
|
cmp(self.to_stack_id, other.from_stack_id))
|
||||||
|
|
||||||
|
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
# * Flip the top card of a stack.
|
# * Flip the top card of a stack.
|
||||||
|
|
Loading…
Add table
Reference in a new issue