From 97a70ea882124e0fd0969bf26c29542a57439d48 Mon Sep 17 00:00:00 2001
From: Shlomi Fish <shlomif@shlomifish.org>
Date: Fri, 19 Feb 2016 19:19:18 +0200
Subject: [PATCH] More refactoring.

---
 pysollib/hint.py | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/pysollib/hint.py b/pysollib/hint.py
index 5ed4766f..b8e531b1 100644
--- a/pysollib/hint.py
+++ b/pysollib/hint.py
@@ -794,9 +794,18 @@ class FreeCellSolver_Hint(Base_Solver_Hint):
         game_type = self.game_type
         return ('preset' in game_type and game_type['preset'] == 'simple_simon')
 
+    def _addBoardLine(self, l):
+        self.board += l + '\n'
+        return
+
+    def _addPrefixLine(self, prefix, b):
+        if b:
+            self._addBoardLine(prefix + b)
+        return
+
     def calcBoardString(self):
         game = self.game
-        board = ''
+        self.board = ''
         is_simple_simon = self._isSimpleSimon()
         #
         #
@@ -804,15 +813,13 @@ class FreeCellSolver_Hint(Base_Solver_Hint):
         for s in game.s.foundations:
             if s.cards:
                 b += ' ' + self.card2str2(s.cards[0 if is_simple_simon else -1])
-        if b:
-            board += 'Founds:' + b + '\n'
-        #
+        self._addPrefixLine('Founds:', b)
+
         b = ''
         for s in game.s.reserves:
             b += ' ' + (self.card2str1(s.cards[-1]) if s.cards else '-')
-        if b:
-            board += 'FC:' + b + '\n'
-        #
+        self._addPrefixLine('FC:', b)
+
         for s in game.s.rows:
             b = ''
             for c in s.cards:
@@ -820,9 +827,9 @@ class FreeCellSolver_Hint(Base_Solver_Hint):
                 if not c.face_up:
                     cs = '<%s>' % cs
                 b += cs + ' '
-            board += b.strip() + '\n'
+            self._addBoardLine(b.strip())
 
-        return board
+        return self.board
 
 
     def computeHints(self):