Example #1
0
def get_boss(ctx):
    channel_status = db.boss_status.get_st(ctx.channel.id)
    if not channel_status:
        boss_lv = 1
        monster = monsters.get(boss_lv)
        monster[1]["HP"] = monster[1]["HP"].replace("boss_level", str(boss_lv))
        db.boss_status.set_st(ctx, monster[0], boss_lv,
                              str_calc.calc(monster[1]["HP"]))
        channel_status = [boss_lv, str_calc.calc(monster[1]["HP"]), monster[0]]
    return channel_status
Example #2
0
 async def _attack(self, ctx):
     user_id = ctx.author.id
     channel_id = ctx.channel.id
     player_hp, error_message = await battle.Battle(self.bot).into_battle(
         user_id, channel_id)
     if error_message:
         return await ctx.send(embed=Embed(description=error_message))
     player_level = status.get_player_level(user_id)
     boss_level, boss_hp, boss_id = battle.get_boss(ctx)
     rand = random.random()
     player_attack = battle.get_player_attack(player_level, boss_level,
                                              boss_id, rand)
     boss_hp = boss_hp - player_attack
     from module import monsters
     monster_name = monsters.get(boss_level, boss_id)[1]["name"]
     attack_message = battle.get_attack_message(user_id, player_attack,
                                                monster_name, rand)
     if boss_hp <= 0:
         win_message = battle.win_process(channel_id, boss_level,
                                          monster_name)
         await ctx.send(embed=Embed(
             description="{}\n{}".format(attack_message, win_message)))
         await battle.reset_battle(ctx, level_up=True)
     else:
         db.boss_status.update(boss_hp, channel_id)
         boss_attack_message = battle.boss_attack_process(
             ctx, player_hp, player_level, monster_name)
         monster = monsters.get(boss_level, boss_id)[1]
         monster["HP"] = monster["HP"].replace("boss_level",
                                               str(boss_level))
         effect = await battle.Battle(self.bot).effect(ctx, monster)
         await ctx.send(embed=Embed(
             description="{}\n - {}のHP:`{}`/{}\n\n{}".format(
                 attack_message, monster_name, boss_hp, calc(monster["HP"]),
                 boss_attack_message) + effect))
Example #3
0
async def reset_battle(ctx, level_up=False):
    db.channel.end_battle(ctx.channel.id, level_up)
    boss_lv, boss_hp, boss_id = get_boss(ctx)
    from module import monsters
    monster = monsters.get(boss_lv, boss_id)
    boss_lv += level_up
    monster = monsters.get(
        boss_lv, None if
        (monster[1].get("canReset") == "True" or level_up) else boss_id)
    from module.str_calc import calc
    monster[1]["HP"] = monster[1]["HP"].replace("boss_level", str(boss_lv))
    db.boss_status.set_st(ctx, monster[0], boss_lv, calc(monster[1]["HP"]))
    em = discord.Embed(title="{}が待ち構えている...!\nLv.{}  HP:{}".format(
        monster[1]["name"], boss_lv, calc(monster[1]["HP"])))
    em.set_image(
        url=f"{db.CONFIG_ROOT}Discord/FFM/img/{monster[1].get('img','404.png')}"
    )
    await ctx.send(embed=em)
Example #4
0
def win_process(channel_id, boss_level, monster_name):
    battle_members = [m for m in db.channel.all_player(channel_id)]
    level_up_comments = []
    members = ""
    fire_members = ""
    elixir_members = ""
    pray_members = ""
    boss_lv, _, boss_id = db.boss_status.get_st(channel_id)
    monster = monsters.get(boss_lv, boss_id)[1]
    monster["exp"] = monster["exp"].replace("boss_level", str(boss_lv))
    exp = str_calc.calc(monster["exp"])
    for battle_member in battle_members:
        member_id = battle_member[0]
        level_up_comments.append(status.experiment(member_id, exp))
        members += "<@{}> ".format(member_id)
        p = min(
            0.02 * boss_level * boss_level /
            db.player.experience.get(member_id), 0.1)
        if boss_level % 10 == 0 and random.random() < p:
            elixir_members += "<@{}> ".format(member_id)
            item.obtain_an_item(member_id, 1)
        if random.random() < p:
            fire_members += "<@{}> ".format(member_id)
            item.obtain_an_item(member_id, 2)
        if random.random() < p * 2:
            pray_members += "<@{}> ".format(member_id)
            item.obtain_an_item(member_id, 3)
    if fire_members:
        fire_members += "は`ファイアボールの書`を手に入れた!"
    if elixir_members:
        elixir_members += "は`エリクサー`を手に入れた!"
    if pray_members:
        pray_members += "は`祈りの書`を手に入れた!"
    level_up_comment = "\n".join([c for c in level_up_comments if c])
    item_get = "\n".join(c
                         for c in [elixir_members, fire_members, pray_members]
                         if c)
    msg = "{0}を倒した!\n\n{1}は`{2}`の経験値を得た。\n{3}\n{4}".format(
        monster_name, members, exp, level_up_comment, item_get)
    return ("勝利メッセージが2000文字を超えたので表示できません" if len(msg) > 2000 else msg)
Example #5
0
def get_boss_attack(ctx):
    boss_lv, _, boss_id = db.boss_status.get_st(ctx.channel.id)
    monster = monsters.get(boss_lv, boss_id)[1]
    monster["ATK"] = monster["ATK"].replace("boss_level", str(boss_lv))
    return str_calc.calc(monster["ATK"])