def exec_init_setup(self, townsfolk_obj_list, outsider_obj_list, minion_obj_list, demon_obj_list):
        """Add two outsiders to the setup, remove two townsfolks from the setup"""

        random.shuffle(townsfolk_obj_list)

        # Remove two townsfolks
        townsfolk_obj_list.pop()
        townsfolk_obj_list.pop()

        # If the single remaining townsfolk is a washerwoman, then remove it
        if len(townsfolk_obj_list) == 1:
            if townsfolk_obj_list[0].name == TBRole.washerwoman.value:
                tb_townsfolk_all = BOTCUtils.get_role_list(TroubleBrewing, Townsfolk)
                all_not_washer = [character for character in tb_townsfolk_all if character.name != TBRole.washerwoman.value]
                townsfolk_obj_list = [random.choice(all_not_washer)]

        tb_outsider_all = BOTCUtils.get_role_list(TroubleBrewing, Outsider)
        random.shuffle(tb_outsider_all)

        count = 0

        for outsider in tb_outsider_all:
            if count >= 2:
                break
            else:
                if str(outsider) not in [str(role) for role in outsider_obj_list]:
                    outsider_obj_list.append(outsider)
                    count += 1

        return [townsfolk_obj_list, outsider_obj_list, minion_obj_list, demon_obj_list]
コード例 #2
0
ファイル: Undertaker.py プロジェクト: Picowchew/BOTC-Bot
    def __create_droisoned_info(self):
        """Create drunk/poisoned information for the undertaker info"""

        executed_player = globvars.master_state.game.today_executed_player

        # If someone has been executed
        if executed_player:

            tb_townsfolk_all = BOTCUtils.get_role_list(TroubleBrewing, Townsfolk)
            tb_outsider_all = BOTCUtils.get_role_list(TroubleBrewing, Outsider)
            tb_minion_all = BOTCUtils.get_role_list(TroubleBrewing, Minion)
            tb_demon_all = BOTCUtils.get_role_list(TroubleBrewing, Demon)

            executed_player.role.set_new_social_self(executed_player)

            # The executed player has a good role. The droisoned undertaker will see a
            # bad role.
            if executed_player.role.social_self.is_good():
                pool = tb_minion_all + tb_demon_all
                ret = random.choice(pool)
                return ret

            # The executed player has a bad role. The droisoned undertaker will see
            # a good role.
            else:
                pool = tb_townsfolk_all + tb_outsider_all
                pool = [character for character in pool if character.name != Undertaker().name]
                ret = random.choice(pool)
                return ret

        # If no one is executed, then send none
        else:
            return None
コード例 #3
0
ファイル: Ravenkeeper.py プロジェクト: Picowchew/BOTC-Bot
    async def exec_learn(self, ravenkeeper_player, learn_player):
        """Execute the learn action (dawn ability interaction)"""

        if DISABLE_DMS:
            return

        # Correct info
        if not ravenkeeper_player.is_droisoned():
            learned_character_type = learn_player.role.social_self

        # Droisoned info
        else:
            real_character_type = learn_player.role.true_self
            # If the real character type is good
            if real_character_type.is_good():
                tb_minion_all = BOTCUtils.get_role_list(TroubleBrewing, Minion)
                tb_demon_all = BOTCUtils.get_role_list(TroubleBrewing, Demon)
                pool = tb_minion_all + tb_demon_all
                learned_character_type = random.choice(pool)
            # If the real character type is bad
            else:
                tb_townsfolk_all = BOTCUtils.get_role_list(
                    TroubleBrewing, Townsfolk)
                tb_outsider_all = BOTCUtils.get_role_list(
                    TroubleBrewing, Outsider)
                pool = tb_townsfolk_all + tb_outsider_all
                learned_character_type = random.choice(pool)

        link = learned_character_type._art_link_cropped
        recipient = ravenkeeper_player.user

        # Add information to replay
        drunk = "Drunk " if ravenkeeper_player.role.true_self.name == Drunk(
        ).name else ""
        globvars.master_state.game.replay += f"- {recipient.name} ({drunk}Ravenkeeper) learns "\
                                    f"that {learn_player.user.name} is {learned_character_type}\n"

        msg = f"***{recipient.name}#{recipient.discriminator}***, the **{self.name}**:"
        msg += "\n"
        msg += self.emoji + " " + self.instruction
        msg += "\n"
        msg += ravenkeeper_reply.format(learned_character_type.name)

        embed = discord.Embed(description=msg)
        embed.set_thumbnail(url=link)
        embed.set_footer(text=copyrights_str)
        embed.timestamp = datetime.datetime.utcnow()

        try:
            await recipient.send(embed=embed)
        except discord.Forbidden:
            pass
