Пример #1
0
async def magic_5(player,mob,final=False):
    ch = mob.mob
    if player.magic_lv() < 4000:
        em = discord.Embed(description=f"熟練度が足りないようだ…")
        await ch.send(embed=em)
        return
    if player.now_mp < 10:
        em=discord.Embed(description="MPが足りないようだ…")
        await ch.send(embed=em)
        return
    soul_fire_num = battle.pg.fetchdict(f"select item from player_tb where id = {player.ID()};")[0]["item"]["魂の焔"]
    if soul_fire_num < 32:
        em=discord.Embed(description="触媒が足りないようだ…")
        await ch.send(embed=em)
        return
    if final:
        if soul_fire_num < 100:
            em=discord.Embed(description="触媒が足りないようだ…")
            await ch.send(embed=em)
            return
        magic_name = "ᶠ ᵢ ⁿ ₐ ᶪ ᴤ ᵖ ₐ ᵣ ᵏ"
        use_num = soul_fire_num
        up_num = 10 + ((player.magic_lv()-4000)/100000) + (use_num/100)
    elif not final:
        magic_name = "MasterSpark"
        use_num = 32
        up_num = min(10 + ((player.magic_lv()-4000)/100000),30)
    start_check = await battle.battle_start(player,mob)
    if start_check is False: return
    # 戦闘処理(Player後手) #
    text1 = battle.create_battle_text(mob,player)
    if player.now_hp > 0:
        player.magic_lv(3)
        player.cut_mp(10)
        status.get_item(client.get_user(player.ID()),4,-use_num)
        text2 = battle.create_battle_text(player,mob,atk_word=f"『{magic_name}』",strength_rate=up_num)
    else:
        text2 = f"{player.user} はやられてしまった…"
    battle_log = f">>> {text1}\n* * * *\n{text2}"
    result_em,spawn_em,anti_magic_em = await battle.battle_result(player, mob)
    await ch.send(content=battle_log,embed=result_em)
    if spawn_em:await ch.send(embed=spawn_em)
    if anti_magic_em:await ch.send(embed=anti_magic_em)
Пример #2
0
async def on_message(message):
    global cmd_lock, macro_checking, doubt_count

    m_ctt = message.content
    m_em = message.embeds
    m_id = message.id
    m_ch = message.channel
    m_guild = message.guild
    m_author = message.author

    if m_author.id == 302050872383242240:
        if message.embeds:
            if not message.embeds[0].description: return
            desc = message.embeds[0].description
            if not "表示順をアップしたよ" in desc: return
            mention = message.mentions[0]
            user = discord.utils.get(message.guild.members, mention=mention)
            if not user:
                await m_ch.send(
                    "報酬を配布しようとしたけど誰がやったかわからなかったようだ。<@715192735128092713> 仕事しろおら。"
                )
                return
            status.get_item(client, user, 6, 10)
            item_emoji = status.items_emoji_a[6]
            await m_ch.send(
                f"<@{user.id}> さんBumpありがとう!\nアイテム配布: {item_emoji}×10")

    if m_ctt.startswith(
            "^^"
    ) and not m_author.id in check_macro.macro_checking and not m_author.bot:

        if cmd_lock.get(m_ch.id) is True:
            await m_ch.send("コマンド処理中。\nいつまでも終わらない場合は`><fix`。")
            return

        if m_ctt == '^^start':
            print("^^start: ", m_author)
            id_list = [
                i["id"] for i in pg.fetchdict("select id from player_tb;")
            ]
            print(id_list)

            def check(m):
                if not m.author.id == m_author.id: return 0
                return 1

            def check2(m):
                if not m.author.id == m_author.id: return 0
                if not m.content in ("y", "Y", "n", "N"): return 0
                return 1

            if m_author.id in id_list:
                await m_ch.send(
                    f"【警告】登録済みです。全てのデータを消して再登録しますか? \nyes -> y\nno -> n")
                try:
                    msg = await client.wait_for("message",
                                                timeout=60,
                                                check=check)
                except asyncio.TimeoutError:
                    return
                else:
                    if msg.content in ("y", "Y"):
                        await m_ch.send(f"再登録を致します。")
                        magic_type_flag = True
                        pg.execute(
                            f"delete from player_tb where id = {m_author.id}")
                    else:
                        await m_ch.send(f"キャセルン!!")
                        return
            await m_ch.send(f"{m_author.mention}さんの冒険者登録を開始。")
            magic_type_flag = False
            while not magic_type_flag is True:
                magic_type_em = discord.Embed(
                    title=f"{m_author.name} の所属魔法領域を選択",
                    description=
                    ("所属する魔法領域の対応番号を半角英数字で送信してください。\n再選択は出来ません。詳しくは[GitHub](https://github.com/Sakuraga200323/BitRPG/blob/master/README.md)の**各システムの解説->魔法システム**"
                     ))
                magic_type_em.add_field(name="1:Wolf", value="`火力特化の魔法領域です。`")
                magic_type_em.add_field(name="2:Armadillo",
                                        value="`防御特化の魔法領域です。`")
                magic_type_em.add_field(name="3:Orca",
                                        value="`テクニカル性特化の魔法領域です。`")
                await m_ch.send(embed=magic_type_em)
                try:
                    msg = await client.wait_for("message",
                                                timeout=60,
                                                check=check)
                except asyncio.TimeoutError:
                    await m_ch.send(f"時間切れです。もう一度`^^start`でやり直して下さい。")
                else:
                    respons = int(msg.content) if msg.content in ("1", "2",
                                                                  "3") else 0
                    if not respons in (1, 2, 3):
                        await m_ch.send(f"【警告】`1,2,3`で答えて下さい。")
                        continue
                    select_magic_type = "Wolf" if respons == 1 else "Armadillo" if respons == 2 else "Orca"
                    await m_ch.send(
                        f"『{select_magic_type}』で宜しいですか?\nyes -> y\nno -> n")
                    try:
                        msg = await client.wait_for("message",
                                                    timeout=10,
                                                    check=check2)
                    except asyncio.TimeoutError:
                        await m_ch.send(f"時間切れです。もう一度`^^start`でやり直して下さい。")
                    else:
                        if msg.content in ("y", "Y"):
                            await m_ch.send(f"『{select_magic_type}』で登録します。")
                            magic_type_flag = True
                        elif msg.content in ("n", "N"):
                            await m_ch.send(f"魔法領域の選択画面に戻ります。")
                            continue
            if not magic_type_flag == True:
                return
            jsonb_items = "'冒険者カード',1, 'HP回復薬',10, 'MP回復薬',10, '魔石',1, '魂の焔',0, '砥石',0, '魔晶',0, '魔硬貨',0"
            cmd = (
                f"INSERT INTO player_tb VALUES (" +
                f"{m_author.id},1,1000,1,1,10,1,1,1,{respons},0,0,jsonb_build_object({jsonb_items}),0"
                + ");")
            print(f"NewPlayer:{m_author}({m_author.id}),{select_magic_type}")
            try:
                pg.execute(cmd)
            except Exception as e:
                await m_ch.send('type:' + str(type(e)),
                                '\nargs:' + str(e.args), '\ne自身:' + str(e))
            else:
                emojis = staus.items_emoji_a
                embed = discord.Embed(description=f"<@{m_author.id}> はを獲得した。",
                                      color=discord.Color.green())
                await m_ch.send(
                    content=
                    "<@{m_author.id}> さんの冒険者登録が完了しました。\nアイテム配布: 冒険者カード{emojis[1]}×1 HP回復薬{emojis[2]}×10 MP回復薬{emojis[3]}×10 魔石{emojis[6]}×1",
                    embed=embed)
            player = avatar.Player(client, m_author.id)
            if not m_author.id in box.players:
                box.players[m_author.id] = player
            await status.open_status(client, m_author, m_ch)
            await help.help(client, m_ch, m_author)

        if client.get_channel(761571389345759232).name == 'true':
            user_roles = [i.name for i in m_author.roles]
            clearance_lv3_user = "******" in user_roles
            clearance_lv4_user = "******" in user_roles
            clearance_lv5_user = "******" in user_roles
            if not clearance_lv3_user or not clearance_lv4_user or not clearance_lv5_user:
                await m_ch.send(
                    '現在開発作業中につき、ClearanceLv3未満のプレイヤーのコマンド使用を制限しています。')
                return

        cmd_lock[m_ch.id] = True
        mob = avatar.Mob(client, m_ch.id)

        try:
            if random.random() <= 0.005:
                result = await check_macro.check_macro(client, m_author, m_ch)
                if not result:
                    return

            cmd_list = [
                "^^help", "^^st", "^^status", "^^point", "^^attack", "^^atk",
                "^^rank", "^^item", "^^reset", "^^re"
            ]
            if not m_author.id in box.players:
                id_list = [
                    i["id"] for i in pg.fetchdict("select id from player_tb;")
                ]
                if m_author.id in id_list:
                    await m_ch.send(
                        f"<@{m_author.id}>のデータがプレイヤー一覧に入っていませんでした。強制的に挿入します。")
                    player = avatar.Player(client, m_author.id)
                else:
                    await m_ch.send(
                        f"<@{m_author.id}>は冒険者登録をしていません。`^^start`で登録してください。")
                    return

            # IURL #
            if m_ctt == "^^url":
                print("^^url: ", m_author)
                await m_ch.send(embed=discord.Embed(
                    title="Invite & Other URL",
                    description=
                    ("▶︎[BitRPGBot招待](https://discord.com/api/oauth2/authorize?client_id=715203558357598240&permissions=8&scope=bot)\n"
                     + "▶︎[公式鯖参加](https://discord.gg/NymwEUP)\n" +
                     "▶︎[Github(運営メンバー紹介、コマンド、システム説明)](https://github.com/Sakuraga200323/BitRPG)"
                     )))

            # ヘルプ #
            if m_ctt == "^^help":
                await help.help(client, m_ch, m_author)

            # ステータスの表示 #
            if m_ctt.startswith("^^st"):
                print("^^st: ", m_author)
                temp = m_ctt
                pattern = r"\^\^(st|status|st (.+)|status (.+))$"
                result = re.search(pattern, temp)
                if result:
                    await status.open_status(client, m_author, m_ch)

            # 戦闘 #
            if m_ctt.startswith("^^attack") or m_ctt.startswith("^^atk"):
                print("^^atk: ", m_author)
                temp = m_ctt
                pattern = r"\^\^(atk|attack|atk (.+)|attack (.+))$"
                result = re.search(pattern, temp)
                if result: await battle.cbt_proc(client, m_author, m_ch)

            # 戦闘から離脱 #
            if m_ctt.startswith("^^re"):
                print("^^re: ", m_author)
                temp = m_ctt
                pattern = r"^\^\^(re|reset|reset (.+)|re (.+))$"
                result = re.search(pattern, temp)
                if result: await battle.reset(client, m_author, m_ch)

            # STPの振り分け #
            if m_ctt.startswith("^^point"):
                print("^^point: ", m_author)
                pattern = r"\^\^point (str|STR|def|DEF|agi|AGI) (\d{1,})$"
                result = re.search(pattern, m_ctt)
                if result: await status.divid(client, m_author, m_ch, result)

            # レベルランキングの表示 #
            if m_ctt == "^^ranking":
                print("^^ranking: ", m_author)
                ranking = rank.RankClass(client)
                ranking.channel(m_author, m_ch)

            # アイテム #
            if m_ctt.startswith("^^i"):
                print("^^item: ", m_author)
                pattern = r"\^\^(i|item) (.+)"
                pattern2 = r"\^\^(i|item)$"
                result = re.search(pattern, m_ctt)
                result2 = re.search(pattern2, m_ctt)
                if result:
                    await status.use_item(client, m_ch, m_author,
                                          result.group(2))
                elif result2:
                    await status.open_inventory(client, m_ch, m_author)

            # Lv上限解放 #
            if m_ctt == "^^lvunlock":
                print("^^lvunlock: ", m_author)
                await status.up_max_lv(client, m_ch, m_author)

            # shop #
            if m_ctt == "^^shop":
                print("^^shop: ", m_author)
                await shop.shop(client, m_ch, m_author)

        finally:
            cmd_lock[m_ch.id] = False

    if not m_author.bot:
        if m_ctt == '><report':
            embed = discord.Embed(
                title='<Safe> -YUI- will help you!!',
                description=(
                    'こんにちは、開発者代理の**天乃 結**です!' +
                    '\nレポート確認開始! 今から5分間待つから、その間にレポートをできるだけ詳しく書いて送信してね。' +
                    '\n最初のメッセージしか送信しないから注意してね。ちなみに画像も一緒に送信できるよd(˙꒳˙* )'))
            # embed.set_footer(text='待機中…')
            await m_ch.send(embed=embed)

            def check(m):
                if m.author.id != m_author.id:
                    return 0
                if m.channel.id != m_ch.id:
                    return 0
                return 1

            try:
                re_m = await client.wait_for('message',
                                             timeout=60,
                                             check=check)
            except asyncio.TimeoutError:
                await m_ch.send(
                    'これ以上待てないよォ…\n5分以内で終わらない時は、先にまとめてかららコピペして送信するといいよ!')
            else:
                ans = re_m.content
                atch = None
                if re_m.attachments:
                    atch = re_m.attachments
                re_em = discord.Embed(description=ans)
                re_em.set_author(name=m_author)
                await client.get_channel(761516423959805972).send(embed=re_em,
                                                                  file=atch)
                await m_ch.send('レポートありがとう!')

        if m_ctt == '><fix':
            embed = discord.Embed(
                title='<Safe> -YUI- will help you!!',
                description=('こんにちは、開発者代理の**天乃 結**です!' +
                             '\n私が来たからにはもう大丈夫、大体のバグを強制的に治しちゃうよ!' +
                             '\n診断していくから`y, n`で答えてね!'))
            await m_ch.send(embed=embed)

            def check(m):
                if m.author.id != m_author.id: return 0
                if m.channel.id != m_ch.id: return 0
                if not m.content in ('y', 'n'): return 0
                return 1

            if m_ch.id in cmd_lock:
                em = discord.Embed(
                    description='もしかしてコマンド処理が終わらないんじゃない?\n`y/n`')
                await m_ch.send(embed=em)
                try:
                    re_m = await client.wait_for('message',
                                                 timeout=60,
                                                 check=check)
                except asyncio.TimeoutError:
                    await m_ch.send('答えないんなら次行くね?')
                else:
                    answer = re_m.content
                    if answer == 'y':
                        cmd_lock[m_ch.id] = False
            embed = discord.Embed(
                description='これで全部かな?\nお待たせしてごめんね、修理完了したよ!\n今後ともBitRPGをよろしく!!')
            await m_ch.send(embed=embed)

    if m_ctt == "SystemCall":
        m_ctt = m_ctt.split("SystemCall")[1].strip("\n")
        user_is_c_lv2 = (client.get_guild(official_guild_id)
                         ).get_role(c_lv2) in m_author.roles
        user_is_c_lv3 = (client.get_guild(official_guild_id)
                         ).get_role(c_lv3) in m_author.roles
        user_is_c_lv4 = (client.get_guild(official_guild_id)
                         ).get_role(c_lv4) in m_author.roles
        user_is_c_lv5 = (client.get_guild(official_guild_id)
                         ).get_role(c_lv5) in m_author.roles
        if not user_is_c_lv4 and not user_is_c_lv5:
            clv = 3 if user_is_c_lv3 else 2 if user_is_c_lv2 else 1
            await m_ch.send(
                f"*<@{m_author.id}> is CrealanceLv{clv}. You need at least ClearanceLv4 to call the system.*"
            )
            return
        else:
            clv = 5 if user_is_c_lv5 else 4
            await m_ch.send(
                f"*<@{m_author.id}> is CrealanceLv{clv}. System was already came.*"
            )

            def check(m):
                if m.author.id != m_author.id: return 0
                if m.channel.id != m_ch.id: return 0
                return 1

            try:
                remsg = await client.wait_for("message", check=check)
            except:
                pass
            else:
                ctt = remsg.content
                try:
                    if ctt.startswith("psql "):
                        cmd = ctt.split("psql ")[1]
                        await m_ch.send(f"`::DATABASE=> {cmd}`")
                        result = None
                        if "select" in cmd:
                            result = f"{pg.fetch(cmd+' LIMIT 10')}\n(DataCount『{len(pg.fetch(cmd))}』)"
                        else:
                            try:
                                pg.execute(cmd)
                            except Exception as error:
                                result = f"{error}"
                            else:
                                result = True
                        try:
                            await m_ch.send(f"```py\n{result}```")
                        except:
                            await m_ch.send("Error.")
                    if ctt.startswith("excec "):
                        cmd = ctt.split("excec ")[1]
                        await m_ch.send(f"`::python=>{cmd}`")
                        try:
                            excec(cmd)
                        except:
                            result = False
                        else:
                            retult = True
                        await m_ch.send(result)

                finally:
                    await m_ch.send("*Completed. System was already closed.*")
