def announce_match_winner(self): if self.game_mode is not GameMode.single_match: player_card_count = purple(len(self.player_cards)) opponent_card_count = purple(len(self.opponent_cards)) final_result = compare(len(self.player_cards), len(self.opponent_cards)) if self.game_mode is GameMode.traditional: print(f'You managed to obtain all {player_card_count} cards!') elif self.game_mode is GameMode.deplete: print( f'You accumulated {player_card_count} cards ' f'and your opponent amassed {opponent_card_count} cards.') if final_result == BattleResult.win: print('Congratulations, you {} the match! ✌️'.format( green('WIN'))) elif final_result == BattleResult.lose: print('☠️ Unfortunately, you {} the match... ☠️'.format( red('LOSE'))) else: print('The match ends in a {}!'.format(yellow('DRAW'))) self.show_final_score() score = Score(self.store.settings['player_name'], self.wins) self.submit_score(ScoreboardType.single_match, 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 choose_turn_player(self, user_choice: CoinToss) -> Turn: print('Tossing coin... ', end='') coin_toss: CoinToss = random.choice([CoinToss.heads, CoinToss.tails]) if user_choice: turn_player = Turn.user if coin_toss == user_choice else Turn.opponent else: turn_player = Turn.user if coin_toss == CoinToss.heads else Turn.opponent coin_toss_str = 'HEADS' if coin_toss == CoinToss.heads else 'TAILS' print('{}! '.format(yellow(coin_toss_str)), end='') if turn_player == Turn.user: print('{} go first!'.format(green('YOU'))) else: print('Your {} goes first!'.format(yellow(red('OPPONENT')))) return turn_player
def get_turn_player_str(self, turn_player: Turn) -> str: if turn_player == Turn.user: return green('YOU') else: return 'Your {}'.format(red('OPPONENT'))