コード例 #4
0
    def exec_init_setup(self, townsfolk_obj_list, outsider_obj_list,
                        minion_obj_list, demon_obj_list):
        """Add two outsiders to the setup, remove two townsfolks from the setup"""

        random.shuffle(townsfolk_obj_list)
        townsfolk_obj_list.pop()
        townsfolk_obj_list.pop()
        tb_outsider_all = BOTCUtils.get_role_list(TroubleBrewing, Outsider)
        random.shuffle(tb_outsider_all)

        count = 0

        for outsider in tb_outsider_all:
            if count >= 2:
                break
            else:
                if str(outsider) not in [
                        str(role) for role in outsider_obj_list
                ]:
                    outsider_obj_list.append(outsider)
                    count += 1

        return [
            townsfolk_obj_list, outsider_obj_list, minion_obj_list,
            demon_obj_list
        ]
コード例 #5
0
    def get_demon_bluffs(self):
        """Get the list of 3 demon bluffs"""

        # 3 demon bluffs: 2 townsfolk characters + 1 outsider character
        # Exclusing all characters taken by other players, as well as the drunk's ego_self
        all_townsfolks = BOTCUtils.get_role_list(BadMoonRising, Townsfolk)
        all_outsiders = BOTCUtils.get_role_list(BadMoonRising, Outsider)
        taken_townsfolks = [
            player.role.name
            for player in globvars.master_state.game.setup.townsfolks
        ]
        taken_outsiders = [
            player.role.name
            for player in globvars.master_state.game.setup.outsiders
        ]

        possible_townsfolk_bluffs = [
            character for character in all_townsfolks
            if character.name not in taken_townsfolks
        ]
        possible_outsider_bluffs = [
            character for character in all_outsiders
            if character.name not in taken_outsiders
        ]
        random.shuffle(possible_townsfolk_bluffs)
        random.shuffle(possible_outsider_bluffs)

        # For the first two bluffs, we want a townsfolk, definitely
        bluff_1 = possible_townsfolk_bluffs.pop()
        bluff_2 = possible_townsfolk_bluffs.pop()

        # For the third bluff, if the outsider list is not empty, we will take an outsider. Otherwise
        # it's 40% chance outsider, 60% chance townsfolk
        if possible_outsider_bluffs:
            town_or_out = random.choices(["t", "o"], weights=[0.6, 0.4])
            if town_or_out[0] == "t":
                bluff_3 = possible_townsfolk_bluffs.pop()
            else:
                bluff_3 = possible_outsider_bluffs.pop()
        else:
            bluff_3 = possible_townsfolk_bluffs.pop()

        globvars.logging.info(
            f">>> Zombull: Received three demon bluffs {bluff_1}, {bluff_2} and {bluff_3}."
        )
        return (bluff_1, bluff_2, bluff_3)
コード例 #6
0
ファイル: Washerwoman.py プロジェクト: Picowchew/BOTC-Bot
    def __create_droisoned_info(self, washerwoman_player):
        """Create the droisoned info for washerwoman"""

        # Choosing townsfolk type
        tb_townsfolk_all = BOTCUtils.get_role_list(TroubleBrewing, Townsfolk)
        registered_townsfolk_type = random.choice(tb_townsfolk_all)

        # Choosing candidates
        candidates = [player for player in globvars.master_state.game.sitting_order
                      if player.user.id != washerwoman_player.user.id]
        random.shuffle(candidates)
        candidate_1 = candidates.pop()
        candidate_2 = candidates.pop()

        return [candidate_1, candidate_2, registered_townsfolk_type]
コード例 #7
0
    def __create_droisoned_info(self, investigator_player):
        """Create the droisoned info for investigator"""

        # Choosing minion type
        tb_minion_all = BOTCUtils.get_role_list(TroubleBrewing, Minion)
        registered_minion_type = random.choice(tb_minion_all)

        # Choosing candidates
        candidates = [
            player for player in globvars.master_state.game.sitting_order
            if player.user.id != investigator_player.user.id
        ]
        random.shuffle(candidates)
        candidate_1 = candidates.pop()
        candidate_2 = candidates.pop()

        return [candidate_1, candidate_2, registered_minion_type]
コード例 #8
0
    def __create_droisoned_info(self, librarian_player):
        """Create the droisoned info for librarian"""

        # Choosing outsider type
        tb_outsider_all = BOTCUtils.get_role_list(TroubleBrewing, Outsider)
        registered_outsider_type = random.choice(tb_outsider_all)

        # Choosing candidates
        candidates = [
            player for player in globvars.master_state.game.sitting_order
            if player.user.id != librarian_player.user.id
        ]
        random.shuffle(candidates)
        candidate_1 = candidates.pop()
        candidate_2 = candidates.pop()

        return [candidate_1, candidate_2, registered_outsider_type]