Beispiel #1
0
    async def match(self, ctx, person1: str, person2: str):
        member1 = self.findMember(person1, ctx.guild.id)
        member2 = self.findMember(person2, ctx.guild.id)
        if member1 is None:
            await ctx.send("The first person could not be found. Try again.")
            return
        if member2 is None:
            await ctx.send("The second villager could not be found. Try again."
                           )
            return

        villager1 = models.villager.Villager.find_one({
            "discord_id": member1.id,
            "server": ctx.guild.id
        })
        villager2 = models.villager.Villager.find_one({
            "discord_id": member2.id,
            "server": ctx.guild.id
        })
        game_document = models.game.Game.find_one({"server": ctx.guild.id})
        if not villager1["alive"] or not villager2["alive"]:
            await ctx.send("You can't match dead villagers. Try again!")
            return
        abilities.use_ability("cupid", ctx.guild.id)
        game_document["inlove"].append(villager1["discord_id"])
        game_document["inlove"].append(villager2["discord_id"])
        game_document.save()
        await ctx.send("{} and {} are in love now".format(person1, person2))
        # self.__bot.remove_command("match")
        read_write_permission = files.readJsonFromConfig(
            "permissions.json")["read_write"]
        love_channel = ctx.guild.get_channel(
            models.channels.getChannelId("lovebirds", ctx.guild.id))
        for x in game_document["inlove"]:
            await love_channel.set_permissions(
                ctx.guild.get_member(x),
                overwrite=discord.PermissionOverwrite(**read_write_permission))
        await love_channel.send("Welcome {} and {}. "
                                "You two are now in love! :heart:".format(
                                    member1.mention, member2.mention))
Beispiel #2
0
 async def investigate(self, ctx, person_name):
     if not abilities.check_ability("seer", ctx.guild.id):
         await ctx.send(
             "The future is hazy, but when it's night again you may have a better chance, if you don't die before then"
         )
         return
     target = self.findMember(person_name, ctx.guild.id)
     if target is None:
         await ctx.send("That person could not be found. Please try again.")
         return
     target_document = models.villager.Villager.find_one({
         "server":
         ctx.guild.id,
         "discord_id":
         target.id
     })
     if target_document is None:
         await ctx.send("That person could not be found. Please try again.")
         return
     await ctx.send("{} is {}a werewolf".format(
         target.mention, "" if target_document['werewolf'] else "not "))
     abilities.use_ability("seer", ctx.guild.id)
Beispiel #3
0
 async def sendmessage(self, ctx, word: str):
     if ctx.guild.id == 695805513480536074 or ctx.guild.id == 523892810319921157:
         await ctx.send("This is temporarily disabled. I'm sorry :cry:")
         return
     v = models.villager.Villager.find_one({
         "server": ctx.guild.id,
         "discord_id": ctx.author.id
     })
     dreamers = models.villager.Villager.find({
         "server": ctx.guild.id,
         "alive": True,
         "werewolf": False
     })
     the_chosen_dreamer = random.choice(dreamers)
     is_werewolf = v["werewolf"]
     if not abilities.check_ability(
             "dead_wolves" if is_werewolf else "spirits", ctx.guild.id):
         await ctx.send(
             "You've already sent a message or a hint. Wait until the next night."
         )
         return
     if len(word.split(' ')) > 1:
         await ctx.send("You can only send one word at a time")
         return
     if self.findPlayer(word, ctx.guild.id) is not None:
         await ctx.send(
             "You cannot use a name of someone playing as the actual word.")
         return
     if is_werewolf:
         abilities.use_ability("dead_wolves", ctx.guild.id)
     else:
         abilities.use_ability("spirits", ctx.guild.id)
     channel = ctx.guild.get_channel(
         models.channels.getChannelId("mason", ctx.guild.id))
     await channel.send("You have received a message from above.")
     await channel.send(word)