Пример #3
0
async def check_macro(user, ch):
    P_list = pg.fetch(f"select * from player_tb where id = {user.id};")
    if not user.id in doubt_count:
        doubt_count[user.id] = 0
    check_flag = True
    result = False
    while check_flag == True:
        flag = await ch.send("デデドン!!")
        await asyncio.sleep(1)
        check_id = flag.id
        macro_checking.append(user.id)
        img, num = await anti_macro.get_img(client)
        cv2.imwrite('anti_macro/num_img/temp.png', img)
        check_em = discord.Embed(
            title="マクロ検知ぃいい!!(迫真)",
            description=
            f'{user.mention}さんのマクロチェックです(突然の冷静)\n以下の画像に書かれている数字を20秒以内に**半角**で送信してください\n※`CheckID『{check_id}』`'
        )
        check_em.set_image(url="attachment://temp.png")
        check_msg = await ch.send(
            embed=check_em,
            file=discord.File(fp="anti_macro/num_img/temp.png"))

        def check(m):
            if not m.author.id == user.id or m.channel.id != ch.id:
                return 0
            if not m.content in [
                    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
            ]:
                return 0
            return 1

        try:
            answer = await client.wait_for('message', timeout=20, check=check)
        except asyncio.TimeoutError:
            doubt_count[user.id] += 1
            temp = None
            await ch.send(f'無回答!! 不正カウント+1(現在{doubt_count[user.id]})')
            result = False
        else:
            temp = answer.content
            if int(answer.content) == int(num):
                await ch.send(f'正解!!\nアイテム配布: 魔石×10')
                status.get_item(user, 6, 10)
                check_flag = False
                result = True
            elif str(num) != str(answer.content):
                doubt_count[user.id] += 1
                await ch.send(f'不正解!! 不正カウント+1(現在{doubt_count[user.id]})')
                result = False
        print(f"MacroCheck:({user.id}) TrueAnswer[{num}], UsersAnswer[{temp}]")
        embed = discord.Embed(title="マクロ検知ログ", color=0x37ff00)
        embed.add_field(name="CheckID", value=check_id, inline=False)
        embed.add_field(name="Result", value=result, inline=False)
        embed.add_field(name="MissNum",
                        value=doubt_count[user.id],
                        inline=False)
        if len(str(P_list)) <= 1024:
            embed.add_field(name="UserData", value=str(P_list), inline=False)
        embed.set_image(url="attachment://temp.png")
        await client.get_channel(763299968353304626).send(
            embed=embed, file=discord.File(fp="anti_macro/num_img/temp.png"))
        macro_checking.remove(user.id)
        if doubt_count[user.id] >= 3:
            check_flag = False
            await ch.send(f'不正カウントが規定量に達しました。ログを送信します。')
            await client, get_channel(799960054840557618).send(embed)
        return result
