From 23843dc2a8b90fcf896e9fca2efe5e436dbeff50 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Wed, 14 Aug 2019 17:59:27 +0300 Subject: [PATCH] Extract a common class/struct. This is Refactoring / code cleanup. See: * https://en.wikipedia.org/wiki/God_object * https://en.wikipedia.org/wiki/Extract_class * 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. --- pysollib/game/__init__.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pysollib/game/__init__.py b/pysollib/game/__init__.py index 812516fb..39db68b7 100644 --- a/pysollib/game/__init__.py +++ b/pysollib/game/__init__.py @@ -360,6 +360,13 @@ class GameTexts(NewStruct): list = attr.ib(factory=list) +@attr.s +class GameHints(NewStruct): + list = attr.ib(default=None) + index = attr.ib(default=-1) + level = attr.ib(default=-1) + + class Game(object): # for self.gstats.updated U_PLAY = 0 @@ -604,11 +611,7 @@ class Game(object): self.filename = "" self.demo = None self.solver = None - self.hints = Struct( - list=None, # list of hints for the current move - index=-1, - level=-1, - ) + self.hints = GameHints() self.saveinfo = Struct( # needed for saving a game stack_caps=[], )