Beispiel #4
0
 async def protect(self, ctx, person_name):
     if not abilities.check_ability("bodyguard", ctx.guild.id):
         await ctx.send(
             "You've been protecting someone and now you're tired. Get some rest until the next morning."
         )
         return
     # protector: villager.Villager = self.findVillager(ctx.message.author.name)
     the_protected_one = self.findMember(name=person_name,
                                         guild_id=ctx.guild.id)
     if the_protected_one is None:
         await ctx.send("I couldn't find that person!")
         return
     game_document = models.game.Game.find_one({"server": ctx.guild.id})
     protected_document = models.villager.Villager.find_one({
         "server":
         ctx.guild.id,
         "discord_id":
         the_protected_one.id
     })
     if protected_document is None:
         await ctx.send("I couldn't find that person!")
         return
     if game_document["last_protected_id"] == the_protected_one.id:
         await ctx.send(
             "You protected that person recently. Try someone new.")
         return
     if not protected_document["alive"]:
         await ctx.send(
             "You should have protected that person sooner. Choose someone else."
         )
         return
     abilities.use_ability("bodyguard", ctx.guild.id)
     await ctx.send("You've protected {}".format(the_protected_one.mention))
     game_document["protected"] = the_protected_one.id
     game_document["last_protected_id"] = the_protected_one.id
     game_document.save()
Beispiel #5
0
    async def kill(self, ctx, person_name):
        game_document = models.game.Game.find_one({"server": ctx.guild.id})
        if game_document is None:
            ctx.send("There's no game right now. You can't kill yet.")
            return
        if not abilities.check_ability("werewolves", ctx.guild.id):
            await ctx.send(
                "You already killed. Get some rest and don't get caught.")
            return
        target = self.findMember(name=person_name, guild_id=ctx.guild.id)
        if target is None:
            await ctx.send("That person could not be found. Please try again.")
            return
        target_document = models.villager.Villager.find_one({
            "discord_id":
            target.id,
            "server":
            ctx.guild.id
        })
        if target.id in game_document["hunter_ids"]:
            await ctx.send(
                "You can't kill the hunter after the hunter has already been killed. "
                "The hunter will die when he shoots. Don't worry!")
            return
        if not target_document["alive"]:
            await ctx.send("That person is already dead. Try again!")
            return
        if target_document is None:
            await ctx.send("That person could not be found. Please try again.")
            return
        abilities.use_ability("werewolves", ctx.guild.id)
        if target.id == game_document["protected"]:
            await ctx.send(
                "That person has been protected. You just wasted your kill!")
            message = "The werewolves have tried to kill someone but failed to do so because that person was protected."
            game_document["morning_messages"].append(message)
            game_document.save()
        else:
            await ctx.send("Killing {}".format(target.mention))
            character = target_document["character"]
            server_document = models.server.Server.find_one(
                {"server": ctx.guild.id})
            if "announce_character" not in server_document:
                server_document["announce_character"] = True
                server_document.save()
            if server_document["announce_character"]:
                killing_message = files.werewolfMessages[
                    target_document["character"]]["killed"].format(
                        target.mention)
            else:
                is_werewolf = target_document["werewolf"]
                if character == "hunter":
                    killing_message = files.werewolfMessages["hunter"][
                        "killed"].format(target.mention)
                    killed_member = ctx.guild.get_member(target.id)
                    await killed_member.send(
                        f"Hi! You've been targeted in {ctx.guild.name} by the werewolves so you "
                        f"need to go to town square now to !shoot someone before you die. "
                        f"Let the host know if you have any questions.")

                elif is_werewolf:
                    killing_message = files.werewolfMessages["werewolf"][
                        "killed"].format(target.mention)
                else:
                    killing_message = files.werewolfMessages["villager"][
                        "killed"].format(target.mention)
            game_document["morning_messages"].append(killing_message)
            game_document.save()
            await self.die_from_db(target.id,
                                   ctx.guild.id,
                                   announce_at_day=True)