def show(self): print(purple('=' * 40)) print(blue('{:^40}'.format(f'{self.name} Scoreboard'))) print(purple('=' * 40)) print(blue('{:^10} {:<20} {:^5}'.format('position', 'player', 'score'))) for position, entry in enumerate(self.scores, start=1): print('{:^10} {:<20} {:>5}'.format(position, entry.player_name, entry.score))
def announce_start(self): print_separator(green) left_side = red('|') right_side = blue('|') title = purple('STARTING GAME...') print('{:<} {:^55} {:>}'.format(left_side, title, right_side)) print_separator(yellow)
def do_battle(self, stat_choice: Entry, user_pokemon: Pokemon, enemy_pokemon: Pokemon) -> BattleResult: self.battle_count += 1 stat_name = stat_choice.name user_pokemon_stat = user_pokemon[stat_name].value enemy_pokemon_stat = enemy_pokemon[stat_name].value result = compare(user_pokemon_stat, enemy_pokemon_stat) if result == BattleResult.draw: self.draws += 1 summary = "{}! Your {} and your opponent's {} both have {} {}.".format( yellow('DRAW'), blue(user_pokemon.name), red(enemy_pokemon.name), yellow(user_pokemon_stat), yellow(stat_name)) else: if result == BattleResult.win: self.wins += 1 self.move_card(enemy_pokemon, Player.user) winner = 'Your' wining_pokemon = blue(user_pokemon.name) wining_stat = yellow(user_pokemon_stat) loser = 'enemy' loser_pokemon = red(enemy_pokemon.name) losing_stat = yellow(enemy_pokemon_stat) print('You {}! '.format(green('WIN')), end='') else: self.loses += 1 self.move_card(user_pokemon, Player.opponent) winner = 'Enemy' wining_pokemon = red(enemy_pokemon.name) wining_stat = yellow(enemy_pokemon_stat) loser = 'your' loser_pokemon = blue(user_pokemon.name) losing_stat = yellow(user_pokemon_stat) print('You {}! '.format(red('LOSE')), end='') coloured_stat_name = yellow(stat_name) summary = f"{winner} {wining_pokemon}'s {wining_stat} {coloured_stat_name} beats "\ f"{loser} {loser_pokemon}'s {losing_stat} {coloured_stat_name}! " print(summary) if result == BattleResult.win: print("You get the opponent's {}!".format(red(enemy_pokemon.name))) elif result == BattleResult.lose: print('Your opponent gets your {}!'.format(blue( user_pokemon.name))) return result
def show_final_score(self): win_count = green(f'{self.wins} wins') lose_count = red(f'{self.loses} loses') draw_count = yellow(f'{self.draws} draws') total = blue(f'{self.battle_count} total') print_separator() self.show_win_rate() print(f'Your score: {win_count}, {lose_count}, {draw_count} ({total})') print_separator()
def give_final_card(self, turn_player: Turn) -> bool: # if there's one more card in the neutral deck, # it will just get added to the winning person's deck, # so start calculating winner if len(self.deck) == 1: pokemon = create_pokemon(self.deck[0]) announcement = 'There is only one card left in the neutral deck ({}). ' \ 'Determining winner...'.format(blue(pokemon.name)) print(announcement) # add last card to current player's turn if turn_player == Turn.user: self.player_cards.append(pokemon) else: self.opponent_cards.append(pokemon) return True return False
def submit_score(self, scoreboard: ScoreboardType, score: Score): new_high_score = self.store.submit_score(scoreboard, False, score) if new_high_score: announcement = 'Congratulations {} for reaching a new high score of {}!'.format( blue(self.store.settings['player_name']), blue(score.score)) print(announcement)
def title_me(title: str): instructions.append("{:^60}".format(blue(title)))