async def handle(e: mv.CardsPlacedBottomOfDeck) -> None: player = game.get_player(e.player) is_client = player is game.client_player print(f"{'You' if is_client else player.username} " f"{'have' if is_client else 'has'} placed back the other " f"{len(e.cards)} {pluralize('card', len(e.cards))} " f"at the bottom of the deck.")
async def handle(e: mv.CardDealt) -> None: player = game.get_player(e.target) is_client = player is game.client_player print( f"{'You' if is_client else player.username} " f"{'are' if is_client else 'is'} dealt another card from the deck." )
async def handle(e: rnd.RoundEnd) -> None: get_username = lambda p: game.get_player(p).username # noqa await pause() print_header("Round end", filler="—") draw_game(game, reveal=True) print(">>>>> The round has ended! <<<<<") if e.reason == rnd.RoundEnd.Reason.EMPTY_DECK: print("There are no cards remaining in the deck.") if len(e.tie_contenders) == 1: print( f"{get_username(e.winner)} wins with a {e.winner.hand.card}, " f"which is the highest card among those remaining.") else: card = mitt.first(p.hand.card for p in e.tie_contenders) contenders = list(map(get_username, e.tie_contenders)) contenders_str = ( f"Both {contenders[0]} and {contenders[1]}" if len(contenders) == 2 else f"Each of {', '.join(contenders[:-1])} and {contenders[-1]}" ) print(f"{contenders_str} have the highest card: a {card}.") print( f"But {get_username(e.winner)} has a higher sum of discarded" f" values, so they win." if len(e.winners) == 1 else f"And they each have the same sum of discarded values," f" so they {'both' if len(contenders) == 2 else 'all'} win" f" in a tie.") elif e.reason == rnd.RoundEnd.Reason.ONE_PLAYER_STANDING: print( f"{get_username(e.winner)} is the only player still alive, " f"so they win the round.")
async def handle(e: rnd.PlayingCard) -> None: player, card = game.get_player(e.player), e.card is_client = player is game.client_player print( f"{'You' if is_client else player.username} " f"{'have' if is_client else 'has'} chosen to play a {card.name}." )
async def handle(e: mv.PlayerEliminated) -> None: player = game.get_player(e.eliminated) is_client = player is game.client_player msg = (f"💀 {'You' if is_client else player.username} " f"{'have' if is_client else 'has'} been eliminated! 💀") if not is_client: msg += f" They had a {e.eliminated_card.name}." print(msg)
async def handle(e: rnd.Turn) -> None: if e.turn_no > 1: await pause() player = game.get_player(e.current_player) is_client = player is game.client_player possessive = "Your" if is_client else f"{player.username}'s" print_header(f"{possessive} turn", filler="—") draw_game(game) if is_client: print(">>>>> It's your turn! <<<<<\a") else: print(f"It's {player.username}'s turn.")
async def handle(e: mv.ImmunityGranted) -> None: player = game.get_player(e.player) is_client = player is game.client_player print(f"{'You' if is_client else player.username} " f"{'have' if is_client else 'has'} been granted immunity.")
async def handle(e: mv.CardChosen) -> None: player = game.get_player(e.player) if player is game.client_player: print(f"You have chosen to keep the {e.choice.name}.") else: print(f"{player.username} has chosen a card to keep.")
async def handle(e: mv.CardDiscarded) -> None: player = game.get_player(e.target) is_client = player is game.client_player print( f"{'You' if is_client else player.username} " f"discard{'s' if not is_client else ''} a {e.discarded.name}.")