Пример #4
0
async def shop(user, ch):
    # shop_msg1 -> ショプの最初のメッセージ
    # shop_msg2 -> コマンドの使いかたや状況の詳細を書き込むメッセージ
    player = box.players[user.id]
    shop_em = discord.Embed(title="Shop",
                            description=("\n`1.`アイテム購入" + "\n`2.`アイテム合成" +
                                         "\n`3.`武器購入"))
    shop_msg = await ch.send(embed=shop_em)

    def check(m):
        if not user.id == m.author.id: return 0
        return 1

    def check2(m):
        if not user.id == m.author.id: return 0
        if not m.content in ("y", "Y", "n", "N"): return 0
        return 1

    def check3(m):
        if not user.id == m.author.id: return 0
        if not m.content.isdigit(): return 0
        return 1

    def check_buy(m):
        if not user.id == m.author.id: return 0
        pattern = r'^(\d+) (\d+)$'
        if not re.search(pattern, m.content) and not m.content == "0": return 0
        return 1

    try:
        msg = await client.wait_for("message", timeout=60, check=check3)
        await msg.delete()
    except asyncio.TimeoutError:
        await shop_msg.edit(embed=shop_em)
    else:
        respons = int(msg.content)

        if respons == 1:
            shop_em1 = discord.Embed(title="アイテムショップ",
                                     description=f"所持Cell:{player.money()}")
            menu_tuple = (
                (f"` 1.`{items_emoji_a[2] }HP回復薬",
                 f"┗━Price: 100cell┃Info: HPを500回復 素材アイテム"),
                (f"` 2.`{items_emoji_a[3] }MP回復薬",
                 f"┗━Price: 100cell┃Info: MPを500回復"),
                (f"` 3.`{items_emoji_a[4] }魂の焔",
                 f"┗━Price: 10cell┃Info: 素材アイテム とある魔法の触媒"),
                (f"` 4.`{items_emoji_a[5] }砥石",
                 f"┗━Price: 500cell┃Info: 素材アイテム"),
                (f"` 5.`{items_emoji_a[6] }魔石",
                 f"┗━Price: 150cell┃Info: 250個でLv上限開放 素材アイテム"),
                (f"` 6.`{items_emoji_a[7] }魔晶",
                 f"┗━Price: 1000cell┃Info: 素材アイテム"),
                (f"` 7.`{items_emoji_a[8] }魔硬貨",
                 f"┗━Price: 2000cell┃Info: とある魔法の触媒"),
                (f"` 8.`{items_emoji_a[9] }HP全回復薬",
                 f"┗━Price: 300cell┃Info: HPを100%回復"),
                (f"` 9.`{items_emoji_a[10]}MP全回復薬",
                 f"┗━Price: 300cell┃Info: MPを100%回復"),
                (f"`10.`{items_emoji_a[26]}型枠-インゴット",
                 f"┗━Price: 5cell┃Info: 素材アイテム"),
                (f"`11.`{items_emoji_a[27]}型枠-強化素材チップ",
                 f"┗━Price: 5cell┃Info: 素材アイテム"),
            )
            for i in menu_tuple:
                shop_em1.add_field(name=i[0], value=i[1], inline=False)
            await shop_msg.edit(
                content=
                "```該当するアイテムの番号と購入数を半角スペースを空けて送信してください。0と送信すると終了します。\n例:HP回復薬を10個購入\n1 10```",
                embed=shop_em1)
            while True:
                try:
                    msg = await client.wait_for("message",
                                                timeout=60,
                                                check=check_buy)
                    await msg.delete()
                except asyncio.TimeoutError:
                    await shop_msg.edit(content="```時間経過により処理終了済み```",
                                        embed=shop_em1)
                    break
                else:
                    pattern = r'^(\d+) (\d+)$'
                    result = re.search(pattern, msg.content)
                    if msg.content == "0":
                        await shop_msg.edit(content="```処理終了済み```",
                                            embed=shop_em1)
                        break
                    item_id_dict = {
                        1: 2,
                        2: 3,
                        3: 4,
                        4: 5,
                        5: 6,
                        6: 7,
                        7: 8,
                        8: 9,
                        9: 10,
                        10: 26,
                        11: 27
                    }
                    if not int(result.group(1)) in item_id_dict:
                        await shop_msg.edit(content="```番号オーバーしてるかもです```", )
                        continue
                    item_id, item_num = item_id_dict[int(
                        result.group(1))], int(result.group(2))
                    cost_dict = {
                        2: 100,
                        3: 100,
                        4: 10,
                        5: 500,
                        6: 150,
                        7: 1000,
                        8: 2000,
                        9: 300,
                        10: 300,
                        26: 5,
                        27: 5
                    }
                    if player.money() < cost_dict[item_id] * item_num:
                        await shop_msg.edit(
                            content=
                            f"```{cost_dict[item_id]*item_num-player.money()}Cell足りません。\nそのまま購入を続けられます。終了する場合は0を送信。```",
                            embed=shop_em1)
                        continue
                    status.get_item(user, item_id, item_num)
                    player.money(-cost_dict[item_id] * item_num)
                    await shop_msg.edit(
                        content=
                        f"{cost_dict[item_id]*item_num}cellで{items_name[item_id]}{items_emoji_a[item_id]}x{item_num}を購入しました。\n\nそのまま購入を続けられます。終了する場合は0を送信。",
                        embed=shop_em1)

        elif respons == 2:
            shop_em2 = discord.Embed(title="合成場",
                                     description=f"所持Cell:{player.money()}")
            menu_tuple = (
                (f"\n` 1.`{items_emoji_a[7] }魔晶",
                 f"**Price**: 500cell\n**Recipe: **{items_emoji_a[5]}×1, {items_emoji_a[6]}×1\n**Info**: 素材アイテム"
                 ),
                (f"\n` 2.`{items_emoji_a[8] }魔硬貨",
                 f"**Price**: 750cell\n**Recipe: **{items_emoji_a[4]}×1, {items_emoji_a[5]}×1, {items_emoji_a[7]}×1\n**Info**: とある魔法の触媒"
                 ),
                (f"\n` 3.`{items_emoji_a[9] }HP全回復薬",
                 f"**Price**: 200cell\n**Recipe: **{items_emoji_a[2]}×1, {items_emoji_a[4]}×10\**Info**: HPを100%回復"
                 ),
                (f"\n` 4.`{items_emoji_a[10]}MP全回復薬",
                 f"**Price**: 200cell\n**Recipe: **{items_emoji_a[3]}×1, {items_emoji_a[4]}×10\**Info**: MPを100%回復"
                 ),
                (f"\n` 5.`{items_emoji_a[24]}黒色酸化鉄",
                 f"**Price**: 100cell\n**Recipe: **{items_emoji_a[23]}×1, {items_emoji_a[4]}×10\**Info**: 武器素材"
                 ),
                (f"\n` 6.`{items_emoji_a[12]}キャラメル鋼",
                 f"**Price**: 100cell\n**Recipe: **{items_emoji_a[11]}×1, {items_emoji_a[4]}×10, {items_emoji_a[26]}×1\n**Info**: 武器素材"
                 ),
                (f"\n` 7.`{items_emoji_a[14]}ブラッド鋼",
                 f"**Price**: 100cell\n**Recipe: **{items_emoji_a[13]}×1, {items_emoji_a[4]}×10, {items_emoji_a[26]}×1\n**Info**: 武器素材"
                 ),
                (f"\n` 8.`{items_emoji_a[16]}ゴールド鋼",
                 f"**Price**: 100cell\n**Recipe: **{items_emoji_a[15]}×1, {items_emoji_a[4]}×10, {items_emoji_a[26]}×1\n**Info**: 武器素材"
                 ),
                (f"\n` 9.`{items_emoji_a[18]}ダーク鋼",
                 f"**Price**: 100cell\n**Recipe: **{items_emoji_a[17]}×1, {items_emoji_a[4]}×10, {items_emoji_a[26]}×1\n**Info**: 武器素材"
                 ),
                (f"\n`10.`{items_emoji_a[20]}ミスリル鋼",
                 f"**Price**: 100cell\n**Recipe: **{items_emoji_a[19]}×1, {items_emoji_a[4]}×10, {items_emoji_a[26]}×1\n**Info**: 武器素材"
                 ),
                (f"\n`11.`{items_emoji_a[22]}オリハルコン鋼",
                 f"**Price**: 100cell\n**Recipe: **{items_emoji_a[21]}×1, {items_emoji_a[4]}×10, {items_emoji_a[26]}×1\n**Info**: 武器素材"
                 ),
                (f"\n`12.`{items_emoji_a[29]}カーボンプレート",
                 f"**Price**: 100cell\n**Recipe: **{items_emoji_a[28]}×1, {items_emoji_a[4]}×10, {items_emoji_a[2]}×1\n**Info**: 武器強化素材"
                 ),
                (f"\n`13.`{items_emoji_a[30]}カーボンチップ",
                 f"**Price**: 100cell\n**Recipe: **{items_emoji_a[29]}×1, {items_emoji_a[4]}×10, {items_emoji_a[27]}×1\n**Info**: 武器強化素材"
                 ),
            )
            for i in menu_tuple:
                shop_em2.add_field(name=i[0], value=i[1], inline=True)
            await shop_msg.edit(
                content=
                "```該当するアイテムの番号と購入数を半角スペースを空けて送信してください。0と送信すると終了します。\n例:HP全回復薬を10個合成\n3 10```",
                embed=shop_em2)
            while True:
                try:
                    msg = await client.wait_for("message",
                                                timeout=60,
                                                check=check_buy)
                    await msg.delete()
                except asyncio.TimeoutError:
                    await shop_msg.edit(content="```時間経過により処理終了済み```",
                                        embed=shop_em2)
                else:
                    pattern = r'^(\d+) (\d+)$'
                    result = re.search(pattern, msg.content)
                    if msg.content == "0":
                        await shop_msg.edit(content="```処理終了済み```",
                                            embed=shop_em2)
                        break
                    item_id_dict = {
                        1: 7,
                        2: 8,
                        3: 9,
                        4: 10,
                        5: 24,
                        6: 12,
                        7: 14,
                        8: 16,
                        9: 18,
                        10: 20,
                        11: 22,
                        12: 29,
                        13: 30
                    }
                    if not int(result.group(1)) in item_id_dict:
                        await shop_msg.edit(content="```番号オーバーしてるかもです```", )
                        continue
                    item_id, item_num = item_id_dict[int(
                        result.group(1))], int(result.group(2))
                    item_name = items_name[item_id]
                    material_dict = {
                        7: ((5, 1), (6, 1)),
                        8: ((4, 1), (5, 1), (7, 1)),
                        9: ((2, 1), (4, 10)),
                        10: ((3, 1), (4, 10)),
                        12: ((11, 1), (4, 10), (26, 1)),
                        14: ((13, 1), (4, 10), (26, 1)),
                        16: ((15, 1), (4, 10), (26, 1)),
                        18: ((17, 1), (4, 10), (26, 1)),
                        20: ((19, 1), (4, 10), (26, 1)),
                        22: ((21, 1), (4, 10), (26, 1)),
                        24: ((23, 1), (4, 10)),
                        29: ((28, 1), (4, 10), (2, 1)),
                        30: ((29, 1), (4, 10), (27, 1)),
                    }
                    cost_dict = {
                        7: 500,
                        8: 750,
                        9: 200,
                        10: 200,
                        12: 100,
                        14: 100,
                        16: 100,
                        18: 100,
                        20: 100,
                        22: 100,
                        29: 100,
                        30: 100
                    }
                    husoku_text = ""
                    for data in material_dict[item_id]:
                        i_name = items_name[data[0]]
                        if player.item_num(i_name) < data[1] * item_num:
                            husoku_text += f"{i_name}{items_emoji_a[data[0]]}×{data[1]*item_num-player.item_num(i_name)} "
                            continue
                    if husoku_text != "":
                        await shop_msg.edit(
                            content=
                            f"{husoku_text}が不足しています。\nそのまま購入を続けられます。終了する場合は0を送信。",
                            embed=shop_em2)
                        continue
                    if player.money() < cost_dict[item_id] * item_num:
                        await shop_msg.edit(
                            content=
                            f"```{cost_dict[item_id]*item_num-player.money()}cell程お金が足りないようです。\nそのまま購入を続けられます。終了する場合は0を送信。```",
                            embed=shop_em2)
                        continue
                    for data in material_dict[item_id]:
                        i_name = items_name[data[0]]
                        status.get_item(user, data[0], -data[1] * item_num)
                    status.get_item(user, item_id, item_num)
                    status.get_item(user, 28, item_num)
                    player.money(-cost_dict[item_id] * item_num)
                    shop_em2.description = f"所持Cell:{player.money()}"
                    await shop_msg.edit(
                        content=
                        f"{cost_dict[item_id]*item_num}cellで{item_name}{items_emoji_a[item_id]}x{item_num}を合成しました。\nそのまま購入を続けられます。終了する場合は0を送信。",
                        embed=shop_em2)

        elif respons == 3:
            split_weapons_key = tuple(split_list(box.shop_weapons, 6))
            em_title = "武具店"
            rank_dict = {1: "D", 2: "C", 3: "B", 4: "A", 5: "S"}
            embeds = []
            weapons = []
            for page_num, weapons_name in zip(range(1, 100),
                                              split_weapons_key):
                em = discord.Embed(title=em_title,
                                   description=f"所持Cell:{player.money()}")
                for num, weapon_name in zip(range(1, 100), weapons_name):
                    weapon_data = box.shop_weapons[weapon_name]
                    em.add_field(
                        name=f"\n`{num}.`{weapon_data[0]}{weapon_name}",
                        value=
                        f"┗━Price: {weapon_data[1]}cell┃MaxRank: {rank_dict[weapon_data[2]]}",
                        inline=False)
                em.set_footer(text=f"Page.{page_num}/{len(split_weapons_key)}")
                embeds.append(em)
            embeds = tuple(embeds)
            page_num = 0
            await shop_msg.edit(
                content=
                f'`リアクション、ページ番号送信でページ切り替えです。`\n{box.menu_emojis["left"]}:一つページを戻す\n{box.menu_emojis["close"]}:処理を終了する\n{box.menu_emojis["right"]}:一つページを進める\n{box.menu_emojis["buy_mode"]}:購入モードに変更`\nMaxRankは購入時にランダムで決められるランクの最大値です`',
                embed=embeds[0])
            shop_flag = True
            while True:
                buy_mode = False
                if shop_flag is False:
                    break
                if not buy_mode:
                    for emoji in tuple(box.menu_emojis.values()):
                        await shop_msg.add_reaction(emoji)

                    def check_react(r, u):
                        if r.message.id != shop_msg.id:
                            return 0
                        if u.id != user.id:
                            return 0
                        if not str(r.emoji) in tuple(box.menu_emojis.values()):
                            return 0
                        return 1

                    try:
                        reaction, msg = None, None
                        reaction, user = await client.wait_for(
                            "reaction_add", check=check_react, timeout=60.0)
                    except asyncio.TimeoutError:
                        await shop_msg.edit(content="```時間経過により処理終了済み```",
                                            embed=embeds[0])
                        await shop_msg.clear_reactions()
                        break
                    else:
                        content = f'`リアクション、ページ番号送信でページ切り替えです。`\n{box.menu_emojis["left"]}:一つページを戻す\n{box.menu_emojis["close"]}:処理を終了する\n{box.menu_emojis["right"]}:一つページを進める\n{box.menu_emojis["buy_mode"]}:購入モードに変更`\nMaxRankは購入時にランダムで決められるランクの最大値です`'
                        if reaction:
                            before_page_num = page_num
                            emoji = str(reaction.emoji)
                            if emoji == box.menu_emojis["right"]:
                                if page_num < len(embeds) - 1:
                                    page_num += 1
                            elif emoji == box.menu_emojis["close"]:
                                await shop_msg.edit(content="```処理終了済み```",
                                                    embed=embeds[0])
                                await shop_msg.clear_reactions()
                                break
                            elif emoji == box.menu_emojis["left"]:
                                if page_num > 0:
                                    page_num -= 1
                            elif emoji == box.menu_emojis["buy_mode"]:
                                buy_mode = True
                            if before_page_num != page_num:
                                await shop_msg.clear_reactions()
                            if buy_mode:
                                await shop_msg.clear_reactions()
                                content = f'`購入モードです。対応する武器の番号を送信してください。武器スロットが5枠すべて埋まっていると購入できません。\n0を送信すると終了します。`'
                            shop_em3 = embeds[page_num]
                            await shop_msg.edit(content=content,
                                                embed=shop_em3)
                while buy_mode:
                    try:
                        msg = await client.wait_for("message",
                                                    timeout=60,
                                                    check=check3)
                        await msg.delete()
                    except asyncio.TimeoutError:
                        await shop_msg.edit(content="```時間経過により処理終了済み```")
                        buy_mode = False
                        shop_flag = False
                        break
                    else:
                        if msg.content == "0":
                            await shop_msg.edit(content="```処理終了済み```")
                            buy_mode = False
                            shop_flag = False
                            break
                        weapon_id = int(msg.content) + (page_num) * 6
                        weapon = box.npc_weapons[weapon_id]
                        if len(player.weapons()) >= 5:
                            await shop_msg.edit(
                                content=f"```既に5個の武器を所持しています。\n処理終了済み```")
                            shop_flag = False
                            break
                        if player.money() < weapon.create_cost:
                            await shop_msg.edit(
                                content=
                                f"```{weapon.create_cost-player.money()}Cell足りません。\nそのまま購入を続けられます。終了する場合は0を送信。```"
                            )
                            continue
                        rank = 1
                        for i in range(1, weapon.max_rank - 1):
                            if random.random() <= weapon.rate_of_rankup:
                                rank += 1
                                if rank == weapon.max_rank:
                                    buy_mode = False
                                    break
                        weapon_obj = player.create_weapon(
                            weapon.name, weapon.emoji, rank)
                        player.get_weapon(weapon_obj)
                        player.money(-weapon.create_cost)
                        await shop_msg.edit(
                            content=
                            f"{weapon.create_cost}cellで{weapon_obj.emoji()}{weapon_obj.name()}(Rank.{weapon_obj.rank()})を購入しました。\nそのまま購入を続けられます。終了する場合は0を送信。",
                        )
