Ejemplo n.º 1
0
def change_player_class(author_id, author_name, player_class_id):
    players = DataManager.read_players()
    try:
        # Find the current player
        player = next(player for player in players if player.id == author_id)
        if player.class_type == 8:
            return False
        player.name = str(author_name)[:-5]
        player.class_type = player_class_id
        if player.class_type == 2:
            player.next_reap = time.time() + GameStat.reap_cooldown * (
                1 - GameStat.mage_reduction_rate)
        else:
            player.next_reap = time.time() + GameStat.reap_cooldown
        DataManager.write_players(players, latest_clear)
        DataManager.update_logs_class(player.name,
                                      GameStat.class_name[player_class_id],
                                      True)
    except StopIteration:
        # Player doesn't exist in our logs
        player = GameStat.Player("{}|{}|{}|{}|{}|{}".format(
            author_id,
            str(author_name)[:-5], 0, time.time(), 0, player_class_id))
        players.append(player)
        DataManager.write_players(players, latest_clear)
        DataManager.update_logs_class(player.name,
                                      GameStat.class_name[player_class_id])
    return True
Ejemplo n.º 2
0
def roll_shell(added_time, players, author):
    reap_message = ""
    if random.random() < GameStat.blue_shell_chance and len(players) > 3:
        # compose blue shell message
        reap_message += "\n{} BLUE SHELL ACTIVATED {}\n**{}** lost *{}*\n**{}** lost *{}*\n**{}** lost *{}*"\
            .format(GameStat.blue_shell_icon, GameStat.blue_shell_icon,
                    players[0].name, seconds_format(added_time),
                    players[1].name, seconds_format(added_time * 0.75),
                    players[2].name, seconds_format(added_time * 0.5),)
        # calculate damage
        players[0].reaped_time -= added_time
        players[1].reaped_time -= added_time * 0.75
        players[2].reaped_time -= added_time * 0.5
        DataManager.update_logs_shell(str(author)[:-5], seconds_format(added_time))
    return reap_message
Ejemplo n.º 3
0
async def check_player(ctx):
    print("- Check by {} -".format(ctx.message.author))
    if maintenance:
        await bot.say("Sorry currently under maintenance")
        return None

    # Bot detection
    if ctx.message.author.bot:
        await bot.say("bot detected, command canceled")
        return None

    # find player

    author_id = ctx.message.author.id
    try:
        players = DataManager.read_players()
        player = next(player for player in players if player.id == author_id)
    except StopIteration:
        # We couldn't find the player, so create a new one and insert it into players
        await bot.say("Looks like you never played before~\nUse **t!start** to get started~")
        return None

    current_time = time.time()

    # check for cooldown
    if current_time < player.next_reap:
        await bot.say("""Sorry, actions is still on cooldown
                      please wait another **{} hours {} minutes and {} seconds**
                      """.format(*hms(player.next_reap - current_time)))
        return None

    return player, players
Ejemplo n.º 4
0
async def steal(ctx):
    # unique thief steal command
    player_package = await check_player(ctx)
    if player_package is None:
        return
    player = player_package[0]
    players = player_package[1]

    global reap_in_progress

    if player is None:
        return
    if player.class_type != 5:
        await ctx.message.channel.send(
            "Sorry **t!steal** is Only Allowed for the Dimensional Bandits")
        return
    if reap_in_progress == 0:
        await ctx.message.channel.send(
            "Sorry no One is Reaping Right Now\nUse **t!reap** to do so")
        return

    global thief_id
    thief_id = ctx.message.author

    author = ctx.message.author.display_name
    current_time = time.time()
    player.reaped_time += reap_in_progress
    player.reap_count += 1
    player.next_reap = current_time + GameStat.reap_cooldown
    player.name = str(author)[:-5]
    reap_message = '<@!{}> has *STOLEN* **{}** to their total\n' \
                   'Adding up to be **{}**\nNext reap in **{}**' \
        .format(ctx.message.author.id, seconds_format(reap_in_progress), seconds_format(player.reaped_time),
                "{} hours and {} minutes".format(*hms(player.next_reap - current_time)))

    global latest_clear
    await ctx.message.channel.send(reap_message)
    # Strip out the last five characters (the #NNNN part)
    DataManager.update_logs_reap(str(author)[:-5],
                                 seconds_format(reap_in_progress),
                                 player.class_type,
                                 stolen=reap_name)
    latest_clear = current_time
    await update_time_status()
    DataManager.write_players(players, latest_clear)
    reap_in_progress = 0
