From e182ddd68f84c81c1d41faf73d93cfd6929a13aa Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Fri, 19 Feb 2016 18:58:16 +0200 Subject: [PATCH] Refactor pysollib/hint. Still a lot of ugliness showing but it's better than nothing. --- pysollib/hint.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/pysollib/hint.py b/pysollib/hint.py index 1a72796b..5ed4766f 100644 --- a/pysollib/hint.py +++ b/pysollib/hint.py @@ -790,30 +790,26 @@ class FreeCellSolver_Hint(Base_Solver_Hint): else: return False + def _isSimpleSimon(self): + game_type = self.game_type + return ('preset' in game_type and game_type['preset'] == 'simple_simon') + def calcBoardString(self): game = self.game - game_type = self.game_type board = '' + is_simple_simon = self._isSimpleSimon() # # b = '' for s in game.s.foundations: if s.cards: - if 'preset' in game_type and game_type['preset'] == 'simple_simon': - ss = self.card2str2(s.cards[0]) - else: - ss = self.card2str2(s.cards[-1]) - b += ' ' + ss + b += ' ' + self.card2str2(s.cards[0 if is_simple_simon else -1]) if b: board += 'Founds:' + b + '\n' # b = '' for s in game.s.reserves: - if s.cards: - cs = self.card2str1(s.cards[-1]) - b += ' ' + cs - else: - b += ' -' + b += ' ' + (self.card2str1(s.cards[-1]) if s.cards else '-') if b: board += 'FC:' + b + '\n' #