Пример #5
0
async def on_message(message):
    global cmd_lock, macro_checking, doubt_count, pg
    global log_text

    m_ctt = message.content
    m_em = message.embeds
    m_id = message.id
    m_ch = message.channel
    m_guild = message.guild
    m_author = message.author
    if m_author.id == 715203558357598240:
        return
    if m_ch.type == discord.ChannelType.private:
        #await m_ch.send(embed=discord.Embed(description='BitRPGは**2021/2/8**からDM非対応となりました\n|ω・`)ゴメンネ…'))
        return
    if m_ctt.startswith(
            "^^"
    ) and not m_author.id in check_macro.macro_checking and not m_author.bot:

        # await m_ch.send(embed=discord.Embed(description='BitRPGは**2021/2/14**にサービス終了致しました。現在復旧予定はありません。\n約1年間のご利用、誠に有難う御座いました。'))
        # return
        if cmd_lock.get(m_ch.id) is True:
            cmd_em = discord.Embed(description="コマンド処理中。終わらない場合は`><fix`。")
            await m_ch.send(embed=cmd_em)
            return
        if m_ctt == '^^start':
            log_text += ("\n^^start: " + str(m_author))
            id_list = [
                i["id"] for i in pg.fetchdict("select id from player_tb;")
            ]
            print(id_list)

            def check(m):
                if not m.author.id == m_author.id: return 0
                return 1

            def check2(m):
                if not m.author.id == m_author.id: return 0
                if not m.content in ("y", "Y", "n", "N"): return 0
                return 1

            if m_author.id in id_list:
                msg_em = discord.Embed(
                    description=
                    "【警告】登録済みです。全てのデータを消して再登録しますか? \nyes -> y\nno -> n")
                await m_ch.send(embed=msg_em)
                try:
                    msg = await client.wait_for("message",
                                                timeout=60,
                                                check=check)
                except asyncio.TimeoutError:
                    msg_em = discord.Embed(description="キャセルン!!")
                    await m_ch.send(embed=msg_em)
                    return
                else:
                    if msg.content in ("y", "Y"):
                        msg_em = discord.Embed(description="再登録を致します。")
                        await m_ch.send(embed=msg_em)
                        magic_type_flag = True
                        pg.execute(
                            f"delete from player_tb where id = {m_author.id}")
                    else:
                        return
            msg_em = discord.Embed(
                description=f"{m_author.mention}さんの冒険者登録を開始。")
            await m_ch.send(embed=msg_em)
            magic_type_flag = False
            while not magic_type_flag is True:
                magic_type_em = discord.Embed(
                    title=f"{m_author.name} の所属魔法領域を選択",
                    description=("所属する魔法領域の対応番号を半角英数字で送信してください 再選択は出来ません"))
                magic_type_em.add_field(name="1:Wolf",
                                        value="`火力特化\n耐久力が低めです`")
                magic_type_em.add_field(
                    name="2:Armadillo",
                    value="`防御特化\n通常攻撃力が低めですが、HPの減少に応じて最大500%まで攻撃力が上昇します`")
                magic_type_em.add_field(
                    name="3:Orca",
                    value="`テクニカル性特化\nうまく使えると非常に強いですが、その分扱いが難しいです`")
                await m_ch.send(embed=magic_type_em)
                try:
                    msg = await client.wait_for("message",
                                                timeout=60,
                                                check=check)
                except asyncio.TimeoutError:
                    msg_em = discord.Embed(
                        description=f"時間切れです もう一度`^^start`でやり直して下さい ")
                    await m_ch.send(embed=msg_em)
                else:
                    respons = int(msg.content) if msg.content in ("1", "2",
                                                                  "3") else 0
                    if respons in (1, 2, 3):
                        select_magic_type = "Wolf" if respons == 1 else "Armadillo" if respons == 2 else "Orca"
                        msg_em = discord.Embed(
                            description=
                            f"『{select_magic_type}』で宜しいですか?\nyes -> y\nno -> n"
                        )
                        await m_ch.send(embed=msg_em)
                        try:
                            msg = await client.wait_for("message",
                                                        timeout=10,
                                                        check=check2)
                        except asyncio.TimeoutError:
                            msg_em = discord.Embed(
                                description=f"時間切れです もう一度`^^start`でやり直して下さい")
                            await m_ch.send(embed=msg_em)
                        else:
                            if msg.content in ("y", "Y"):
                                msg_em = discord.Embed(
                                    description=f"『{select_magic_type}』で登録します")
                                await m_ch.send(embed=msg_em)
                                magic_type_flag = True
                            elif msg.content in ("n", "N"):
                                msg_em = discord.Embed(
                                    description=f"魔法領域の選択画面に戻ります")
                                await m_ch.send(embed=msg_em)
            if not magic_type_flag == True:
                return
            item_jsonb = str({
                "冒険者カード": 1,
                "HP回復薬": 10,
                "MP回復薬": 10,
                "HP全回復薬": 1,
                "MP全回復薬": 1,
                "魔石": 1,
                "魂の焔": 0,
                "砥石": 0,
                "魔晶": 0,
                "魔硬貨": 0,
                "獲得Exp増加薬": 0,
                "鉄": 0,
                "黒色酸化鉄": 0,
                "キャラメル鉱石": 0,
                "ブラッド鉱石": 0,
                "ゴールド鉱石": 0,
                "ダーク鉱石": 0,
                "ミスリル鉱石": 0,
                "オリハルコン鉱石": 0,
                "キャラメル鋼": 0,
                "ブラッド鋼": 0,
                "ゴールド鋼": 0,
                "ダーク鋼": 0,
                "ミスリル鋼": 0,
                "オリハルコン鋼": 0,
                '炭素粉末': 0,
                "カーボンプレート": 0,
                'カーボンチップ': 0,
                "ハンマー": 0,
                '型枠-インゴット': 0,
                '型枠-武器強化チップ': 0
            }).replace("'", '"')
            temp = '{}'
            cmd = (
                f"INSERT INTO player_tb (id,magic_class,item,weapon,weapons) VALUES ({m_author.id},{respons},'{item_jsonb}',NULL,'{temp}');"
            )
            try:
                pg.execute(cmd)
            except Exception as e:
                await m_ch.send('type:' + str(type(e)) + '\nargs:' +
                                str(e.args) + '\ne自身:' + str(e))
            else:
                emojis = status.items_emoji_a
                msg_em = discord.Embed(
                    description=
                    f"<@{m_author.id}> さんの冒険者登録が完了しました\nアイテム配布: 冒険者カード{emojis[1]}×1 HP回復薬{emojis[2]}×10 MP回復薬{emojis[3]}×10 魔石{emojis[6]}×1"
                )
                await m_ch.send(embed=msg_em)
            player = avatar.Player(client, m_author.id)
            if m_author.id in id_list:
                del box.players[m_author.id]
            box.players[m_author.id] = player
            await status.open_status(m_author, m_ch)
            await m_ch.send(
                content="**まずは`^^help`でコマンド確認をし、`^^url`でBitRPGの公式サバに入りましょう!**")
            ch = client.get_channel(795810767139373076)
            new_player_em = discord.Embed(
                title='New Player',
                description=f'{m_author}({m_author.id}):{respons}')
            await ch.send(embed=new_player_em)
        if client.get_channel(761571389345759232).name == 'true':
            guild = client.get_guild(official_guild_id)
            if not m_author in guild.members:
                msg_em = discord.Embed(
                    description=
                    f"現在開発作業中につき、ClearanceLv3未満のプレイヤーのコマンド使用を制限しています。")
                await m_ch.send(embed=msg_em)
                return
            guild = client.get_guild(official_guild_id)
            user_is_c_lv3 = guild.get_role(c_lv3) in guild.get_member(
                m_author.id).roles
            user_is_c_lv4 = guild.get_role(c_lv4) in guild.get_member(
                m_author.id).roles
            user_is_c_lv5 = guild.get_role(c_lv5) in guild.get_member(
                m_author.id).roles
            if not user_is_c_lv3 and not user_is_c_lv4 and not user_is_c_lv5:
                msg_em = discord.Embed(
                    description=
                    f"現在開発作業中につき、ClearanceLv3未満のプレイヤーのコマンド使用を制限しています。")
                await m_ch.send(embed=msg_em)
                return

        cmd_lock[m_ch.id] = True
        mob = avatar.Mob(client, m_ch.id)

        try:
            if random.random() <= 0.005:
                result = await check_macro.check_macro(m_author, m_ch)
                if not result:
                    return

            cmd_list = [
                "^^help", "^^st", "^^status", "^^point", "^^attack", "^^atk",
                "^^rank", "^^item", "^^reset", "^^re"
            ]
            if not m_author.id in box.players:
                id_list = [
                    i["id"] for i in pg.fetchdict("select id from player_tb;")
                ]
                if m_author.id in id_list:
                    msg_em = discord.Embed(
                        description=
                        f"<@{m_author.id}> のデータがプレイヤー一覧に入っていませんでした。強制的に挿入します。")
                    await m_ch.send(embed=msg_em)
                    player = avatar.Player(client, m_author.id)
                    box.players[m_author.id] = player
                else:
                    msg_em = discord.Embed(
                        description=
                        f"<@{m_author.id}> は冒険者登録をしていません。`^^start`で登録してください。")
                    await m_ch.send(embed=msg_em)
                    return

            # URL #
            if m_ctt == "^^url":
                log_text += ("^^url: " + str(m_author))
                await m_ch.send(embed=discord.Embed(
                    title="Invite & Other URL",
                    description=
                    "▶︎[BitRPGBot招待](https://discord.com/api/oauth2/authorize?client_id=715203558357598240&permissions=8&scope=bot)\n▶︎[公式鯖参加](https://discord.gg/NymwEUP)\n"
                ))

            # ヘルプ #
            if m_ctt == "^^help":
                log_text += ("\mn^^help: " + str(m_author))
                await help.help(m_author, m_ch)

            # ステータスの表示 #
            if m_ctt.startswith("^^st"):
                log_text += ("\n^^st: " + str(m_author))
                temp = m_ctt
                pattern = r"\^\^(st|status|st (.+)|status (.+))$"
                result = re.search(pattern, temp)
                if result:
                    await status.open_status(m_author, m_ch)

            # 戦闘 #
            if m_ctt.startswith("^^attack") or m_ctt.startswith("^^atk"):
                log_text += ("\n^^atk: " + str(m_author))
                temp = m_ctt
                pattern = r"^\^\^(atk|attack|atk (.+)|attack (.+))$"
                result = re.search(pattern, temp)
                if result: await battle.cbt_proc(m_author, m_ch)

            # 魔法 #
            if m_ctt.startswith("^^m"):
                log_text += ("\n^^magic: " + str(m_author))
                pattern = r"^\^\^(m|magic) (.+)"
                pattern2 = r"^\^\^(m|magic)$"
                result = re.search(pattern, m_ctt)
                if result:
                    await battle.use_magic(m_author, m_ch, result.group(2))
                    return
                result2 = re.search(pattern2, m_ctt)
                if result2:
                    await battle.open_magic(m_author, m_ch)

            # 戦闘から離脱 #
            if m_ctt.startswith("^^re"):
                print("^^re: " + str(m_author))
                temp = m_ctt
                pattern = r"^\^\^(re|reset|reset (.+)|re (.+))$"
                result = re.search(pattern, temp)
                if result: await battle.reset(m_author, m_ch)

            # training #
            if m_ctt.startswith("^^tr"):
                log_text += ("\n^^training: " + str(m_author))
                temp = m_ctt
                pattern = r"^\^\^(tr|training|training (.+)|tr (.+))$"
                result = re.search(pattern, temp)
                if result:
                    training.client, training.pg = client, pg
                    await training.abc_training(m_author, m_ch)

            # STPの振り分け #
            if m_ctt.startswith("^^point"):
                log_text += ("\n^^point: " + str(m_author))
                pattern = r"\^\^(point (.+)|point)$"
                result = re.search(pattern, m_ctt)
                if result:
                    await status.share_stp(m_author, m_ch)

            # 図鑑の表示 #
            if m_ctt == "^^zukan":
                log_text += ("\n^^zukan: " + str(m_author))
                await mob_data.open_zukan(m_author, m_ch)

            # アイテム #
            if m_ctt.startswith("^^i"):
                log_text += ("\n^^item: " + str(m_author))
                pattern = r"\^\^(i|item) (.+)"
                pattern2 = r"\^\^(i|item)$"
                result = re.search(pattern, m_ctt)
                result2 = re.search(pattern2, m_ctt)
                if result:
                    await status.use_item(m_author, m_ch, result.group(2))
                elif result2:
                    await status.open_inventory(m_author, m_ch)
                else:
                    em = discord.Embed(description="`^^item アイテム名`")
                    await m_ch.send(embed=em)

            # ポーチ #
            if m_ctt.startswith("^^p") and not m_ctt.startswith('^^point'):
                log_text += ("\n^^pouch: " + str(m_author))
                pattern1 = r"^\^\^(pouch|p)$"
                pattern2 = r"^\^\^(pouch|p) (1|2|3)$"
                pattern3 = r"^\^\^(pouch|p) (1|2|3) (.+)$"
                result1 = re.match(pattern1, m_ctt)
                result2 = re.match(pattern2, m_ctt)
                result3 = re.match(pattern3, m_ctt)
                if result1:
                    await status.open_pouch(m_author, m_ch)
                elif result2:
                    await status.use_pouch(m_author, m_ch, result2.group(2))
                elif result3:
                    await status.set_pouch(m_author, m_ch, result3.group(2),
                                           result3.group(3))
                else:
                    em = discord.Embed(
                        description=
                        "アイテム使用┃`^^pouch 番号`\nアイテム割当┃`^^pouch 番号 アイテム名`")
                    await m_ch.send(embed=em)

            # Lv上限解放 #
            if m_ctt == "^^lvunlock":
                log_text += ("\n^^lvunlock: " + str(m_author))
                await status.up_max_lv(m_author, m_ch)

            # shop #
            if m_ctt == "^^shop":
                log_text += ("\n^^shop: " + str(m_author))
                await shop.shop(m_author, m_ch)

            # ranking #
            if m_ctt == "^^rank":
                log_text += ("\n^^rank: " + str(m_author))
                await rank.open_ranking(m_author, m_ch)

            # weapon #
            if m_ctt.startswith("^^w"):
                log_text += ("\n^^weapon: " + str(m_author))
                temp = m_ctt
                pattern = r"^\^\^(w|weapon)$"
                result = re.search(pattern, temp)
                if result:
                    await status.set_weapon(m_author, m_ch)

            if m_ctt == "^^menu":
                menu_emojis = (
                    "<:status_icon:800039843668426782>",
                    "<:inventory_icon:800039843572482079>",
                    "<:magic_icon:800062790081052702>",
                    "<:shop_icon:800039843626876938>",
                    "<:rank_icon:800039843882860544>",
                )
                menu_text = (
                    "<:status_icon:800039843668426782> [` Status  `]" +
                    "\n<:inventory_icon:800039843572482079> [`Inventory`]" +
                    "\n<:magic_icon:800062790081052702> [`  Magic  `]" +
                    "\n<:shop_icon:800039843626876938> [`  Shop   `]" +
                    "\n<:rank_icon:800039843882860544> [`Rankking `]")
                menu_em = discord.Embed(description=menu_text, color=0xebebeb)
                menu_msg = await m_ch.send(embed=menu_em)
                for emoji in menu_emojis:
                    await menu_msg.add_reaction(emoji)

                def check_react(r, user):
                    if r.message.id != menu_msg.id:
                        return 0
                    if user.id != m_author.id:
                        return 0
                    if not str(r.emoji) in menu_emojis:
                        return 0
                    return 1

                try:
                    reaction, user = await client.wait_for("reaction_add",
                                                           check=check_react,
                                                           timeout=60.0)
                except asyncio.TimeoutError:
                    await menu_msg.clear_reactions()
                else:
                    print("menu!")
                    emoji = str(reaction.emoji)
                    menu_text2 = ""
                    for i in menu_text.split("\n"):
                        if not i.startswith(emoji):
                            menu_text2 += "\n<:off_icon:800041025288405013>"
                        else:
                            menu_text2 += f'\n{i.replace("> ","> ◀")}'
                    menu_em = discord.Embed(description=menu_text2,
                                            color=0xebebeb)
                    await menu_msg.edit(embed=menu_em)
                    if emoji == menu_emojis[0]:
                        await status.open_status(m_author, m_ch)
                    elif emoji == menu_emojis[1]:
                        await status.open_inventory(m_author, m_ch)
                    elif emoji == menu_emojis[2]:
                        await battle.open_magic(m_author, m_ch)
                    elif emoji == menu_emojis[3]:
                        await shop.shop(m_author, m_ch)
                    elif emoji == menu_emojis[4]:
                        await rank.open_ranking(m_author, m_ch)
        finally:
            cmd_lock[m_ch.id] = False

    if not m_author.bot:
        if m_ctt.startswith('><embed '):
            title, desc = m_ctt.split('"')[1], m_ctt.split('"')[3]
            await m_author.send(m_ctt)
            await message.delete()
            embed = discord.Embed(title=title, description=desc)
            await m_ch.send(embed=embed)
        if m_ctt == '><report':
            embed = discord.Embed(
                title='<Safe> -YUI- will help you!!',
                description=(
                    'こんにちは、開発者代理の**天乃 結**です!' +
                    '\nレポート確認開始! 今から5分間待つから、その間にレポートをできるだけ詳しく書いて送信してね。' +
                    '\nちなみに画像も一緒に送信できるよd(˙꒳˙* )'))
            # embed.set_footer(text='待機中…')
            await m_ch.send(embed=embed)

            def check(m):
                if m.author.id != m_author.id:
                    return 0
                if m.channel.id != m_ch.id:
                    return 0
                return 1

            try:
                re_m = await client.wait_for('message',
                                             timeout=60,
                                             check=check)
            except asyncio.TimeoutError:
                await m_ch.send(
                    'これ以上待てないよォ…\n5分以内で終わらない時は、先にまとめてかららコピペして送信するといいよ!')
            else:
                ans = re_m.content
                atch = None
                if re_m.attachments:
                    atch = re_m.attachments
                re_em = discord.Embed(description=ans)
                re_em.set_author(name=m_author)
                await client.get_channel(761516423959805972).send(embed=re_em,
                                                                  file=atch)
                await m_ch.send('レポートありがとう!')

        if m_ctt == '><fix':
            embed = discord.Embed(
                title='<Safe> -YUI- will help you!!',
                description=('こんにちは、開発者代理の**天乃 結**です!' +
                             '\n私が来たからにはもう大丈夫、大体のバグを強制的に治しちゃうよ!' +
                             '\n診断していくから`y, n`で答えてね!'))
            await m_ch.send(embed=embed)

            def check(m):
                if m.author.id != m_author.id: return 0
                if m.channel.id != m_ch.id: return 0
                if not m.content in ('y', 'n'): return 0
                return 1

            if m_ch.id in cmd_lock:
                em = discord.Embed(
                    description='もしかしてコマンド処理が終わらないんじゃない?\n`y/n`')
                await m_ch.send(embed=em)
                try:
                    re_msg = await client.wait_for('message',
                                                   timeout=60,
                                                   check=check)
                except asyncio.TimeoutError:
                    await m_ch.send('答えないんなら次行くね?')
                else:
                    answer = re_msg.content
                    if answer == 'y':
                        cmd_lock[m_ch.id] = False
            embed = discord.Embed(
                description='これで全部かな?\nお待たせしてごめんね、修理完了したよ!\n今後ともBitRPGをよろしく!!')
            await m_ch.send(embed=embed)

        if m_ctt == "><help me daima":
            if m_author.id == 715192735128092713:
                await m_ch.send(
                    f"Help me Daimaaaaaaaaa!!\n(<@570243143958528010>)")

    if m_ctt == "SystemCall":
        m_ctt = m_ctt.split("SystemCall")[1].strip("\n")
        guild = client.get_guild(official_guild_id)
        user_is_c_lv2 = guild.get_role(c_lv2) in guild.get_member(
            m_author.id).roles
        user_is_c_lv3 = guild.get_role(c_lv3) in guild.get_member(
            m_author.id).roles
        user_is_c_lv4 = guild.get_role(c_lv4) in guild.get_member(
            m_author.id).roles
        user_is_c_lv5 = guild.get_role(c_lv5) in guild.get_member(
            m_author.id).roles
        if not user_is_c_lv4 and not user_is_c_lv5:
            clv = 3 if user_is_c_lv3 else 2 if user_is_c_lv2 else 1
            await m_ch.send(
                f"*<@{m_author.id}> is CrealanceLv{clv}. You need at least ClearanceLv4 to call the system.*"
            )
            return
        else:
            clv = 5 if user_is_c_lv5 else 4
            await m_ch.send(
                f"*<@{m_author.id}> is CrealanceLv{clv}. System was already came.*"
            )

            def check(m):
                if m.author.id != m_author.id: return 0
                if m.channel.id != m_ch.id: return 0
                return 1

            while True:
                await m_ch.send("* * * *")
                try:
                    remsg = await client.wait_for("message", check=check)
                except:
                    break
                else:
                    ctt = remsg.content
                    if ctt == 'close':
                        break
                    if ctt.startswith("psql"):
                        PG = pg
                        if ctt.startswith("psql2 "):
                            PG = pg2
                            cmd = ctt.split("psql2 ")[1]
                        elif ctt.startswith("psql1 "):
                            cmd = ctt.split("psql1 ")[1]
                        result = None
                        if "select" in cmd:
                            result = f"{PG.fetch(cmd + ';')}\n(DataCount『{len(PG.fetch(cmd))}』)"
                        else:
                            try:
                                PG.execute(cmd + ';')
                            except Exception as error:
                                result = f"{error}"
                            else:
                                result = True
                        await m_ch.send(f"```::DATABASE=> {cmd}```")
                        await m_ch.send(f"```py\n{result}```")

                    if ctt.startswith("player "):
                        pattern = r"^player (.+) (get_exp|lv|damaged|get_data|plus|get_item) (.+)"
                        result = re.match(pattern, ctt)
                        target_user = None
                        cmd = None
                        arg = None
                        if result:
                            user_key = result.group(1)
                            cmd = result.group(2)
                            arg = result.group(3)
                            if not user_key.isdigit():
                                target_user = discord.utils.get(
                                    m_guild.member, mention=user_key)
                            else:
                                target_user = client.get_user(int(user_key))
                            if target_user is None:
                                await m_ch.send(
                                    f"```Player[{user_key}] is None```")
                                return
                            player = box.players[target_user.id]
                            if cmd == "get_exp":
                                pattern = r"^(\d+)"
                                result = re.match(pattern, arg)
                                if result:
                                    exp = int(result.group(1))
                                    lvup_count = player.get_exp(int(exp))[1]
                                    await m_ch.send(
                                        f"```{target_user} Exp+{int(exp)} NowLv{player.lv()}```"
                                    )
                            if cmd == "lv":
                                pattern = r"^(\d+)"
                                result = re.match(pattern, arg)
                                if result:
                                    lv = player.lv() - int(result.group(1))
                                    await m_ch.send(
                                        f"```{target_user} NowLv{player.lv(lv)}```"
                                    )
                            if cmd == "damaged":
                                pattern = r"^(\d+)"
                                result = re.match(pattern, arg)
                                if result:
                                    set = player.damaged(int(result.group(1)))
                                    await m_ch.send(
                                        f"```{target_user} {set[0]}Damaged NowDefense{set[1]} HP({player.now_hp}/{player.max_hp})```"
                                    )
                            if cmd == "get_data":
                                result = player.get_data(arg)
                                await ch.send(
                                    "```py\nplayer.{arg} = {result}```")
                            if cmd == "get_item":
                                pattern = r"^(\d+) (\d+)"
                                result = re.match(pattern, arg)
                                if result:
                                    id, num = int(result.group(1)), int(
                                        result.group(2))
                                    result2 = status.get_item(
                                        player.user, id, num)
                                    if result2:
                                        await ch.send(
                                            "{target_user} got {item_name}x{num}"
                                        )

            await m_ch.send("*Completed. System was already closed.*")
