mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-15 02:54:09 -04:00
Extract a function or class to step away from God Object.
See: * https://en.wikipedia.org/wiki/God_object * https://www.c-sharpcorner.com/article/god-object-a-code-smell/ . This is Refactoring / code cleanup. See: * https://refactoring.com/catalog/extractMethod.html * https://en.wikipedia.org/wiki/Code_refactoring * https://www.refactoring.com/ * https://www.joelonsoftware.com/2002/01/23/rub-a-dub-dub/ Some small optimisations may have slipped in as well.
This commit is contained in:
parent
78c7e333c4
commit
bcaa95660b
1 changed files with 12 additions and 8 deletions
|
@ -167,6 +167,16 @@ def _updateStatus_process_key_val(tb, sb, k, v):
|
||||||
raise AttributeError(k)
|
raise AttributeError(k)
|
||||||
|
|
||||||
|
|
||||||
|
def _stats__is_perfect(stats):
|
||||||
|
"""docstring for _stats__is_perfect"""
|
||||||
|
return (stats.undo_moves == 0 and
|
||||||
|
stats.goto_bookmark_moves == 0 and
|
||||||
|
# stats.quickplay_moves == 0 and
|
||||||
|
stats.highlight_piles == 0 and
|
||||||
|
stats.highlight_cards == 0 and
|
||||||
|
stats.shuffle_moves == 0)
|
||||||
|
|
||||||
|
|
||||||
class Game(object):
|
class Game(object):
|
||||||
# for self.gstats.updated
|
# for self.gstats.updated
|
||||||
U_PLAY = 0
|
U_PLAY = 0
|
||||||
|
@ -1813,7 +1823,7 @@ class Game(object):
|
||||||
#
|
#
|
||||||
|
|
||||||
# game changed - i.e. should we ask the player to discard the game
|
# game changed - i.e. should we ask the player to discard the game
|
||||||
def changed(self, restart=0):
|
def changed(self, restart=False):
|
||||||
if self.gstats.updated < 0:
|
if self.gstats.updated < 0:
|
||||||
return 0 # already won or lost
|
return 0 # already won or lost
|
||||||
if self.gstats.loaded > 0:
|
if self.gstats.loaded > 0:
|
||||||
|
@ -1832,13 +1842,7 @@ class Game(object):
|
||||||
if not won or self.stats.hints > 0 or self.stats.demo_moves > 0:
|
if not won or self.stats.hints > 0 or self.stats.demo_moves > 0:
|
||||||
# sorry, you lose
|
# sorry, you lose
|
||||||
return won, 0, self.U_LOST
|
return won, 0, self.U_LOST
|
||||||
if (self.stats.undo_moves == 0 and
|
if _stats__is_perfect(self.stats):
|
||||||
self.stats.goto_bookmark_moves == 0 and
|
|
||||||
# self.stats.quickplay_moves == 0 and
|
|
||||||
self.stats.highlight_piles == 0 and
|
|
||||||
self.stats.highlight_cards == 0 and
|
|
||||||
self.stats.shuffle_moves == 0):
|
|
||||||
# perfect !
|
|
||||||
return won, 2, self.U_PERFECT
|
return won, 2, self.U_PERFECT
|
||||||
return won, 1, self.U_WON
|
return won, 1, self.U_WON
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue