@@ -114,11 +114,11 @@ def wrapper(self, *args):
114114
115115 return wrapper
116116
117- def set_is_new_game (self , is_new_game ): # pragma: no cover
117+ def set_is_new_game (self , is_new_game ): # pragma: no cover
118118 """Set if this is a new game or restored from the saved game."""
119119 self .is_new_game = is_new_game
120120
121- def preloop (self ): # pragma: no cover
121+ def preloop (self ): # pragma: no cover
122122 """Preloop.
123123
124124 This will run before the game loop begins,
@@ -133,7 +133,7 @@ def preloop(self): # pragma: no cover
133133 self .start_game ()
134134 self .display_score_board ()
135135
136- def choose_number_of_dice (self ): # pragma: no cover
136+ def choose_number_of_dice (self ): # pragma: no cover
137137 """Choose if one or two dice."""
138138 num_of_dice = inquirer .select (
139139 message = "How many dice?" , choices = ["1" , "2" ]
@@ -142,7 +142,7 @@ def choose_number_of_dice(self): # pragma: no cover
142142 return 1
143143 return 2
144144
145- def choose_robot_or_human (self ): # pragma: no cover
145+ def choose_robot_or_human (self ): # pragma: no cover
146146 """Choose if they want to play with a robot or a human."""
147147 action = inquirer .select (
148148 message = "Play with?" , choices = ["🦾 a robot" , "💪 a human" ]
@@ -161,7 +161,7 @@ def choose_robot_or_human(self): # pragma: no cover
161161 self .is_opponent_robot = False
162162 self .start_game ()
163163
164- def choose_intelligence_level (self ): # pragma: no cover
164+ def choose_intelligence_level (self ): # pragma: no cover
165165 """Choose the IQ of the robot."""
166166 intel = inquirer .select (
167167 message = "How smart do you want your robot friend to be?" ,
@@ -176,7 +176,7 @@ def choose_intelligence_level(self): # pragma: no cover
176176 return intelligence_levels ["h" ]
177177
178178 @check_is_new_game
179- def do_start (self , arg ): # pragma: no cover
179+ def do_start (self , arg ): # pragma: no cover
180180 """Start the game."""
181181 if self .is_game_in_progress :
182182 print ("Can't start a game while there is one in progress" )
@@ -185,7 +185,7 @@ def do_start(self, arg): # pragma: no cover
185185 self .number_of_dice = self .choose_number_of_dice ()
186186 self .choose_robot_or_human ()
187187
188- def start_game (self ): # pragma: no cover
188+ def start_game (self ): # pragma: no cover
189189 """Start game or resume."""
190190 print ("Game started" )
191191 self .is_game_paused = False
@@ -195,14 +195,15 @@ def start_game(self): # pragma: no cover
195195
196196 @check_is_active_game
197197 @check_is_game_paused
198- def do_play (self , arg ): # pragma: no cover
198+ def do_play (self , arg ): # pragma: no cover
199199 """Play. You will be asked to choose to roll or hold."""
200200 turn_score = 0
201201 points = self .current_player .get_score ()
202202
203203 print (
204204 f"\n {
205- self .current_player .get_name ()} 's total points: { points } , Round total: { turn_score } " )
205+ self .current_player .get_name ()} 's total points: { points } , Round total: { turn_score } "
206+ )
206207
207208 choice = self .choose_roll_or_hold ()
208209 is_winner_found = False
@@ -241,7 +242,7 @@ def do_play(self, arg): # pragma: no cover
241242 self .auto_play ()
242243
243244 @check_is_game_paused
244- def auto_play (self ): # pragma: no cover
245+ def auto_play (self ): # pragma: no cover
245246 """Robot plays."""
246247 points = self .player_two .get_score ()
247248 turn_score = 0
@@ -279,7 +280,7 @@ def auto_play(self): # pragma: no cover
279280 if not is_winner_found :
280281 self .pass_to_human ()
281282
282- def choose_roll_or_hold (self ): # pragma: no cover
283+ def choose_roll_or_hold (self ): # pragma: no cover
283284 """Choose to roll the dice or hold."""
284285 choice = inquirer .select (
285286 message = "Roll or hold" , choices = ["Roll" , "Hold" ]
@@ -288,7 +289,7 @@ def choose_roll_or_hold(self): # pragma: no cover
288289 return "Roll"
289290 return "Hold"
290291
291- def roll (self ): # pragma: no cover
292+ def roll (self ): # pragma: no cover
292293 """Roll the dice once or twice depending on how many dice there are."""
293294 result_list = []
294295 result = 0
@@ -302,27 +303,30 @@ def roll(self): # pragma: no cover
302303 print ()
303304 return result , result_list
304305
305- def count_ones (self , faces ): # pragma: no cover
306+ def count_ones (self , faces ): # pragma: no cover
306307 """Count the number of ones in the list "faces."""
307308 count = faces .count (1 )
308309 return count
309310
310- def print_rolled_one_outcome (self , num_of_ones ): # pragma: no cover
311+ def print_rolled_one_outcome (self , num_of_ones ): # pragma: no cover
311312 """Check how many ones have been rolled this round.
312313
313314 To decide if the player had lost points from this round, points
314315 from this game, or no points at all.
315316 """
316317 if num_of_ones == 1 :
317- print ("Rolled a single one and lost all the points from this turn." ) # pragma: no cover
318+ print (
319+ "Rolled a single one and lost all the points from this turn."
320+ ) # pragma: no cover
318321
319322 if num_of_ones == 2 :
320- print ("Rolled double ones and lost all points from this game." ) # pragma: no cover
323+ print (
324+ "Rolled double ones and lost all points from this game."
325+ ) # pragma: no cover
321326
322327 print ("TURN ENDS.\n " ) # pragma: no cover
323328
324-
325- def switch_current_player (self ): # pragma: no cover
329+ def switch_current_player (self ): # pragma: no cover
326330 """Set current player to other player when current players turn ends.
327331
328332 Change name in prompt.
@@ -333,12 +337,12 @@ def switch_current_player(self): # pragma: no cover
333337 self .current_player = self .player_one
334338 Game .prompt = self .current_player .get_name () + "> "
335339
336- def pass_to_human (self ): # pragma: no cover
340+ def pass_to_human (self ): # pragma: no cover
337341 """Change current player to human. Change name in prompt."""
338342 self .current_player = self .player_one
339343 Game .prompt = self .player_one .get_name () + "> "
340344
341- def run_winner_found_sequence (self , winner ): # pragma: no cover
345+ def run_winner_found_sequence (self , winner ): # pragma: no cover
342346 """Announce the winner.
343347
344348 Set that there is no active game;
@@ -354,13 +358,12 @@ def run_winner_found_sequence(self, winner): # pragma: no cover
354358 self .score_record .record_game (self .player_one , self .player_two , winner )
355359 self .reset_player_scores ()
356360
357- def reset_player_scores (self ): # pragma: no cover
361+ def reset_player_scores (self ): # pragma: no cover
358362 """Reset players scores."""
359363 self .player_two .set_score (0 )
360364 self .player_one .set_score (0 )
361365
362366 def display_score_board (self ): # pragma: no cover
363-
364367 """Display in game score board."""
365368 info = {
366369 self .player_one .get_name (): self .player_one .get_score (),
@@ -374,46 +377,45 @@ def display_score_board(self): # pragma: no cover
374377 """
375378 Utils .print_dict_table (info , banner )
376379
377- def announce_winner (self , player ): # pragma: no cover
380+ def announce_winner (self , player ): # pragma: no cover
378381 """Announce the winner."""
379382 print (f"{ player .get_name ()} has won. Congrats🎉" )
380383
381- def announce_game_end (self ): # pragma: no cover
384+ def announce_game_end (self ): # pragma: no cover
382385 """Announce the end of game."""
383386 print ("\n GAME OVER!. Type 'start' to play another game" )
384387 Game .prompt = "piggygame> "
385388
386389 @check_is_active_game
387390 @check_is_game_paused
388- def do_cheat (self , arg ): # pragma: no cover
391+ def do_cheat (self , arg ): # pragma: no cover
389392 """Cheat to win."""
390393 self .current_player .set_score (100 )
391394 self .run_winner_found_sequence (self .current_player )
392395
393396 @check_is_active_game
394- def do_pause (self , arg ): # pragma: no cover
397+ def do_pause (self , arg ): # pragma: no cover
395398 """Save game data to file and pause the game."""
396399 # self.save_game()
397400 self .is_game_paused = True
398401 print ("Game paused. Type 'unpause' to resume game\n " )
399402 Game .prompt = "piggygame> "
400403
401- def do_explain (self , arg ): # pragma: no cover
404+ def do_explain (self , arg ): # pragma: no cover
402405 """Explain the rules of the game."""
403406 just_the_rules = Game .intro .splitlines ()[4 :14 ]
404407 print ("\n " .join (just_the_rules ))
405408
406409 @check_is_active_game
407- def do_unpause (self , arg ): # pragma: no cover
410+ def do_unpause (self , arg ): # pragma: no cover
408411 """Unpause the game."""
409412 self .is_game_paused = False
410413 self .display_score_board ()
411414 Game .prompt = self .current_player .name + "> "
412415
413416 @check_is_active_game
414417 @check_is_game_paused
415- def do_changename (self , arg ): # pragma: no cover
416-
418+ def do_changename (self , arg ): # pragma: no cover
417419 """Change your username."""
418420 old_name = self .current_player .get_name ()
419421 new_name = input ("Enter your new name: " )
@@ -425,8 +427,7 @@ def do_changename(self, arg): # pragma: no cover
425427 self .score_record .update_player_name (old_name , new_name )
426428 Game .prompt = self .current_player .get_name () + "> "
427429
428- def do_show (self , arg ):# pragma: no cover
429-
430+ def do_show (self , arg ): # pragma: no cover
430431 """Show statistics."""
431432 choice = inquirer .select (
432433 message = "What would you like to see?" ,
@@ -438,7 +439,7 @@ def do_show(self, arg):# pragma: no cover
438439 else :
439440 stats .display_games_played ()
440441
441- def do_exit (self , arg ): # pragma: no cover
442+ def do_exit (self , arg ): # pragma: no cover
442443 """Exit the game."""
443444 choice = inquirer .select (
444445 message = "Save the game to resume later?" ,
@@ -454,8 +455,7 @@ def do_exit(self, arg): # pragma: no cover
454455
455456 return True
456457
457- def __getstate__ (self ):# pragma: no cover
458-
458+ def __getstate__ (self ): # pragma: no cover
459459 """Fix error.
460460
461461 Added this to solve "can't pickle
@@ -470,8 +470,7 @@ def __getstate__(self):# pragma: no cover
470470 del state [key ]
471471 return state
472472
473- def __setstate__ (self , state ):# pragma: no cover
474-
473+ def __setstate__ (self , state ): # pragma: no cover
475474 """Fix error.
476475
477476 Added this to solve "can't pickle
@@ -483,7 +482,7 @@ def __setstate__(self, state):# pragma: no cover
483482 self .stdin = sys .stdin
484483 self .stdout = sys .stdout
485484
486- def postloop (self ): # pragma: no cover
485+ def postloop (self ): # pragma: no cover
487486 """Pickle the whole game object."""
488487 if self .save_game :
489488 with open ("game_state.pkl" , "wb" ) as f :
0 commit comments