Пример #6
0
async def battle_result(player, mob):
    types = ("Normal", "Elite", "Catastrophe", "WorldEnd", "Rare", "UltraRare",
             "UltraEro")
    reward_items = { # {id:(num,item was droped)}
        2:(randint(3,6),random()<=0.05 or mob.type in types[2:]),
        3:(randint(3,6),random()<=0.05 or mob.type in types[2:]),
        4:(randint(1,5),True),
        5:(randint(1,2),mob.name in ("モノリス",'ゴールド-モノリス') or mob.type in types[1:]),
        6:(randint(3,6),random()<=0.03 or mob.type in types[2:]),
        11:(randint(3,6),(random()<=0.05 and mob.lv()%10==0) or mob.type in ("UltraRare",)),
        13:(randint(3,6),(random()<=0.05 and mob.lv()%10==0) or mob.type in ("UltraRare",)),
        15:(randint(2,5),(random()<=0.05 and mob.lv()%100==0) or mob.type in ("UltraRare",)),
        17:(randint(2,5),(random()<=0.05 and mob.lv()%100==0) or mob.type in ("UltraRare",)),
        19:(randint(1,3),(random()<=0.05 and mob.lv()%100==0) or mob.type in ("UltraRare","UltraEro")),
        21:(randint(1,3),(random()<=0.05 and mob.lv()%100==0) or mob.type in ("UltraRare","UltraEro")),
        23:(randint(3,6),(random()<=0.025 or mob.type in types[1:])),
        25:(1,mob.name in ("ドワーフ") and random()<=0.01),
    }
    ch = mob.mob
    user = player.user
    result_em = stp_em = item_em = spawn_em = None
    anti_magic_em = None
    if mob.now_hp <= 0:
        if mob.ID() in box.anti_magic:
            box.anti_magic.remove(mob.ID())
        if mob.mob.id in box.nerf:
            del box.nerf[mob.mob.id]
        if mob.mob.id in box.stun:
            del box.stun[mob.mob.id]
        result_desc = ""
        now = datetime.now(JST).strftime("%H:%M %b")
        exp, money = mob.reward()[0] + 1, int(mob.reward()[1] /
                                              len(mob.battle_players))
        guild = client.get_guild(719165196861702205)
        if now in ['23:18 Sat']:
            exp *= 3
            await ch.send("**初代開発者**『今日生きているからといって、明日生きているとは限らない。』")
        print(
            f"『{mob.name: <10}』(Lv.{mob.lv()})を{[ str(client.get_user(i)) for i in mob.battle_players]}が討伐"
        )
        roles_mention = (
            '<@&800263879607189515>',
            '<@&800262422774415381>',
            '<@&763409546424352769>',
            '<@&800261859927654401>',
            '<@&800261583732604928>',
            '<@&763359264672579605>',
            '<@&763404511318245416>',
            '<@&799961431536697366>',
        )
        roles = tuple(
            [discord.utils.get(guild.roles, mention=i) for i in roles_mention])
        for p_id in mob.battle_players:
            p = box.players[p_id]
            EXP = exp
            member = guild.get_member(p_id)
            if member:
                for role in roles[:-1]:
                    if role in member.roles:
                        EXP += (exp * 0.1)
            EXP = int(EXP)
            up_exp, up_lv = p.get_exp(EXP)
            p.kill_count(1)
            p.money(money)
            if p.ID() == player.ID():
                result_desc += f"\n*<@{p_id}>*"
            else:
                result_desc += f"\n<@{p_id}>"
            result_desc += f"\n> Exp+{EXP} Cell+{money}"
            if up_lv > 0:
                result_desc += f"\n> LvUP {p.lv()-up_lv} → {p.lv()}"
            p.battle_end()
        result_em = discord.Embed(title="Result",
                                  description=result_desc,
                                  color=discord.Color.green())
        # ドロップアイテムfor #
        drop_item_text = ''
        member = guild.get_member(player.ID())
        user_is_frontier = False
        if member:
            user_is_frontier = roles[-1] in member.roles
        for id in reward_items:
            num, item_was_droped = reward_items[id]
            if item_was_droped:
                status.get_item(player.user, id, num)
                drop_item_text += f"{box.items_emoji[id]}×{num} "
            else:
                if user_is_frontier:
                    if random() <= 0.001:
                        status.get_item(player.user, id, num)
                        drop_item_text += f"(開拓者Bonus!!{box.items_emoji[id]}×{num}) "
        result_em.add_field(name=f"Drop Item",
                            value=f"<@{user.id}>\n>>> {drop_item_text}")
        if random() <= 0.001:
            player.now_stp(500)
            result_em.add_field(name=f"Lucky Bonus",
                                value=f"<@{user.id}>\n>>> STP+500")
        if mob.lv() % 100 == 0:
            player.money(1000)
            result_em.add_field(name=f"Last Attack Bonus",
                                value=f"<@{user.id}>\n>>> Cell+1000")
        if len([
                ch.name for ch in mob.mob.guild.text_channels
                if ch.name.startswith('🔧lock_lv1-')
        ]):
            ch_name = [
                ch.name for ch in mob.mob.guild.text_channels
                if ch.name.startswith('🔧lock_lv1-')
            ][0].split('🔧lock_lv1-')[1]
            if mob.mob.name.startswith(ch_name):
                lv_1_num = mob.lv() - 1
                mob.lv(plus=-lv_1_num)
            else:
                mob.lv(plus=1)
        else:
            mob.lv(plus=1)
        spawn_em = mob.battle_end()
        irregular_text = ''
        if mob.type in ("Elite", "UltraRare", ""):
            box.anti_magic.append(mob.ID())
            irregular_text += f"{mob.name} のアンチマジックエリアが発動!"
        if mob.type in ("WoldEnd", "UltraRare", ""):
            box.sleep[mob.ID()] = 3
            irregular_text += f"\n{mob.name} は眠っている…"
        if irregular_text != '':
            anti_magic_em = discord.Embed(description=irregular_text)
    return result_em, spawn_em, anti_magic_em
