Skip to content

Commit

Permalink
config file option for printing tiles/time info in status message
Browse files Browse the repository at this point in the history
  • Loading branch information
privong authored and George C. Privon committed Nov 20, 2018
1 parent bc7a0f3 commit 39c3ce1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions CarcassonneScore.conf.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
[CarcassonneScore]
DBNAME = CarcassonneScore.db

[Status]
SHOWTILES = true
SHOWTIME = true
15 changes: 11 additions & 4 deletions cgame.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ def loadConfig(self, cfile):
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):
"""
Expand Down Expand Up @@ -432,8 +437,8 @@ def runGame(self):
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)
Expand Down Expand Up @@ -512,9 +517,11 @@ def printStatus(self, tilestats=False, timestats=False, sort=False):

_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
Expand Down

0 comments on commit 39c3ce1

Please sign in to comment.