@@ -13,15 +13,15 @@ def __init__(self, players, action_count: int) -> None:
1313 if action_count < 0 :
1414 raise ValueError (f"Action count must be greater than or equal to 3" )
1515
16- if not players or len (players ) < 2 :
17- raise ValueError (f"Must have at least two players" )
16+ # if not players or len(players) < 2:
17+ # raise ValueError(f"Must have at least two players")
1818
1919 self ._players = players
2020 self ._original_players = players .copy () # for resetting game
2121 self ._action_count = action_count
2222 self ._beats = {}
23- self .round_num = 0
24- self .game_num = 1
23+ self ._round_num = 1
24+ self ._game_num = 1
2525
2626 # set beats/game rules created by https://www.umop.com/rps.htm
2727 if 3 <= action_count <= 15 and action_count % 2 != 0 and action_count != 13 :
@@ -39,6 +39,26 @@ def beats(self):
3939 @property
4040 def players (self ):
4141 return self ._players
42+
43+ @players .setter
44+ def players (self , players ):
45+ self ._players = players
46+
47+ @property
48+ def round_num (self ):
49+ return self ._round_num
50+
51+ @round_num .setter
52+ def round_num (self , round_num ):
53+ self ._round_num = round_num
54+
55+ @property
56+ def game_num (self ):
57+ return self ._game_num
58+
59+ @game_num .setter
60+ def game_num (self , game_num ):
61+ self ._game_num = game_num
4262
4363 def generate_beats (self ):
4464 """generate beats dictionary for games with action size 17 or greater"""
@@ -91,7 +111,7 @@ def eliminate(self, actions: list[int]) -> list[int]:
91111 if i == n :
92112 result .append (p )
93113
94- log .info (f"eliminated players: { [(p .name , p . action ) for p in result ]} " )
114+ log .info (f"eliminated players: { [(p .name ) for p in result ]} " )
95115
96116 return eliminated
97117
@@ -116,15 +136,15 @@ def play_round(self):
116136
117137 def reset (self ):
118138 self ._players = self ._original_players .copy ()
119- self .round_num = 0
120- self .game_num += 1
139+ self ._round_num = 1
140+ self ._game_num += 1
141+ log .info ("game has been reset" )
121142
122143 def play (self ):
123- self .round_num += 1
124144 while len (self ._players ) > 1 :
125- log .info (f"Round { round } " )
145+ log .info (f"Round { self . _round_num } " )
126146 self .play_round ()
127- self .round_num += 1
147+ self ._round_num += 1
128148 log .info (" " )
129149
130150 log .info (f"Winner is { self ._players [0 ].name } " )
0 commit comments