Пример #7
0
async def shop(client, ch, user):
    player = box.players[user.id]
    shop_em = discord.Embed(
        title="Shop",
        description=("`該当するサービスの番号を半角英数字で送信してください。`"
            + "\n`1.`アイテム購入"
            + "\n`2.`アイテム合成"
    ))
    shop_em_msg = await ch.send(embed=shop_em)
    def check(m):
        if not user.id == m.author.id:
            return 0
        return 1
    def check2(m):
        if not user.id == m.author.id:
            return 0
        if not m.content in ("y","Y","n","N"):
            return 0
        return 1
    try:
        msg = await client.wait_for("message", timeout=60, check=check)
    except asyncio.TimeoutError:
        await ch.send(f"冷やかしはお断りだよ!")
    else:
        respons = int(msg.content) if msg.content in ("1","2") else 0
        if respons == 1:
            service_em1 = discord.Embed(
                title="アイテム購入",
                description=("`該当するアイテムの番号と購入数を半角英数字で送信してください。\n例(HP回復薬を10個購入)『1 10』`"
                    + f"\n`1.`{items_emoji_a[2]}`HP回復薬 `[`100`cell]"
                    + f"\n`2.`{items_emoji_a[3]}`MP回復薬 `[`100`cell]"
                    + f"\n`3.`{items_emoji_a[4]}`魂の焔   `[`10`cell]"
                    + f"\n`4.`{items_emoji_a[5]}`砥 石   `[`500`cell]"
                    + f"\n`5.`{items_emoji_a[6]}`魔 石   `[`150`cell]"
                    + f"\n`6.`{items_emoji_a[7]}`魔 晶   `[`1000`cell]"
                    + f"\n`7.`{items_emoji_a[8]}`魔硬貨   `[`2000`cell]"
            ))
            await shop_em_msg.edit(embed=service_em1)
            try:
                msg = await client.wait_for("message", timeout=60, check=check)
            except asyncio.TimeoutError:
                await ch.send(f"冷やかしはお断りだよ!")
            else:
                pattern = r'^(\d+) (\d+)$'
                result = re.search(pattern, msg.content)
                if not result:
                    await ch.send('ちゃんと注文して')
                    return
                item_id, item_num = int(result.group(1))+1, int(result.group(2))
                cost_dict = {2:100,3:100,4:10,5:500,6:150,7:1000,8:2000}
                if player.money() < cost_dict[item_id]*item_num:
                    await ch.send(f"{cost_dict[item_id]*item_num-player.money()}cell程お金が足りないようです。")
                    return
                status.get_item(client,user,item_id,item_num)
                player.money(-cost_dict[item_id])
                await ch.send(f"{cost_dict[item_id]*item_num}cellで{items_name[item_id]}{items_emoji_a[item_id]}x{item_num}を購入しました。またのご来店をお待ちしております!")

        elif respons == 2:
            service_em2 = discord.Embed(
                title="アイテム購入",
                description=("`該当するアイテムの番号と購入数を半角英数字で送信してください。\n例(HP回復薬を10個購入)『1 10』`"
                    + f"\n`1.`{items_emoji_a[7]}`魔 晶   `[`500`cell {items_emoji_a[5]}×1 {items_emoji_a[6]}×1]"
                    + f"\n`2.`{items_emoji_a[8]}`魔硬貨   `[`750`cell {items_emoji_a[4]}×1 {items_emoji_a[5]}×1 {items_emoji_a[7]}×1]"
            ))
            await shop_em_msg.edit(embed=service_em2)
            try:
                msg = await client.wait_for("message", timeout=60, check=check)
            except asyncio.TimeoutError:
                await ch.send(f"冷やかしはお断りだよ!")
            else:
                pattern = r'^(\d+) (\d+)$'
                result = re.search(pattern, msg.content)
                if not result:
                    await ch.send('ちゃんと注文して')
                    return
                item_id, item_num = int(result.group(1))+6, int(result.group(2))
                item_name = items_name[item_id]
                item_dtd = pg.fetchdict(f"select item from player_tb where id = {user.id};")[0]["item"]
                material_dict = {
                    7:((5,1),(6,1)),
                    8:((4,1),(5,1),(7,1))}
                cost_dict = {7:500,8:750}
                husoku_text = ""
                for data in material_dict[item_id]:
                    i_name = items_name[data[0]]
                    if item_dtd[i_name] < data[1]*item_num:
                        husoku_text += f"{i_name}{items_emoji_a[data[0]]}×{data[1]*item_num-item_dtd[i_name]} "
                        continue
                    status.get_item(client,user,data[0],-data[1])
                if husoku_text != "":
                    await ch.send(f"{husoku_text}が足りないです。")
                    return
                if player.money() < cost_dict[item_id]*item_num:
                    await ch.send(f"{cost_dict[item_id]*item_num-player.money()}cell程お金が足りないようです。")
                    return
                status.get_item(client,user,item_id,item_num)
                player.money(-cost_dict[item_id])
                await ch.send(f"{cost_dict[item_id]*item_num}cellで{item_name}{items_emoji_a[item_id]}x{item_num}を合成しました。またのご来店をお待ちしております!")
