1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

FIxed demo and stuck indicator getting stuck too early in Hit or Miss.

This commit is contained in:
Joe R 2022-07-28 16:56:23 -04:00
parent b5a305340d
commit ed811016de
2 changed files with 10 additions and 2 deletions

View file

@ -1110,7 +1110,7 @@ class Game(object):
def leaveState(self, old_state): def leaveState(self, old_state):
self.moves.state = old_state self.moves.state = old_state
def getSnapshot(self): def getSnapshotHash(self):
# generate hash (unique string) of current move # generate hash (unique string) of current move
sn = [] sn = []
for stack in self.allstacks: for stack in self.allstacks:
@ -1119,8 +1119,11 @@ class Game(object):
s.append('%d%03d%d' % (card.suit, card.rank, card.face_up)) s.append('%d%03d%d' % (card.suit, card.rank, card.face_up))
sn.append(''.join(s)) sn.append(''.join(s))
sn = '-'.join(sn) sn = '-'.join(sn)
return sn
def getSnapshot(self):
# optimisation # optimisation
sn = hash(sn) sn = hash(self.getSnapshotHash())
return sn return sn
def createSnGroups(self): def createSnGroups(self):

View file

@ -154,6 +154,11 @@ class HitOrMiss(Game):
# save vars (for undo/redo) # save vars (for undo/redo)
return [self.rank, self.deadDeals] return [self.rank, self.deadDeals]
def getSnapshotHash(self):
# Takes the chosen rank into account when determining
# if the game is stuck.
return Game.getSnapshotHash(self) + str(self.rank)
# register the game # register the game
registerGame(GameInfo(774, HitOrMiss, "Hit or Miss", registerGame(GameInfo(774, HitOrMiss, "Hit or Miss",