示例#1
0
 async def chess_leave(self, ctx):
     player = db.get_player_info(ctx.guild.id, ctx.author.id)
     db.execute("UPDATE Characters SET chess = 0 WHERE id = %s",
                (player.get('id'), ))
     await ctx.send(
         f"{ctx.author.display_name} has been removed from the chess queue."
     )
示例#2
0
 async def check_stats(self, ctx, *, member: discord.Member = 0):
     """
     Checks the stats of the command's invoker, or if executed by an ST or narrator,\n\
     the command of a given member.\n\n\
     Syntax: $check_stats / $check_stats [member]
     """
     authorized = False
     guild = db.get_guild_info(ctx.guild.id)
     for role in ctx.author.roles:
         if guild.get("st_id") == role.id:
             authorized = True
         elif guild.get("narrator_id") == role.id:
             authorized = True
     if authorized:
         if member == 0:
             stats_member = ctx.author
         else:
             stats_member = member
     else:
         stats_member = ctx.author
     player = db.get_player_info(ctx.guild.id, stats_member.id)
     await ctx.author.send(
         f"--Stats for {stats_member.mention} on \"{ctx.guild.name}\"--\n\nBlood Points: {player.get('bp')}\nBlood "
         f"Point Cap: {player.get('bp_max')}\nWillpower: {player.get('wp')}\nWillpower Cap: {player.get('wp_max')}\n"
         f"Aggravated Damage: {player.get('agg_dmg')}\nMonthly Upkeep: {player.get('upkeep')}\nExperience: "
         f"{player.get('experience')}"
     )
示例#3
0
 async def add_player(self, ctx, member: discord.Member):
     """
     Adds a blank entry for the mentioned Discord user.
     """
     authorized = False
     guild = db.get_guild_info(ctx.guild.id)
     for role in ctx.author.roles:
         if guild.get("st_id") == role.id:
             authorized = True
         elif guild.get("narrator_id") == role.id:
             authorized = True
     if authorized:
         try:
             exist_check = db.get_player_info(ctx.guild.id, member.id)
         except TypeError:
             db.execute(
                 "INSERT INTO Characters (player_id, bp_max, bp, wp_max, wp, upkeep, upkeep_dt, agg_dmg, "
                 "alert_flag, guild_id, active_toggle, Experience) VALUES (%s,5,5,5,5,0,' ', 0,0,%s, 0, 0)",
                 (member.id, guild.get("id")),
             )
             await ctx.send("Player Added")
         else:
             await ctx.send(
                 "Player is already in the database for this server. Please remove them first."
             )
示例#4
0
 async def add_exp(self, ctx, member, value):
     authorized = False
     guild = db.get_guild_info(ctx.guild.id)
     for role in ctx.author.roles:
         if guild.get("st_id") == role.id:
             authorized = True
     if authorized:
         player = db.get_player_info(ctx.guild.id, int(member))
         new_exp = player.get('experience') + int(value)
         db.execute("UPDATE Characters SET Experience = %s WHERE player_id = %s",
                    (new_exp, player.get('player_id')))
         await ctx.send("Experience added successfully.")
示例#5
0
 async def chess_new(self, ctx):
     player = db.get_player_info(ctx.guild.id, ctx.author.id)
     players = db.get_all_players(ctx.guild.id)
     exist_check = 0
     for person in players:
         if person.get('chess') == ctx.channel.id:
             exist_check = 1
     if player.get('chess') == 0 and exist_check == 0:
         db.execute(
             "UPDATE Characters SET chess = %s WHERE id = %s",
             (ctx.channel.id, player.get('id')),
         )
         await ctx.send("Game lobby created successfully.")
示例#6
0
 async def chess_join(self, ctx):
     players = db.get_all_players(ctx.guild.id)
     for player in players:
         if player.get('chess') == ctx.channel.id:
             p1 = ctx.guild.get_member(player.get('player_id')).display_name
             p2 = ctx.author.display_name
             user = db.get_player_info(ctx.guild.id, ctx.author.id)
             await ctx.send(
                 f"Game prepared in this channel for players: {p1} and {p2}."
             )
             db.execute(
                 "UPDATE Characters SET chess = %s WHERE id = %s",
                 (ctx.channel.id, user.get('id')),
             )
示例#7
0
 async def add_exp_role(self, ctx, role_added: discord.Role, value):
     authorized = False
     guild = db.get_guild_info(ctx.guild.id)
     for role in ctx.author.roles:
         if guild.get("st_id") == role.id:
             authorized = True
     if authorized:
         r_list = role_added.members
         print(r_list)
         for member in r_list:
             player = db.get_player_info(ctx.guild.id, member.id)
             new_exp = player.get('experience') + int(value)
             db.execute("UPDATE Characters SET Experience = %s WHERE player_id = %s AND guild_id = %s",
                        (new_exp, player.get('player_id'), player.get('guild_id')))
         await ctx.send("Experience added successfully.")
示例#8
0
 async def chess_start(self, ctx, white=0):
     player = db.get_player_info(ctx.guild.id, ctx.author.id)
     p_list = db.get_all_players(ctx.guild.id)
     p1 = ctx.author.display_name
     if player.get('chess') == ctx.channel.id:
         for person in p_list:
             p2 = ctx.guild.get_member(player.get('player_id')).display_name
             if person.get('chess') == ctx.channel.id:
                 if white == 0:
                     white = random.randrange(1, 2, 1)
                 if white == 1:
                     await ctx.send(
                         f"Starting game for {p1} and {p2}, {p1} to start as white."
                     )
                 elif white == 2:
                     await ctx.send(
                         f"Starting game for {p1} and {p2}, {p2} to start as white."
                     )
示例#9
0
 async def blood_bag(self):
     for guild in db.get_guild_list():
         guild = db.get_guild_info(guild[0])
         bb_role = self.bot.get_guild(guild.get("guild_id")).get_role(
             guild.get("bb_id")
         )
         bb_members = bb_role.members
         if bb_members is not None:
             for member in bb_members:
                 try:
                     player = db.get_player_info(guild.get("guild_id"), member.id)
                     if player.get("bp") + 1 <= player.get("bp_max"):
                         await self.bot.get_guild(guild.get("guild_id")).get_member(
                             member.id
                         ).remove_roles(bb_role)
                         new_bp = player.get("bp") + 1
                         db.execute(
                             "UPDATE Characters SET bp = %s WHERE id = %s",
                             (new_bp, player.get("id")),
                         )
                 except TypeError:
                     continue
示例#10
0
 async def bp_wp_pop(self, ctx):
     """
     Populates BP/WP database with users in-server. (ST only command)\n\
     Does not affect those who already have entries in the table.\n\
     Will set all values other than their player_id to 0.
     """
     authorized = False
     guild = db.get_guild_info(ctx.guild.id)
     for role in ctx.author.roles:
         if guild.get("st_id") == role.id:
             authorized = True
     if authorized:
         for member in ctx.guild.members:
             if guild.get("player_role") in member.roles:
                 try:
                     exist_check = db.get_player_info(ctx.guild.id, member.id)
                 except TypeError:
                     db.execute(
                         "INSERT INTO Characters (player_id, bp_max, bp, wp_max, wp, upkeep,"
                         "agg_dmg, alert_flag, guild_id) VALUES (%s,5,5,5,5,0,' ', 0,0,%s, 0, 0)",
                         (member.id, guild.get("id")),
                     )
         await ctx.send("Table populated.")
示例#11
0
 async def wp(self, ctx, arg1="none", arg2="none"):
     """
     WP checking and expenditure for all!\n\n\
     There's two versions of this command:\n\
     [+] All players - $wp checks WP level and DMs you, $wp [value] spends [value] BP\n\
     [+] STs and Narrators - $wp [user] checks their WP and DMs you, $wp [user] [value] works similarly.
     """
     if arg1 == "none":
         player = db.get_player_info(ctx.guild.id, ctx.author.id)
         await ctx.author.send(
             f"{ctx.author.mention}'s Willpower: {player.get('wp')}"
         )
     else:
         user_id = None
         try:
             arg1 = int(arg1)
             if arg1 < 0:
                 await ctx.send("Error: Cannot spend negative WP.")
             elif arg1 < 100:
                 mod = arg1
                 player = db.get_player_info(ctx.guild.id, ctx.author.id)
                 if mod > player.get("wp"):
                     await ctx.send("Error: Cannot spend WP in excess of pool.")
                 else:
                     mod = player.get("wp") - mod
                     db.execute(
                         "UPDATE Characters SET wp = %s WHERE id = %s",
                         (mod, player.get("id")),
                     )
                     await ctx.send("Values updated.")
             else:
                 user_id = arg1
         except ValueError:
             try:
                 uid = self.bot.get_user(int(arg1[2:-1])).id
                 if uid is None:
                     await ctx.send("Error: Invalid syntax.")
                 else:
                     user_id = uid
             except ValueError:
                 await ctx.send("Error: Invalid syntax.")
         if user_id is not None:
             authorized = False
             guild = db.get_guild_info(ctx.guild.id)
             for role in ctx.author.roles:
                 if guild.get("st_id") == role.id:
                     authorized = True
                 elif guild.get("narrator_id") == role.id:
                     authorized = True
             if authorized:
                 if arg2 == "none":
                     player = db.get_player_info(ctx.guild.id, user_id)
                     await ctx.author.send(
                         f"{self.bot.get_user(user_id).mention}'s Willpower: {player.get('wp')}"
                     )
                 else:
                     try:
                         mod = int(arg2)
                         if mod < 0:
                             await ctx.send("Error: Cannot spend negative WP.")
                         else:
                             player = db.get_player_info(ctx.guild.id, user_id)
                             if mod > player.get("wp"):
                                 await ctx.send(
                                     "Error: Cannot spend WP in excess of pool."
                                 )
                             else:
                                 mod = player.get("wp") - mod
                                 db.execute(
                                     "UPDATE Characters SET wp = %s WHERE id = %s",
                                     (mod, player.get("id")),
                                 )
                                 await ctx.send("Values updated.")
                     except ValueError:
                         await ctx.send("Error: Invalid syntax.")
示例#12
0
    async def rs(self, ctx, pool: int = 1, diff: int = 6, wp: str = "0", *reason):
        """
        Same as $r except this also applies explosions to the dice.\n\
        Syntax: $rs [Dice Pool] [Difficulty] [wpifier]\n\
        \n\
        Example: $rs 5 7 => [10, 2, 8, 4, 3] [9] Results: 3 Successes!
        """
        st_alert = 0
        reason_string = ""

        if pool < 1:
            pass

        elif diff < 1:
            pass

        else:
            reason = list(reason)
            try:
                wp = int(wp)
            except ValueError:
                reason.insert(0, wp)
                wp = 0
            if not reason:
                reason = ["No reason provided."]
            for word in reason:
                reason_string += word + " "
            reason_string = reason_string[:-1]
            ss = 0
            fail = 0
            tens = 0
            random_raw = []
            for i in range(pool):
                random_raw.append(random.randint(1, 10))
            await ctx.send(random_raw)
            for roll in random_raw:
                if roll >= diff:
                    ss += 1

                elif roll == 1:
                    fail += 1

                if roll == 10:
                    tens += 1
            guild = db.get_guild_info(ctx.guild.id)
            if guild.get("exploding_toggle") == 1:
                if ss <= 0 and wp <= 0:
                    if fail > 0:
                        result = "Botch! | Reason: " + str(reason_string)
                        st_alert = 2

                    else:
                        result = "Failure! | Reason: " + str(reason_string)
                        st_alert = 1

                else:
                    ss -= fail
                    tens -= fail
                    while tens > 0:
                        explosion = []
                        for i in range(tens):
                            explosion.append(random.randint(1, 10))
                        await ctx.send(explosion)
                        ten = 0
                        for roll in explosion:
                            if roll == 10:
                                ten += 1
                                ss += 1
                            elif roll >= diff:
                                ss += 1
                        tens = ten
                    if ss <= 0:
                        ss = wp
                    else:
                        ss += wp

                    if ss <= 0:
                        result = "Failure! | Reason: " + str(reason_string)
                        st_alert = 1
                    else:
                        result = str(ss) + " Successes! | Reason: " + str(reason_string)
            elif guild.get("exploding_toggle") == 0:
                ss += tens
                ss -= fail
                if ss <= 0:
                    ss = wp
                else:
                    ss += wp

                if ss <= 0:
                    result = "Failure! | Reason: " + str(reason_string)
                    st_alert = 1
                else:
                    result = str(ss) + " Successes! | Reason: " + str(reason_string)

            await ctx.send("{} - Results: ".format(ctx.author.mention) + result)
            if ctx.channel.id == guild.get("feeding_chan"):
                net_ss = ss - fail
                if net_ss < 0:
                    net_ss = wp
                player = db.get_player_info(ctx.guild.id, ctx.author.id)
                current_bp = player.get("bp")
                bp_max = player.get("bp_max")
                new_bp = current_bp + net_ss
                if new_bp > bp_max:
                    new_bp = bp_max
                db.execute(
                    "UPDATE Characters SET bp = %s WHERE id = %s",
                    (new_bp, player.get("id")),
                )
                if st_alert == 1:
                    await self.bot.get_channel(guild.get("st_alerts_chan")).send(
                        "{} failed a feeding roll!".format(ctx.author.mention)
                    )
                elif st_alert == 2:
                    await self.bot.get_channel(guild.get("st_alerts_chan")).send(
                        "{} botched a feeding roll!".format(ctx.author.mention)
                    )
