From 7bbacfb97eab3f9182a0b16a09460aa7a6bc4224 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Wed, 14 Aug 2019 20:49:03 +0300 Subject: [PATCH] Extract a method or a function. 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 | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/pysollib/game/__init__.py b/pysollib/game/__init__.py index 3731f297..aa5a3eea 100644 --- a/pysollib/game/__init__.py +++ b/pysollib/game/__init__.py @@ -396,6 +396,16 @@ class GameStatsStruct(NewStruct): elapsed_time = attr.ib(default=0.0) pause_start_time = attr.ib(default=0.0) + def _reset_statistics(self): + """docstring for _reset_stats""" + self.undo_moves = 0 + self.redo_moves = 0 + self.player_moves = 0 + self.demo_moves = 0 + self.total_moves = 0 + self.quickplay_moves = 0 + self.goto_bookmark_moves = 0 + _GLOBAL_U_PLAY = 0 @@ -2756,14 +2766,7 @@ class Game(object): index=0, current=[], # atomic moves for the current move ) - # reset statistics - self.stats.undo_moves = 0 - self.stats.redo_moves = 0 - self.stats.player_moves = 0 - self.stats.demo_moves = 0 - self.stats.total_moves = 0 - self.stats.quickplay_moves = 0 - self.stats.goto_bookmark_moves = 0 + self.stats._reset_statistics() def __storeMove(self, am): if self.S_DEAL <= self.moves.state <= self.S_PLAY: