Пример #1
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))
Пример #2
0
 async def pray(self, ctx, mentions: discord.Member = None):
     user_id, channel_id = ctx.message.author.id, ctx.message.channel.id
     if not mentions:
         return await ctx.send(
             "祈りの書は仲間を復活させます。祈る相手を指定して使います。\n例)!!item 祈りの書 @ユーザー名")
     prayed_user_id = mentions.id
     prayed_user = db.player.hp.get(prayed_user_id, channel_id)
     if not prayed_user:
         return await ctx.send("<@{}>は戦闘に参加していない!".format(prayed_user_id))
     if prayed_user[0] != 0:
         return await ctx.send("<@{}>はまだ生きている!".format(prayed_user_id))
     player_hp, error_message = await battle.Battle(self.bot).into_battle(
         user_id, channel_id)
     if error_message:
         return error_message
     if not consume_an_item(user_id, 3):
         return await ctx.send("<@{}>は祈りの書を持っていない!".format(user_id))
     db.player.hp.update(1, prayed_user_id)
     await ctx.send("<@{0}>は祈りを捧げ、<@{1}>は復活した!\n<@{1}> 残りHP: 1".format(
         user_id,
         prayed_user_id,
     ))
     boss_lv, _, boss_id = battle.get_boss(ctx)
     monster = monsters.get(boss_lv, boss_id)[1]
     await battle.Battle(self.bot).effect(ctx, monster)
Пример #3
0
 async def fireball(self, ctx):
     user_id, channel_id = ctx.message.author.id, ctx.message.channel.id
     player_hp, error_message = await battle.Battle(self.bot).into_battle(
         user_id, channel_id)
     if error_message:
         return await ctx.send(error_message)
     if not consume_an_item(user_id, 2):
         return await ctx.send(f"<@{user_id}>はファイアボールの書を持っていない!")
     player_level = status.get_player_level(user_id)
     boss_lv, boss_hp, boss_id = battle.get_boss(ctx)
     player_attack = int(player_level * (1 + random.random()) / 10)
     boss_hp = boss_hp - player_attack
     monster = monsters.get(boss_lv, boss_id)[1]
     monster_name = monster["name"]
     attack_message = "ファイアボール!<@{}>は{}に`{}`のダメージを与えた!".format(
         user_id, monster_name, player_attack)
     if boss_hp <= 0:
         win_message = battle.win_process(channel_id, boss_lv, monster_name)
         await ctx.send("{}\n{}".format(attack_message, win_message))
         await battle.reset_battle(ctx, level_up=True)
     else:
         db.boss_status.update(boss_hp, channel_id)
         await ctx.send("{}\n{}のHP:`{}`/{}".format(attack_message,
                                                   monster_name, boss_hp,
                                                   boss_lv * 10 + 50))
         await battle.Battle(self.bot).effect(ctx, monster)
Пример #4
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)
Пример #5
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
Пример #6
0
 async def elixir(self, ctx):
     user_id = ctx.message.author.id
     channel_id = ctx.message.channel.id
     if not consume_an_item(user_id, 1):
         return await ctx.send("<@{}>はエリクサーを持っていない!".format(user_id))
     in_battles = db.channel.all_battle_player(channel_id)
     for in_battle in in_battles:
         full_hp = int(math.sqrt(in_battle[1])) * 5 + 50
         db.player.hp.update(full_hp, in_battle[0])
     await ctx.send("<@{}>はエリクサーを使った!このチャンネルの仲間全員が全回復した!".format(user_id))
     boss_lv, _, boss_id = battle.get_boss(ctx)
     monster = monsters.get(boss_lv, boss_id)[1]
     await battle.Battle(self.bot).effect(ctx, monster)
Пример #7
0
def get_player_attack(player_level, boss_level, boss_id, rand):
    boss = monsters.get(boss_level, boss_id)
    if rand < boss[1]["Evasion rate"]:
        player_attack = 0
    elif boss_level % MONSTER_NUM in [3, 11, 17, 32, 41]:
        plus = rand / 3 + 0.5 if rand < 0.96 else 3
        player_attack = int(player_level * plus + 10)
    elif boss_level % 5 == 0:
        plus = rand / 2 + 0.8 if rand < 0.96 else 3
        player_attack = int(player_level * plus + 10)
    else:
        plus = rand / 2 + 1 if rand < 0.96 else 3
        player_attack = int(player_level * plus + 10)
    return player_attack
Пример #8
0
 async def kill(self, ctx):
     if all((x in USERs.get(str(ctx.author.id), []))
            for x in ["Cheater", "Debugger"]):
         player_hp, error_message = await battle.Battle(
             self.bot).into_battle(ctx.author.id, ctx.channel.id)
         if error_message:
             return await ctx.send(error_message)
         boss_level, boss_hp, boss_id = battle.get_boss(ctx)
         monster_name = monsters.get(boss_level, boss_id)[1]["name"]
         attack_message = battle.get_attack_message(ctx.author.id, boss_hp,
                                                    monster_name, 2)
         win_message = battle.win_process(ctx.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)
Пример #9
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)
Пример #10
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"])
Пример #11
0
 async def boss(self, ctx):
     if all((x in USERs.get(str(ctx.author.id), []))
            for x in ["Cheater", "Debugger"]):
         boss_level, _, boss_id = battle.get_boss(ctx)
         await ctx.send(str(monsters.get(boss_level, boss_id)),
                        delete_after=10)