瀏覽代碼

config file option for printing tiles/time info in status message

George C. Privon 7 年之前
父節點
當前提交
39c3ce1a85
共有 3 個文件被更改,包括 16 次插入4 次删除
  1. 1 0
      CHANGELOG.md
  2. 4 0
      CarcassonneScore.conf.example
  3. 11 4
      cgame.py

+ 1 - 0
CHANGELOG.md

@@ -10,6 +10,7 @@
 * Reorder game initilization so that most of the info can be entered before the player order is determined.
 * Announce gameID and location at the start.
 * Status printout now shows time elapsed since end of previous turn.
+* In the status message, showing the number of tiles played/remaining and the time elapsed since the end of the previous turn is now controlled via options in the configuration file.
 
 #### Bug fixes
 

+ 4 - 0
CarcassonneScore.conf.example

@@ -1,2 +1,6 @@
 [CarcassonneScore]
 DBNAME = CarcassonneScore.db
+
+[Status]
+SHOWTILES = true
+SHOWTIME = true

+ 11 - 4
cgame.py

@@ -65,6 +65,11 @@ class cgame:
         self.config = _configparser.RawConfigParser()
         self.config.read(cfile)
 
+        # set up a preferences dictionary
+        self.preferences = {}
+        self.preferences['SHOWTILES'] = self.config['Status'].getboolean('SHOWTILES')
+        self.preferences['SHOWTIME'] = self.config['Status'].getboolean('SHOWTIME')
+
 
     def showCommands(self):
         """
@@ -432,8 +437,8 @@ class cgame:
                 if self.state:
                     self.printStatus(tilestats=False)
                 else:
-                    self.printStatus(tilestats=True,
-                                     timestats=True)
+                    self.printStatus(tilestats=self.preferences['SHOWTILES'],
+                                     timestats=self.preferences['SHOWTIME'])
             elif _re.match('n', cmd, _re.IGNORECASE):
                 self.advanceTurn(builder=False,
                                  abbey=False)
@@ -512,9 +517,11 @@ class cgame:
 
             _sys.stdout.write('\t' + player[1]+ ': {0:1.0f}'.format(score) + '\n')
 
+        _sys.stdout.write('\n')
+
         if tilestats:
-            _sys.stdout.write("\n{0:1.0f} tiles played, {1:1.0f} remaining.\n\n".format(self.ntile,
-                                                                                        self.totaltiles - self.ntile))
+            _sys.stdout.write("{0:1.0f} tiles played, {1:1.0f} remaining.\n\n".format(self.ntile,
+                                                                                      self.totaltiles - self.ntile))
 
         if timestats:
             gamedt = _datetime.utcnow() - self.starttime