Skip to content

Commit 81fbdd7

Browse files
author
Kevin J Walters
committed
Moving points values out to constants.
Squashing some assignments onto one line.
1 parent ff6fffe commit 81fbdd7

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

CLUE_Rock_Paper_Scissors/advanced/clue-multi-rpsgame.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
if ble_name is None:
6969
print("INFO: No rps_name or ble_name entry found in secrets dict")
7070
except ImportError:
71-
pass
71+
pass # File is optional, reaching here is not a program error
7272

7373

7474
debug = 1
@@ -232,10 +232,7 @@ def tftGizmoPresent():
232232

233233
game_no = 1
234234
round_no = 1
235-
wins = 0
236-
losses = 0
237-
draws = 0
238-
voids = 0
235+
wins = losses = draws = voids = 0
239236

240237
# TOTAL_ROUNDS = 5
241238
TOTAL_ROUNDS = 3
@@ -244,6 +241,9 @@ def tftGizmoPresent():
244241
KEY_SIZE = 8 # in bytes
245242
KEY_ENLARGE = 256 // KEY_SIZE // 8
246243

244+
# Scoring values
245+
POINTS_WIN = 2
246+
POINTS_DRAW = 1
247247

248248
WIN = const(1)
249249
DRAW = const(2) # AKA tie
@@ -350,10 +350,7 @@ def addPlayer(name, addr_text, address, ad):
350350

351351
# Reset variables for another game
352352
round_no = 1
353-
wins = 0
354-
losses = 0
355-
draws = 0
356-
voids = 0
353+
wins = losses = draws = voids = 0
357354
scores = [0] * len(players)
358355
game_no += 1
359356

@@ -535,14 +532,14 @@ def addPlayer(name, addr_text, address, ad):
535532
voids += this_player
536533
elif result == DRAW:
537534
draws += this_player
538-
scores[p_idx0] += 1
539-
scores[p_idx1] += 1
535+
scores[p_idx0] += POINTS_DRAW
536+
scores[p_idx1] += POINTS_DRAW
540537
elif result == WIN:
541538
wins += this_player
542-
scores[p_idx0] += 2
539+
scores[p_idx0] += POINTS_WIN
543540
else:
544541
losses += this_player
545-
scores[p_idx1] += 2
542+
scores[p_idx1] += POINTS_WIN
546543

547544
d_print(2,
548545
p0_name, player_choices[p_idx0], "vs",

0 commit comments

Comments
 (0)