Exemple #1
0
    async def process_night_ability(self, player):
        """Process night actions for the zombuul character.
        @player : the Zombuul player (Player object)
        """

        # We only do any of the following if the zombuul is alive. Otherwise skip everything.
        if player.is_alive():

            phase = globvars.master_state.game._chrono.phase_id
            action = player.action_grid.retrieve_an_action(phase)
            # The zombuul has submitted an action. We call the execution function immediately
            if action:
                assert action.action_type == ActionTypes.kill, f"Wrong action type {action} in zombuul"
                targets = action.target_player
                killed_player = targets[0]
                await self.exec_kill(player, killed_player)
            # The zombuul has not submitted an action. We will randomize the action and make
            # the zombuul kill one random player that is not the zombuul.
            else:
                if player.is_alive():
                    killed_player = BOTCUtils.get_random_player_excluding(
                        player)
                    await self.exec_kill(player, killed_player)
                    msg = botutils.BotEmoji.butterfly
                    msg += " "
                    msg += action_assign.format(killed_player.game_nametag)
                    try:
                        await player.user.send(msg)
                    except discord.Forbidden:
                        pass
                else:
                    pass
    async def process_night_ability(self, player):
        """Process night actions for the butler character.
        @player : the Butler player (Player object)
        """

        phase = globvars.master_state.game._chrono.phase_id
        action = player.action_grid.retrieve_an_action(phase)
        # The butler has submitted an action. We call the execution function immediately
        if action:
            assert action.action_type == ActionTypes.serve, f"Wrong action type {action} in butler"
            targets = action.target_player
            master_player = targets[0]
            await self.exec_serve(player, master_player)
        # The butler has not submitted an action. We randomize the master for him,
        # DM him the choice of the master, and then call the execution function
        else:
            master_player = BOTCUtils.get_random_player_excluding(player)
            await self.exec_serve(player, master_player)
            msg = botutils.BotEmoji.butterfly
            msg += " "
            msg += action_assign.format(master_player.game_nametag)
            try:
                await player.user.send(msg)
            except discord.Forbidden:
                pass