Procházet zdrojové kódy

print (all) player names when confirming scores

George C. Privon před 7 roky
rodič
revize
a045849cad
2 změnil soubory, kde provedl 14 přidání a 1 odebrání
  1. 2 0
      CHANGELOG.md
  2. 12 1
      cgame.py

+ 2 - 0
CHANGELOG.md

@@ -12,6 +12,7 @@
 * 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.
 * Add `requirements.txt` file.
+* Print the player's name when confirming a score entry.
 
 #### Bug fixes
 
@@ -20,6 +21,7 @@
   This requres running the following command in sqlite3: `update expansions set scoretypes="Abbey" where expansionID=5;`
 * Include played Abbey tiles in the total number of tiles played.
 * Ensure negative scores cannot be entered.
+* Print all players who are scoring when confirming.
 
 ### 0.4.1 (18 November 2018)
 

+ 12 - 1
cgame.py

@@ -251,6 +251,16 @@ class cgame:
         return 0
 
 
+    def getPlayerName(self, playerID):
+        """
+        Given a playerID, return a player's name from the database.
+        """
+
+        playerName = self.cur.execute('''SELECT name FROM players WHERE playerID={0:1.0f}'''.format(playerID)).fetchall()[0]
+
+        return playerName[0]
+
+
     def recordScore(self):
         """
         Record a score event in the game
@@ -340,7 +350,8 @@ class cgame:
         score['comments'] = input("Enter any comments you would like saved (a single line): ")
 
         # check score input to make sure it's correct
-        _sys.stdout.write('Player {0:d} scores {1:d} points on a '.format(score['playerIDs'][0], score['points']) + score['scoretype'] + '.\n')
+        _sys.stdout.write(', '.join([self.getPlayerName(x) for x in score['playerIDs']]) + ' ')
+        _sys.stdout.write('scores {0:d} points on a '.format(score['points']) + score['scoretype'] + '.\n')
         answer = input("Is this correct? (y/n) ")
         if not _re.match('y', answer, _re.IGNORECASE):
             return 1