Sfoglia il codice sorgente

bugfix: ensure scores cannot be negative

George C. Privon 7 anni fa
parent
commit
50c82fbdd3
2 ha cambiato i file con 7 aggiunte e 3 eliminazioni
  1. 1 1
      CHANGELOG.md
  2. 6 2
      cgame.py

+ 1 - 1
CHANGELOG.md

@@ -19,7 +19,7 @@
 * Fixed missing Abbey score type when Expansion 5 is used.
   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.
 
 ### 0.4.1 (18 November 2018)
 

+ 6 - 2
cgame.py

@@ -327,8 +327,12 @@ class cgame:
         while not VALID:
             points = input("Enter the total number of points: ")
             try:
-                score['points'] = int(points)
-                VALID = True
+                pts = int(points)
+                if pts >= 0:
+                    score['points'] = int(points)
+                    VALID = True
+                else:
+                    _sys.stderr.write("Score cannot be negative.\n")
             except:
                 _sys.stderr.write("'" + points + "' is not a valid score.\n")
                 continue