Пример #8
0
async def cbt_proc(client, user, ch):
    if not user.id in box.players:
        print("box.playersに存在しないPlayer.idを取得")
        if not user.id in [i["id"] for i in pg.fetchdict(f"select id from player_tb;")]:
            box.players[user.id] = avatar.Player(client, user.id)
            print(f"Playerデータ挿入(battle.py->cbt_proc): {box.players[user.id].user}")
    player,mob = box.players[user.id],box.mobs[ch.id]
    if not player.battle_start(ch.id):
        channel = client.get_channel(player.battle_ch)
        if channel:
            await ch.send(f"<@{user.id}> は現在『{now_ch.mention}』で戦闘中です。")
            return
        await ch.send(f"<@{user.id}> が認識できないチャンネルで戦闘中。データの上書きを行ないます。")
        player.battle_end()
        if player.battle_start(ch.id):
            await ch.send(f"上書き完了")
        else:
            await ch.send(f"上書き失敗、戦闘に参加できていません。")
            return

    reward_items = { # {id:(num,item was droped)}
        2:(randint(3,6),random()<=0.05),
        3:(randint(3,6),random()<=0.05),
        4:(1,True),
        5:(choice((1,2)),mob.name in ("Golem",)),
        6:(randint(3,6),random()<=0.03)
    }
    if player.now_hp <= 0:
        await ch.send(f"<@{user.id}> は既に死亡しています。")
        return
    mob.player_join(user.id)

    # モンスターとの戦闘で使うダメージ、運の計算およびログの定義 #
    dmg1,dmg2 = calc.dmg(player.STR(), mob.defe()),calc.dmg(mob.str(), player.DEFE())
    dmg2 = int(dmg2*1.45) if mob.name=="古月" else dmg2
    log1_1 = log2_1 = ""

    # HPゲージ作成関数 #
    def hp_gauge(now, max):
        return "-"*20 if now<=0 else (int((now/max)*20)*"/")+((20-int((now/max)*20))*" ")

    a,b = random(),random()
    t,x = ("極",5) if a>=0.95 else ("超",2) if a>=0.9 else ("強",1.5) if a>=0.85 else ("",1)
    t2,x2 = ("極",5) if b>=0.95 else ("超",2) if b>=0.9 else ("強",1.5) if b>=0.85 else ("",1)
    t += "ダメージ!"
    t2 += "ダメージ!"
    
    # ダメージがない場合のメッセージ #
    def zero_dmg_text():
        text = ("華麗に躱した","完全に防いだ","当たらなかった","効かなかったようだ","無駄無駄無駄無駄無駄ァ!")
        return choice(text)

    # 戦闘処理(Player先手) #
    if player.AGI() >= mob.agi():
        log1_1 += f'+ {player.user}の攻撃->'
        dmg1 = round(x * dmg1)
        log1_1 += f"{str(dmg1)}の{t}" if dmg1!=0 else zero_dmg_text()
        log1_1 += f'\n{mob.name}({mob.cut_hp(dmg1)}/{mob.max_hp})\n[{hp_gauge(mob.now_hp, mob.max_hp)}]'
        log2_1 += f'{mob.name}を倒した!!' if mob.now_hp<=0 else f'- {mob.name}の攻撃->'
        if not mob.now_hp <= 0:
            dmg2 = round(x2 * dmg2)
            log2_1 += f"{str(dmg2)}の{t2}" if dmg2!=0 else zero_dmg_text()
            log2_1 += f'\n{user}({player.cut_hp(dmg2)}/{player.max_hp})\n[{hp_gauge(player.now_hp, player.max_hp)}]'

    # 戦闘処理(Player後手) #
    else:
        log1_1 += f'- {mob.name}の攻撃->'
        dmg2 = round(x * dmg2)
        log1_1 += f"{str(dmg2)}の{t}" if dmg2!=0 else zero_dmg_text()
        log1_1 += f'\n{user}({player.cut_hp(dmg2)}/{player.max_hp})\n[{hp_gauge(player.now_hp, player.max_hp)}]'
        log2_1 += f'{user}はやられてしまった!!' if player.now_hp<=0 else f'- {user}の攻撃->'
        if not player.now_hp <= 0 :
            dmg1 = round(x2 * dmg1)
            log2_1 += f"{str(dmg1)}の{t2}" if dmg1!=0 else zero_dmg_text()
            log2_1 += f'\n{mob.name}({mob.cut_hp(dmg1)}/{mob.max_hp})\n[{hp_gauge(mob.now_hp, mob.max_hp)}]\n'

    battle_log = f"```diff\n{log1_1}``````diff\n{log2_1}```"

    embed = em = item_em = spawn_embed = None
    if mob.now_hp <= 0 :
        desc = ""
        now = datetime.now(JST).strftime("%H:%M")
        if  now in ['23:18']:
            get_exp *= 16
            await ch.send("????『幸運を。死したものより祝福を。』")
        exp,money = mob.reward()[0],int(mob.reward()[1]/len(mob.battle_players))
        print("戦闘参加していたPlayer: ",mob.battle_players)
        for p_id in mob.battle_players:
            p = box.players[p_id]
            up_exp, up_lv = p.get_exp(exp)
            p.kill_count(1)
            p.money(money)
            desc += f"<@{p_id}> Exp+{exp} Cell+{money} "
            if up_lv > 0:
                desc += f"\nLvUP {p.lv()-up_lv} -> {p.lv()}"
            drop_item_text = ""
            # ドロップアイテムfor #
            for id in reward_items:
                num,item_was_droped = reward_items[id]
                if item_was_droped:
                    status.get_item(client,user,id,num)
                    drop_item_text += f"{item_emoji_a[id]}×{num} "
            desc += f"\nDropItem: {'-' if not drop_item_text else drop_item_text}"
        if random() <= 0.01:
            player.now_stp(mob.lv())
            em = discord.Embed(description=f"<@{user.id}> STP+{mob.lv()}")
        embed = discord.Embed(title="Result",description=desc,color=discord.Color.green())
        mob.lv(1)
        spawn_embed = mob.battle_end()
    
    await ch.send(content=battle_log,embed = embed)
    if em: await ch.send(embed=em)
    if item_em: await ch.send(embed=item_em)
    if spawn_embed: await ch.send(embed=spawn_embed)