From b3f79c9df821b41e39f4eaf6ea473f470cf65836 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Mon, 30 Dec 2019 20:38:25 +0200 Subject: [PATCH] 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. --- pysollib/game/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pysollib/game/__init__.py b/pysollib/game/__init__.py index dc274c94..bd3c79ca 100644 --- a/pysollib/game/__init__.py +++ b/pysollib/game/__init__.py @@ -465,6 +465,12 @@ class GameGlobalSaveInfo(NewStruct): comment = attr.ib(default="") +# Needed for saving a game +@attr.s +class GameSaveInfo(NewStruct): + stack_caps = attr.ib(factory=list) + + class Game(object): # for self.gstats.updated U_PLAY = _GLOBAL_U_PLAY @@ -710,9 +716,7 @@ class Game(object): self.demo = None self.solver = None self.hints = GameHints() - self.saveinfo = Struct( # needed for saving a game - stack_caps=[], - ) + self.saveinfo = GameSaveInfo() self.loadinfo = GameLoadInfo() self.snapshots = [] self.failed_snapshots = []