示例#13
0
    async def r(self, ctx, pool: int = 1, diff: int = 6, wp: str = "0", *reason):
        """
        Rolls and checks successes.\n\
        Syntax: $r [Dice Pool] [Difficulty] [modifier]\n\
        \n\
        Example: $r 5 7 => [5, 2, 8, 4, 3] Results: 1 Successes!
        """
        alert_st = 0
        reason_string = ""
        if pool < 1:
            pass

        elif diff < 1:
            pass

        else:
            reason = list(reason)
            try:
                wp = int(wp)
            except ValueError:
                reason.insert(0, wp)
                wp = 0
            if not reason:
                reason = ["No reason provided."]
            for word in reason:
                reason_string += word + " "
            reason_string = reason_string[:-1]
            ss = 0
            fail = 0
            random_raw = []
            for i in range(pool):
                random_raw.append(random.randint(1, 10))
            await ctx.send(random_raw)
            for roll in random_raw:
                if roll >= diff:
                    ss += 1

                if roll == 1:
                    fail += 1

            if ss <= 0 and wp <= 0:
                if fail > 0:
                    result = "Botch! | Reason: " + str(reason_string)
                    alert_st = 2

                else:
                    result = "Failure! | Reason: " + str(reason_string)
                    alert_st = 1

            elif ss - fail <= 0 < ss and wp <= 0:
                result = "Failure! | Reason: " + str(reason_string)
                alert_st = 1

            else:
                ss += wp
                if ss - fail > 0:
                    result = (
                        str(ss - fail) + " successes! | Reason: " + str(reason_string)
                    )
                else:
                    result = (
                        "{} successes!".format(str(wp))
                        + " | Reason: "
                        + str(reason_string)
                    )
            await ctx.send("{} - Results: ".format(ctx.author.mention) + result)
            guild = db.get_guild_info(ctx.guild.id)
            if ctx.channel.id == guild.get("feeding_chan"):
                net_ss = ss - fail
                if net_ss < 0:
                    net_ss = wp
                player = db.get_player_info(ctx.guild.id, ctx.author.id)
                current_bp = player.get("bp")
                bp_max = player.get("bp_max")
                new_bp = current_bp + net_ss
                if new_bp > bp_max:
                    new_bp = bp_max
                db.execute(
                    "UPDATE Characters SET bp = %s WHERE id = %s",
                    (new_bp, player.get("id")),
                )
                if alert_st == 1:
                    await self.bot.get_channel(guild.get("st_alerts_chan")).send(
                        "{} failed a feeding roll!".format(ctx.author.mention)
                    )
                elif alert_st == 2:
                    await self.bot.get_channel(guild.get("st_alerts_chan")).send(
                        "{} botched a feeding roll!".format(ctx.author.mention)
                    )