Ejemplo n.º 5
0
def generate_leaderboard_embed(start_rank, season=GameStat.current_season):
    players = DataManager.read_players(season)[start_rank - 1:start_rank + 9]
    if len(players) == 0:
        return None
    embed = discord.Embed(color=0x42d7f4)

    # determine title
    if season == GameStat.current_season:
        if start_rank == 1:
            embed.title = "The Current Top {} Are!!!".format(len(players))
        else:
            embed.title = "The {} to {} Place are:".format(
                start_rank, start_rank + len(players) - 1)
        embed.set_footer(
            text="Rank: {} - {}".format(start_rank, start_rank + len(players) -
                                        1))
    else:
        if start_rank == 1:
            embed.title = "The Season {}: Top {} Are!".format(
                season, len(players))
        else:
            embed.title = "The Season {}: {} to {} Place are:".format(
                season, start_rank, start_rank + len(players) - 1)
        embed.set_footer(text="Season {} Rank: {} - {}".format(
            season, start_rank, start_rank + len(players) - 1))

    # cycle through players
    for index, player in enumerate(players):
        # Drop the number at the end of the author's name (#NNNN)
        player_title = player.name

        # sets the icons if it's current_season
        if season >= 4:  # the season where classes are introduced
            if player.id in GameStat.reward_icons.keys():
                player_title += " " + GameStat.reward_icons[player.id]

            player_class_type = GameStat.class_name_short[player.class_type]
            embed.add_field(name='*#{}* {}: {}'.format(index + start_rank,
                                                       player_class_type,
                                                       player_title),
                            value=seconds_format(player.reaped_time))
        else:
            embed.add_field(name='*#{}* {}'.format(index + start_rank,
                                                   player_title),
                            value=seconds_format(player.reaped_time))
    return embed
Ejemplo n.º 6
0
async def print_info(channel, user_id=0, user_rank=0):
    if notice_message != "":
        await bot.send_message(channel, notice_message)

    players = DataManager.read_players()
    if user_id != 0:
        try:
            # Find the current player
            index, player = next((index, player) for index, player in enumerate(players) if player.id == user_id)
        except StopIteration:
            # Player doesn't exist in our logs, so tell them to reap
            await bot.send_message(channel, """<@!{}> has stored 0 seconds
                                use t!reap to get started""".format(user_id))
            return
    elif user_rank != 0:
        user_rank = int(user_rank)
        try:
            # Find the current player
            index, player = next((index, player) for index, player in enumerate(players) if index+1 == user_rank)
        except StopIteration:
            # Player doesn't exist in our logs, so tell them to reap
            await bot.send_message(channel, """<@!{}> has stored 0 seconds
                                use t!reap to get started""".format(user_id))
            return

    current_time = float(time.time())
    if current_time < player.next_reap:
        next_reap = seconds_format(player.next_reap - current_time)
    else:
        next_reap = 'Your next reap is up'

    average_reap = seconds_format(0 if (player.reap_count == 0) else player.reaped_time / player.reap_count)
    # in case of div by zero
    embed = discord.Embed(color=0xfc795c)
    embed.add_field(name="Stats of *{}*" .format(player.name), value="""
    **Class:** {}
    **Rank:** {}
    **Stored Time:** {}
    **Average Reap:** {}
    **Reap Count:** {}
    **Next Reap:** {}
    """.format(GameStat.class_name[player.class_type], index + 1,
               seconds_format(player.reaped_time), average_reap,
               int(player.reap_count), next_reap))
    await bot.say(embed=embed)
Ejemplo n.º 7
0
async def reap(ctx):
    global reap_in_progress
    player_package = await check_player(ctx)
    if player_package is None:
        return
    player = player_package[0]
    players = player_package[1]
    if reap_in_progress != 0:
        await bot.say("Reap is Currently In Progress \nBandits are allowed to steal with *t!steal*")
        return

    global latest_clear
    current_time = time.time()
    added_time = current_time - latest_clear
    reap_message = ""

    author = ctx.message.author
    player.reap_count += 1
    player.next_reap = current_time + GameStat.reap_cooldown
    player.name = str(author)[:-5]
    reap_delay = 60

    # --------------------- Unique Class Passive ------------------
    if player.class_type == 1:
        added_time *= GameStat.warrior_buff
        reap_message += '**HEROIC STRIKE ACTIVATED!**\n Reap Time Increased to {}%\n'\
            .format(GameStat.warrior_buff * 100)

    elif player.class_type == 2:
        reap_message += '**TIME WARP ACTIVATED!**\n Reap Cooldown Reduced by {}%\n'\
            .format(GameStat.mage_reduction_rate * 100)
        player.next_reap = current_time + GameStat.reap_cooldown * (1 - GameStat.mage_reduction_rate)

    elif player.class_type == 3:
        if random.random() < GameStat.hunter_crit_rate:
            added_time *= 2
            reap_message += '**HUNTER\'S MARK ACTIVATED!**\n Reap Time Increased to {}%\n'\
                .format(GameStat.hunter_crit_dmg * 100)
        else:
            reap_message += '**HUNTER\'S MARK FAILED!**\n Reap Time Gains No Modifier\n'

    elif player.class_type == 4:
        added_time += GameStat.fairy_boost * 60
        reap_message += '**WILD GROWTH ACTIVATED!**\n Reap Time Increased by {}M\n'.format(GameStat.fairy_boost)

    elif player.class_type == 6:
        reap_delay = 0
        reap_message += '**BLINDING ASSAULT ACTIVATED!**\n Instant Reap Complete\n'

    elif player.class_type == 7:
        if random.random() < GameStat.gamble_chance:
            reap_delay = 0
            added_time *= GameStat.gamble_reward
            for win in range(3):
                reap_message += '**💰!!!LUCKY COIN ACTIVATED!!!💰**\n Reap Time Increased to {}%!!!\n'\
                    .format(GameStat.gamble_reward * 100)
            # DataManager.update_logs_win(True, "GAMBLE")
        else:
            msg = '**LUCKY COIN FAILED**\n{} Minutes has Been Lost\n'.format(GameStat.gamble_cost) \
                  + roll_shell(added_time, players, author)
            player.reaped_time -= GameStat.gamble_cost * 60
            await bot.say(msg)
            DataManager.write_players(players, latest_clear)
            DataManager.update_logs_win(False, "GAMBLE", str(author)[:-5], seconds_format(added_time))
            return

    elif player.class_type == 8:
        if random.random() < GameStat.voyage_chance:
            reap_delay = 0
            added_time *= GameStat.voyage_reward
            for win in range(20):
                reap_message += '**🌌!!!ABYSSAL VOYAGE SUCCESSFUL!!!🌌**\n Reap Time Increased to {}%!!!\n'\
                    .format(GameStat.voyage_reward * 100)
            DataManager.update_logs_win(True, "VOYAGE")
        else:
            msg = '**ABYSSAL VOYAGE FAILED**\n🌌There is Nothing in the Abyss🌌\n' + roll_shell(added_time, players, author)
            await bot.say(msg)
            DataManager.write_players(players, latest_clear)
            DataManager.update_logs_win(False, "VOYAGE", str(author)[:-5], seconds_format(added_time))
            return

    DataManager.write_players(players, latest_clear)

    # ------------------------------- Initialize Reaping -------------------------
    reap_in_progress = added_time
    reap_lockin_message = await bot.say("Reap Initiated, Will be Completed in 60 Seconds")
    await bot.change_presence(game=discord.Game(name='⚔️Reaping: {}'.format("{}H {}M {}S".format(*hms(added_time)))))
    while reap_delay > 0:
        if reap_in_progress != 0:
            await asyncio.sleep(5)
            reap_delay -= 5
            try:
                await bot.edit_message(reap_lockin_message, "Reap Initiated, Will be Completed in {} Seconds"
                                                            "".format(reap_delay))
            except discord.errors.NotFound:
                reap_lockin_message = await bot.say("Reap Initiated, Will be Completed in {} Seconds"
                                                    "".format(reap_delay))
        else:
            await bot.edit_message(reap_lockin_message, "<@!{}> Your Reap Has Been *STOLEN* by {}"
                                   .format(player.id, str(thief_id)[:-5]))
            return

    await bot.edit_message(reap_lockin_message, "Reap Successful")

    reap_in_progress = 0
    # --------------------- Store Data ------------------
    player.reaped_time = math.floor(player.reaped_time + added_time)
    reap_message += '<@!{}> has added **{}** to their total\n' \
                    'Adding up to be **{}**\nNext reap in **{}**\n'\
        .format(author.id, seconds_format(added_time), seconds_format(player.reaped_time),
                "{} hours and {} minutes".format(*hms(player.next_reap - current_time)))

    # --------------------- Roll Shell ------------------
    reap_message += roll_shell(added_time, players, author)

    await bot.say(reap_message)
    # Strip out the last five characters (the #NNNN part)
    DataManager.update_logs_reap(str(author)[:-5], seconds_format(added_time), player.class_type)
    latest_clear = current_time

    DataManager.write_players(players, latest_clear)
    print("reap by {} with {}".format(author, math.floor(added_time)))
    # await start_timer()
    await update_time_status()
Ejemplo n.º 8
0
async def print_info(channel, user_id=0, user_rank=0):
    players = DataManager.read_players()
    player = None
    index = 0

    if user_id != 0:  # Check by ID
        try:
            # Find the current player
            index, player = next((index, player)
                                 for index, player in enumerate(players)
                                 if player.id == user_id)
        except StopIteration:
            # Player doesn't exist in our logs, so tell them to reap
            await channel.send("""<@!{}> has stored 0 seconds
                                use t!reap to get started""".format(user_id))
            return
    elif user_rank != 0:  # Check by Rank
        user_rank = int(user_rank)
        try:
            # Find the current player
            index, player = next((index, player)
                                 for index, player in enumerate(players)
                                 if index + 1 == user_rank)
        except StopIteration:
            # Player doesn't exist in our logs, so tell them to reap
            await channel.send("""<@!{}> has stored 0 seconds
                                use t!reap to get started""".format(user_id))
            return

    # Initiate Data
    current_time = float(time.time())
    if current_time < player.next_reap:
        next_reap = seconds_format(player.next_reap - current_time)
    else:
        if player.class_type == 11:
            next_reap = "Your next reap is available ({}%)".format(
                round((current_time - player.next_reap) / 864 *
                      GameStat.capacitor_boost) + 100)
        else:
            next_reap = 'Your next reap is available'

    average_reap = seconds_format(0 if (
        player.reap_count == 0) else player.reaped_time / player.reap_count)
    # in case of div by zero
    embed = discord.Embed(color=0xfc795c)
    embed.add_field(name="Stats of *{}*".format(player.name),
                    value="""
    **Class:** {}
    **Rank:** {}
    **Stored Time:** {}
    **Average Reap:** {}
    **Reap Count:** {}
    **Next Reap:** {}
    {}
    """.format(
                        GameStat.class_name[player.class_type], index + 1,
                        seconds_format(player.reaped_time), average_reap,
                        int(player.reap_count), next_reap,
                        player.get_class_data(
                            GameStat.class_data_info[player.class_type].format(
                                player.class_data))))

    await channel.send(content=notice_message, embed=embed)
Ejemplo n.º 9
0
async def reap(ctx):
    global reap_in_progress
    player_package = await check_player(ctx)
    if player_package is None:
        return
    player = player_package[0]
    players = player_package[1]
    if reap_in_progress != 0:
        await ctx.message.channel.send(
            "Reap is Currently In Progress \nBandits are allowed to steal with *t!steal*"
        )
        return

    global latest_clear
    current_time = time.time()
    added_time = current_time - latest_clear
    reap_message = ""

    author = ctx.message.author
    player.reap_count += 1
    player.next_reap = current_time + GameStat.reap_cooldown
    player.name = str(author)[:-5]
    reap_await = current_time - player.next_reap
    reap_delay = 60

    # --------------------- Unique Class Passive ------------------
    if player.class_type == 1:  # ---------------------------- Warrior ------------------------------
        added_time *= GameStat.warrior_buff
        reap_message += '**HEROIC STRIKE ACTIVATED!**\n Reap Time Increased to {}%\n' \
            .format(GameStat.warrior_buff * 100)
        player.class_data += (added_time * (GameStat.warrior_buff - 1)) / 3600

    elif player.class_type == 2:  # ---------------------------- Mage ------------------------------
        reap_message += '**TIME WARP ACTIVATED!**\n Reap Cooldown Reduced by {}%\n' \
            .format(GameStat.mage_reduction_rate * 100)
        player.next_reap = current_time + GameStat.reap_cooldown * (
            1 - GameStat.mage_reduction_rate)
        player.class_data += (GameStat.reap_cooldown - reap_await) / 3600

    elif player.class_type == 3:  # ---------------------------- Hunter ------------------------------
        if random.random() < GameStat.hunter_crit_rate:
            added_time *= 2
            reap_message += '**HUNTER\'S MARK ACTIVATED!**\n Reap Time Increased to {}%\n' \
                .format(GameStat.hunter_crit_dmg * 100)
            player.class_data += 1
        else:
            reap_message += '**HUNTER\'S MARK FAILED!**\n Reap Time Gains No Modifier\n'

    elif player.class_type == 4:  # ---------------------------- Fairy ------------------------------
        added_time += GameStat.fairy_boost * 60
        reap_message += '**WILD GROWTH ACTIVATED!**\n Reap Time Increased by {}M\n'.format(
            GameStat.fairy_boost)
        player.class_data += GameStat.fairy_boost / 60

    elif player.class_type == 6:  # ---------------------------- Merc ------------------------------
        reap_delay = 0
        reap_message += '**BLINDING ASSAULT ACTIVATED!**\n Instant Reap Complete\n'

    elif player.class_type == 7:  # ---------------------------- Gambler ------------------------------
        if random.random() < GameStat.gamble_chance:
            reap_delay = 0
            added_time *= GameStat.gamble_reward
            for win in range(3):
                reap_message += '**💰!!!LUCKY COIN ACTIVATED!!!💰**\n Reap Time Increased to {}%!!!\n' \
                    .format(GameStat.gamble_reward * 100)

            player.class_data += 1
        else:
            msg = '**LUCKY COIN FAILED**\n{} Minutes has Been Lost\n'.format(GameStat.gamble_cost) \
                  + roll_shell(added_time, players, author)
            player.reaped_time -= GameStat.gamble_cost * 60
            await ctx.message.channel.send(msg)
            latest_clear = current_time
            DataManager.write_players(players, latest_clear)
            DataManager.update_logs_win(False, "GAMBLE",
                                        str(author)[:-5],
                                        seconds_format(added_time))
            await update_time_status()
            return

    elif player.class_type == 8:  # ---------------------------- Voyager ------------------------------
        if random.random() < GameStat.voyage_chance:
            reap_delay = 0
            added_time *= GameStat.voyage_reward
            for win in range(20):
                reap_message += '**🌌!!!ABYSSAL VOYAGE SUCCESSFUL!!!🌌**\n Reap Time Increased to {}%!!!\n' \
                    .format(GameStat.voyage_reward * 100)
            DataManager.update_logs_win(True, "VOYAGE")
        else:
            player.class_data += added_time * (1 - GameStat.voyage_reduction)
            added_time *= GameStat.voyage_reduction
            reap_message += '**' + GameStat.get_voyage_msg() + '**\n Reap Time Reduced to {}%\n' \
                .format(GameStat.voyage_reduction * 100)

    elif player.class_type == 9:
        if added_time > GameStat.sniper_threshold:
            reap_message += '**COSMIC SHOT LANDED!**\n Reap Cooldown Reset\n'
            player.next_reap = current_time
            player.class_data += 1
        else:
            reap_message += '**Cosmic Shot Missed**\n Reap Cooldown Not Affected\n'

    elif player.class_type == 10:
        reward = GameStat.striker_max_reward - reap_await / 60 * GameStat.striker_reward_drop
        if reward > 1:
            reap_message += '**MOMENTUM STABLE!**\n Reap Time Increased to {}%\n' \
                .format(round(reward * 100))
            added_time *= reward
            player.class_data += 1
        else:
            reap_message += '**Momentum Lost**\n Reap Time Not Affected\n'

    elif player.class_type == 11:
        player.class_data += reap_await / 3600

        reward = reap_await / 86400 * GameStat.capacitor_boost + 1
        reap_message += '**CAPACITOR DISCHARGE!**\n Reap Time Increased to {}%\n' \
            .format(round(reward * 100))
        added_time *= reward

    DataManager.write_players(players, latest_clear)
    reap_in_progress = added_time
    global reap_name
    reap_name = player.name
    # ------------------------------- Initialize Reaping -------------------------
    reap_lockin_message = await ctx.message.channel.send(
        "Reap Initiated, Will be Completed in 60 Seconds")
    await bot.change_presence(activity=discord.Game(
        name='⚔️Reaping: {}'.format("{}H {}M {}S".format(*hms(added_time)))))

    fun_fact = GameStat.get_fun_fact()
    while reap_delay > 0:
        if reap_in_progress != 0:
            await asyncio.sleep(5)
            reap_delay -= 5
            try:
                await reap_lockin_message.edit(
                    content=
                    "Reap Initiated, Will be Completed in {} Seconds\nFun Fact: {}"
                    "".format(reap_delay, fun_fact))
            except discord.errors.NotFound:
                reap_lockin_message = await ctx.message.channel.send(
                    "Reap Initiated, Will be Completed in {} Seconds".format(
                        reap_delay))
        else:
            await reap_lockin_message.edit(
                content="<@!{}> Your Reap Has Been *STOLEN* by {}".format(
                    player.id,
                    str(thief_id)[:-5]))
            return

    await reap_lockin_message.edit(content="Reap Successful")

    reap_in_progress = 0
    # --------------------- Store Data ------------------
    player.reaped_time = math.floor(player.reaped_time + added_time)
    reap_message += '<@!{}> has added **{}** to their total\n' \
                    'Adding up to be **{}**\nNext reap in **{}**\n' \
        .format(author.id, seconds_format(added_time), seconds_format(player.reaped_time),
                "{} hours and {} minutes".format(*hms(player.next_reap - current_time)))

    # --------------------- Roll Shell ------------------
    reap_message += roll_shell(added_time, players, author)

    await ctx.message.channel.send(reap_message)
    # Strip out the last five characters (the #NNNN part)
    DataManager.update_logs_reap(
        str(author)[:-5], seconds_format(added_time), player.class_type)
    latest_clear = current_time

    DataManager.write_players(players, latest_clear)
    print("reap by {} with {}".format(author, math.floor(added_time)))
    # await start_timer()
    await update_time_status()