diff --git a/commands/CardCommand.py b/commands/CardCommand.py index b6f8542..440b2e4 100644 --- a/commands/CardCommand.py +++ b/commands/CardCommand.py @@ -1,6 +1,7 @@ import datetime import io +import aiohttp import discord import i18n from discord.ext import commands @@ -34,7 +35,7 @@ async def card_command(self, ctx, uid: discord.Option(required=False, input_type def get_view(): return View(selecter, calculation_selecter, generate_button, uid_change_button, uid_hide_button, - roll_hide_button, timeout=600) + roll_hide_button, timeout=3000) def update_uid_hide_button(): if is_uid_hide: @@ -52,12 +53,41 @@ def update_roll_hide_button(): roll_hide_button.style = discord.ButtonStyle.gray roll_hide_button.label = f"{i18n.t('message.hide_roll', locale=lang) + i18n.t('message.off', locale=lang)}" + async def update_calc_selector(): + if len(json_parsed) == 0: + calculation_selecter.options = [discord.SelectOption(label="Loading...", default=True, value="no_score")] + return + chara_types = [] + chara_id = json_parsed["characters"][select_number]["id"] + async with aiohttp.ClientSession() as session: + async with session.get(f"https://hcs.lenlino.com/weight_list/" + f"{chara_id}") as response: + chara_type_json = await response.json() + is_first = True + for k, v in chara_type_json.items(): + if "lang" in v and v["lang"]["jp"] != "string": + jp_name = v["lang"]["jp"] + en_name = v["lang"]["en"] + else: + jp_name = i18n.t("message.compatibility_criteria", locale=lang) + en_name = "compatibility" + chara_types.append(discord.SelectOption(label=jp_name, value=k, default=is_first)) + if is_first: + is_first = False + chara_types.append( + discord.SelectOption(label=i18n.t("message.no_score", locale=lang), default=is_first, value="no_score")) + calculation_selecter.options = chara_types + async def selector_callback(interaction): try: nonlocal select_number select_number = int(selecter.values[0]) + await update_calc_selector() + update_selector_option() + if len(selecter.options) != 0: + await ctx.edit(view=get_view()) await interaction.response.send_message("") - except discord.errors.HTTPException: + except discord.errors.HTTPException as ex: pass async def calculation_selector_callback(interaction): @@ -116,8 +146,8 @@ async def button_callback(interaction): await set_uid(uid) return image_binary.write(panel_img_result['img']) - #panel_img = panel_img_result['img'] - #panel_img.save(image_binary, 'PNG') + # panel_img = panel_img_result['img'] + # panel_img.save(image_binary, 'PNG') image_binary.seek(0) dt_now = datetime.datetime.now() file = discord.File(image_binary, f"hertacardsys_{dt_now.strftime('%Y%m%d%H%M')}.png") @@ -138,7 +168,7 @@ async def button_callback(interaction): res_embed.add_field(name=i18n.t(f'message.weight', locale=lang), value=weight_text) score_rank = panel_img_result["header"] - #score_rank = generate.utils.get_score_rank(int(avatar_id), uid, panel_img_result['score']) + # score_rank = generate.utils.get_score_rank(int(avatar_id), uid, panel_img_result['score']) # 統計 rank_text = "" rank_text += f"{i18n.t('message.Rank', locale=lang)}: {score_rank['rank']} / {score_rank['data_count']}\n" @@ -164,6 +194,13 @@ async def uid_change_modal_callback(modal_interaction): modal.callback = uid_change_modal_callback await interaction.response.send_modal(modal) + def update_selector_option(): + count = 0 + for v in selecter.options: + is_select = count == select_number + selecter.options[count].default = is_select + count += 1 + async def set_uid(changed_uid): nonlocal uid nonlocal user_detail_dict @@ -180,9 +217,11 @@ async def set_uid(changed_uid): selecter.append_option( discord.SelectOption(label=i["name"], value=str(index), default=True if index == select_number else False)) + if len(selecter.options) == 0: embed.description += "\n" + i18n.t("message.error_no_chara_set", locale=lang) else: + await update_calc_selector() await ctx.edit(view=get_view()) elif json_parsed["detail"] == 400 or json_parsed["detail"] == 404: embed.description = i18n.t("message.error_not_exist_uid", locale=lang) @@ -206,10 +245,8 @@ async def set_uid(changed_uid): uid_change_button.callback = uid_change_button_callback uid_change_button.row = 4 calculation_selecter.callback = calculation_selector_callback - calculation_selecter.options = [ - discord.SelectOption(label=i18n.t("message.compatibility_criteria", locale=lang), default=True, - value="compatibility"), - discord.SelectOption(label=i18n.t("message.no_score", locale=lang), default=False, value="no_score")] + await update_calc_selector() + calculation_selecter.row = 1 uid_hide_button.row = 4 uid_hide_button.callback = uid_hide_button_callback diff --git a/commands/ChangeWeightCommand.py b/commands/ChangeWeightCommand.py new file mode 100644 index 0000000..47bea49 --- /dev/null +++ b/commands/ChangeWeightCommand.py @@ -0,0 +1,421 @@ +import datetime +import io +import json + +import aiohttp +import discord +import i18n +from discord.ext import commands +from discord.ui import Select, Button, Modal, View + +import main +import utils.Weight +from generate.generate import generate_panel +from generate.utils import get_json_from_url, get_mihomo_lang + + +class ChangeWeightCommand(commands.Cog): + + async def get_chara_types(ctx: discord.AutocompleteContext): + chara_id = ctx.options["chara_id"] + if chara_id is not None: + chara_types = [] + async with aiohttp.ClientSession() as session: + async with session.get(f"https://hcs.lenlino.com/weight_list/" + f"{chara_id}") as response: + chara_type_json = await response.json() + for k, v in chara_type_json.items(): + if "lang" in v and v["lang"]["jp"] != "string": + jp_name = v["lang"]["jp"] + en_name = v["lang"]["en"] + else: + jp_name = "相性基準" + en_name = "def" + chara_types.append(discord.OptionChoice(name=jp_name, value=en_name)) + return chara_types + else: + return ["chara_idを先に指定してください"] + + @discord.slash_command(name="change_weight", description="Change weight", guild_ids=["1118740618882072596"]) + async def change_weight_command(self, ctx, + chara_id: discord.Option(required=True, description="キャラ", input_type=str, + autocomplete=discord.utils.basic_autocomplete( + main.characters)), + type_id: discord.Option(required=True, description="基準名", input_type=str, + autocomplete=discord.utils.basic_autocomplete( + get_chara_types))): + await ctx.defer() + weight = utils.Weight.Weight() + base_weight = utils.Weight.Weight() + if type_id == "def": + weight_id = f"{chara_id}" + else: + weight_id = f"{chara_id}_{type_id}" + async with aiohttp.ClientSession() as session: + async with session.get(f"https://hcs.lenlino.com/weight_list/{weight_id}" + ) as response: + chara_type_json = await response.json() + weight = weight.model_validate(chara_type_json[weight_id]) + base_weight = base_weight.model_validate(chara_type_json[weight_id]) + lang = get_mihomo_lang(ctx.interaction.locale) + embed = discord.Embed( + title=main.characters_name[chara_id] + ) + + async def update_embed(): + embed = discord.Embed( + title=f"{main.characters_name[chara_id]}・{weight.lang.jp}(投票中)", + description="修正申請", + colour=discord.Colour.gold() + ) + embed_value = "" + base_weight_model = base_weight.model_dump() + for k, v in weight.main.w3.model_dump().items(): + base_value = base_weight_model["main"]["w3"][k] + if base_value == v: + continue + embed_value += f"{i18n.t('message.' + k, locale=lang)}: {base_value}->{v}\n" + if embed_value != "": + embed.add_field(name="胴", value=embed_value) + embed_value = "" + for k, v in weight.main.w4.model_dump().items(): + base_value = base_weight_model["main"]["w4"][k] + if base_value == v: + continue + embed_value += f"{i18n.t('message.' + k, locale=lang)}: {base_value}->{v}\n" + if embed_value != "": + embed.add_field(name="脚", value=embed_value) + embed_value = "" + for k, v in weight.main.w5.model_dump().items(): + base_value = base_weight_model["main"]["w5"][k] + if base_value == v: + continue + embed_value += f"{i18n.t('message.' + k, locale=lang)}: {base_value}->{v}\n" + if embed_value != "": + embed.add_field(name="オーブ", value=embed_value) + embed_value = "" + for k, v in weight.main.w6.model_dump().items(): + base_value = base_weight_model["main"]["w6"][k] + if base_value == v: + continue + embed_value += f"{i18n.t('message.' + k, locale=lang)}: {base_value}->{v}\n" + if embed_value != "": + embed.add_field(name="縄", value=embed_value) + embed_value = "" + for k, v in weight.weight.model_dump().items(): + base_value = base_weight_model["weight"][k] + if base_value == v: + continue + embed_value += f"{i18n.t('message.' + k, locale=lang)}: {base_value}->{v}\n" + if embed_value != "": + embed.add_field(name="サブステ", value=embed_value) + await ctx.interaction.edit(embed=embed) + + class MyView(discord.ui.View): + @discord.ui.button(label="胴1") + async def button_callback_31(self, button, interaction): + await interaction.response.send_modal(Modal31(title="胴1")) + + @discord.ui.button(label="胴2") + async def button_callback_32(self, button, interaction): + await interaction.response.send_modal(Modal32(title="胴2")) + + @discord.ui.button(label="脚1") + async def button_callback_41(self, button, interaction): + await interaction.response.send_modal(Modal41(title="脚1")) + + @discord.ui.button(label="オーブ1") + async def button_callback_51(self, button, interaction): + await interaction.response.send_modal(Modal51(title="オーブ1")) + + @discord.ui.button(label="オーブ2") + async def button_callback_52(self, button, interaction): + await interaction.response.send_modal(Modal52(title="オーブ2")) + + @discord.ui.button(label="縄1") + async def button_callback_61(self, button, interaction): + await interaction.response.send_modal(Modal61(title="縄1")) + + @discord.ui.button(label="サブステ1") + async def button_callback_s1(self, button, interaction): + await interaction.response.send_modal(Modals1(title="サブステ1")) + + @discord.ui.button(label="サブステ2") + async def button_callback_s2(self, button, interaction): + await interaction.response.send_modal(Modals2(title="サブステ2")) + + @discord.ui.button(label="サブステ3") + async def button_callback_s3(self, button, interaction): + await interaction.response.send_modal(Modals3(title="サブステ3")) + + @discord.ui.button(label="送信", style=discord.ButtonStyle.primary) + async def button_callback_send(self, button, interaction): + nonlocal weight + weight_model = weight.model_dump() + base_weight_model = base_weight.model_dump() + for k, v in weight.main.w3.model_dump().items(): + base_value = base_weight_model["main"]["w3"][k] + if base_value == v: + weight_model["main"]["w3"][k] = 0 + for k, v in weight.main.w4.model_dump().items(): + base_value = base_weight_model["main"]["w4"][k] + if base_value == v: + weight_model["main"]["w4"][k] = 0 + for k, v in weight.main.w5.model_dump().items(): + base_value = base_weight_model["main"]["w5"][k] + if base_value == v: + weight_model["main"]["w5"][k] = 0 + for k, v in weight.main.w6.model_dump().items(): + base_value = base_weight_model["main"]["w6"][k] + if base_value == v: + weight_model["main"]["w6"][k] = 0 + for k, v in weight.weight.model_dump().items(): + base_value = base_weight_model["weight"][k] + if base_value == v: + weight_model["weight"][k] = 0 + + weight = weight.model_validate(weight_model) + attachment = discord.File(fp=io.BytesIO(bytes(weight.model_dump_json(), encoding="utf-8")), + filename=f"{chara_id}.json") + await interaction.edit(file=attachment, view=None) + await interaction.message.add_reaction("⭕") + await interaction.message.add_reaction("❌") + await interaction.message.create_thread(name="申請理由など") + + class Modal31(discord.ui.Modal): + def __init__(self, *args, **kwargs) -> None: + super().__init__(*args, **kwargs) + + self.add_item( + discord.ui.InputText(label=i18n.t('message.HPAddedRatio', locale=lang), min_length=3, max_length=3, + value=str(weight.main.w3.HPAddedRatio))) + self.add_item(discord.ui.InputText(label=i18n.t('message.AttackAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w3.AttackAddedRatio))) + self.add_item(discord.ui.InputText(label=i18n.t('message.DefenceAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w3.DefenceAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.CriticalChanceBase', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w3.CriticalChanceBase))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.CriticalDamageBase', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w3.CriticalDamageBase))) + + async def callback(self, interaction: discord.Interaction): + weight.main.w3.HPAddedRatio = float(self.children[0].value) + weight.main.w3.AttackAddedRatio = float(self.children[1].value) + weight.main.w3.DefenceAddedRatio = float(self.children[2].value) + weight.main.w3.CriticalChanceBase = float(self.children[3].value) + weight.main.w3.CriticalDamageBase = float(self.children[4].value) + await update_embed() + await interaction.response.defer() + + class Modal32(discord.ui.Modal): + def __init__(self, *args, **kwargs) -> None: + super().__init__(*args, **kwargs) + + self.add_item( + discord.ui.InputText(label=i18n.t('message.HealRatioBase', locale=lang), min_length=3, max_length=3, + value=str(weight.main.w3.HealRatioBase))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.StatusProbabilityBase', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w3.StatusProbabilityBase))) + + async def callback(self, interaction: discord.Interaction): + weight.main.w3.HealRatioBase = float(self.children[0].value) + weight.main.w3.StatusProbabilityBase = float(self.children[1].value) + await update_embed() + await interaction.response.defer() + + class Modal41(discord.ui.Modal): + def __init__(self, *args, **kwargs) -> None: + super().__init__(*args, **kwargs) + + self.add_item( + discord.ui.InputText(label=i18n.t('message.HPAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w4.HPAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.AttackAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w4.AttackAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.DefenceAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w4.DefenceAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.SpeedDelta', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w4.SpeedDelta))) + + async def callback(self, interaction: discord.Interaction): + weight.main.w4.HPAddedRatio = float(self.children[0].value) + weight.main.w4.AttackAddedRatio = float(self.children[1].value) + weight.main.w4.DefenceAddedRatio = float(self.children[2].value) + weight.main.w4.SpeedDelta = float(self.children[3].value) + await update_embed() + await interaction.response.defer() + + class Modal51(discord.ui.Modal): + def __init__(self, *args, **kwargs) -> None: + super().__init__(*args, **kwargs) + + self.add_item( + discord.ui.InputText(label=i18n.t('message.HPAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w5.HPAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.AttackAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w5.AttackAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.DefenceAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w5.DefenceAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.PhysicalAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w5.PhysicalAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.FireAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w5.FireAddedRatio))) + + async def callback(self, interaction: discord.Interaction): + weight.main.w5.HPAddedRatio = float(self.children[0].value) + weight.main.w5.AttackAddedRatio = float(self.children[1].value) + weight.main.w5.DefenceAddedRatio = float(self.children[2].value) + weight.main.w5.PhysicalAddedRatio = float(self.children[3].value) + weight.main.w5.FireAddedRatio = float(self.children[4].value) + await update_embed() + await interaction.response.defer() + + class Modal52(discord.ui.Modal): + def __init__(self, *args, **kwargs) -> None: + super().__init__(*args, **kwargs) + + self.add_item( + discord.ui.InputText(label=i18n.t('message.IceAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w5.IceAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.ThunderAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w5.ThunderAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.WindAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w5.WindAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.QuantumAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w5.QuantumAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.ImaginaryAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w5.ImaginaryAddedRatio))) + + async def callback(self, interaction: discord.Interaction): + weight.main.w5.IceAddedRatio = float(self.children[0].value) + weight.main.w5.ThunderAddedRatio = float(self.children[1].value) + weight.main.w5.WindAddedRatio = float(self.children[2].value) + weight.main.w5.QuantumAddedRatio = float(self.children[3].value) + weight.main.w5.ImaginaryAddedRatio = float(self.children[4].value) + await update_embed() + await interaction.response.defer() + + class Modal61(discord.ui.Modal): + def __init__(self, *args, **kwargs) -> None: + super().__init__(*args, **kwargs) + + self.add_item( + discord.ui.InputText(label=i18n.t('message.BreakDamageAddedRatioBase', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w6.BreakDamageAddedRatioBase))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.SPRatioBase', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w6.SPRatioBase))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.HPAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w6.HPAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.AttackAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w6.AttackAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.DefenceAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w6.DefenceAddedRatio))) + + async def callback(self, interaction: discord.Interaction): + weight.main.w6.BreakDamageAddedRatioBase = float(self.children[0].value) + weight.main.w6.SPRatioBase = float(self.children[1].value) + weight.main.w6.HPAddedRatio = float(self.children[2].value) + weight.main.w6.AttackAddedRatio = float(self.children[3].value) + weight.main.w6.DefenceAddedRatio = float(self.children[4].value) + await update_embed() + await interaction.response.defer() + + class Modals1(discord.ui.Modal): + def __init__(self, *args, **kwargs) -> None: + super().__init__(*args, **kwargs) + + self.add_item( + discord.ui.InputText(label=i18n.t('message.HPDelta', locale=lang), min_length=3, + max_length=3, value=str(weight.weight.HPDelta))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.AttackDelta', locale=lang), min_length=3, + max_length=3, value=str(weight.weight.AttackDelta))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.DefenceDelta', locale=lang), min_length=3, + max_length=3, value=str(weight.weight.DefenceDelta))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.HPAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.weight.HPAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.AttackAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.weight.AttackAddedRatio))) + + async def callback(self, interaction: discord.Interaction): + weight.weight.HPDelta = float(self.children[0].value) + weight.weight.AttackDelta = float(self.children[1].value) + weight.weight.DefenceDelta = float(self.children[2].value) + weight.weight.HPAddedRatio = float(self.children[3].value) + weight.weight.AttackAddedRatio = float(self.children[4].value) + await update_embed() + await interaction.response.defer() + + class Modals2(discord.ui.Modal): + def __init__(self, *args, **kwargs) -> None: + super().__init__(*args, **kwargs) + + self.add_item( + discord.ui.InputText(label=i18n.t('message.DefenceAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.weight.DefenceAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.SpeedDelta', locale=lang), min_length=3, + max_length=3, value=str(weight.weight.SpeedDelta))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.CriticalChanceBase', locale=lang), min_length=3, + max_length=3, value=str(weight.weight.CriticalChanceBase))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.CriticalDamageBase', locale=lang), min_length=3, + max_length=3, value=str(weight.weight.CriticalDamageBase))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.StatusProbabilityBase', locale=lang), min_length=3, + max_length=3, value=str(weight.weight.StatusProbabilityBase))) + + async def callback(self, interaction: discord.Interaction): + weight.weight.DefenceAddedRatio = float(self.children[0].value) + weight.weight.SpeedDelta = float(self.children[1].value) + weight.weight.CriticalChanceBase = float(self.children[2].value) + weight.weight.CriticalDamageBase = float(self.children[3].value) + weight.weight.StatusProbabilityBase = float(self.children[4].value) + await update_embed() + await interaction.response.defer() + + class Modals3(discord.ui.Modal): + def __init__(self, *args, **kwargs) -> None: + super().__init__(*args, **kwargs) + + self.add_item( + discord.ui.InputText(label=i18n.t('message.StatusResistanceBase', locale=lang), min_length=3, + max_length=3, value=str(weight.weight.StatusResistanceBase))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.BreakDamageAddedRatioBase', locale=lang), min_length=3, + max_length=3, value=str(weight.weight.BreakDamageAddedRatioBase))) + + async def callback(self, interaction: discord.Interaction): + weight.weight.StatusResistanceBase = float(self.children[0].value) + weight.weight.BreakDamageAddedRatioBase = float(self.children[1].value) + await update_embed() + await interaction.response.defer() + + await ctx.send_followup(view=MyView()) + await update_embed() + + +def setup(bot): # this is called by Pycord to setup the cog + bot.add_cog(ChangeWeightCommand(bot)) # add the cog to the bot diff --git a/commands/CreateWeightCommand.py b/commands/CreateWeightCommand.py new file mode 100644 index 0000000..f13af4f --- /dev/null +++ b/commands/CreateWeightCommand.py @@ -0,0 +1,345 @@ +import datetime +import io + +import discord +import i18n +from discord.ext import commands +from discord.ui import Select, Button, Modal, View + +import main +import utils.Weight +from generate.generate import generate_panel +from generate.utils import get_json_from_url, get_mihomo_lang + + +class CreateWeightCommand(commands.Cog): + + async def get_chara_types(ctx: discord.AutocompleteContext): + return main.characters + + @discord.slash_command(name="create_weight", description="Create weight", guild_ids=["1118740618882072596"]) + async def create_weight_command(self, ctx, + chara_id: discord.Option(required=True, description="キャラ", input_type=str, + autocomplete=discord.utils.basic_autocomplete( + main.characters)), + jp_name: discord.Option(required=True, description="基準の日本語名(攻撃型、回復型など)"), + en_name: discord.Option(required=True, description="基準の英語名・スペース、記号禁止(attack、healなど)")): + await ctx.defer() + weight = utils.Weight.Weight() + lang = get_mihomo_lang(ctx.interaction.locale) + embed = discord.Embed( + title=main.characters_name[chara_id] + ) + weight.lang.jp = jp_name + weight.lang.en = en_name + + async def update_embed(): + embed = discord.Embed( + title=f"{main.characters_name[chara_id]}・{jp_name}(投票中)", + description="追加申請", + colour=discord.Colour.gold() + ) + embed_value = "" + for k, v in weight.main.w3.model_dump().items(): + embed_value += f"{i18n.t('message.' + k, locale=lang)}: {v}\n" + embed.add_field(name="胴", value=embed_value) + embed_value = "" + for k, v in weight.main.w4.model_dump().items(): + embed_value += f"{i18n.t('message.' + k, locale=lang)}: {v}\n" + embed.add_field(name="脚", value=embed_value) + embed_value = "" + for k, v in weight.main.w4.model_dump().items(): + embed_value += f"{i18n.t('message.' + k, locale=lang)}: {v}\n" + embed.add_field(name="オーブ", value=embed_value) + embed_value = "" + for k, v in weight.main.w5.model_dump().items(): + embed_value += f"{i18n.t('message.' + k, locale=lang)}: {v}\n" + embed.add_field(name="縄", value=embed_value) + embed_value = "" + for k, v in weight.weight.model_dump().items(): + embed_value += f"{i18n.t('message.' + k, locale=lang)}: {v}\n" + embed.add_field(name="サブステ", value=embed_value) + await ctx.interaction.edit(embed=embed) + + class MyView(discord.ui.View): + @discord.ui.button(label="胴1") + async def button_callback_31(self, button, interaction): + await interaction.response.send_modal(Modal31(title="胴1")) + + @discord.ui.button(label="胴2") + async def button_callback_32(self, button, interaction): + await interaction.response.send_modal(Modal32(title="胴2")) + + @discord.ui.button(label="脚1") + async def button_callback_41(self, button, interaction): + await interaction.response.send_modal(Modal41(title="脚1")) + + @discord.ui.button(label="オーブ1") + async def button_callback_51(self, button, interaction): + await interaction.response.send_modal(Modal51(title="オーブ1")) + + @discord.ui.button(label="オーブ2") + async def button_callback_52(self, button, interaction): + await interaction.response.send_modal(Modal52(title="オーブ2")) + + @discord.ui.button(label="縄1") + async def button_callback_61(self, button, interaction): + await interaction.response.send_modal(Modal61(title="縄1")) + + @discord.ui.button(label="サブステ1") + async def button_callback_s1(self, button, interaction): + await interaction.response.send_modal(Modals1(title="サブステ1")) + + @discord.ui.button(label="サブステ2") + async def button_callback_s2(self, button, interaction): + await interaction.response.send_modal(Modals2(title="サブステ2")) + + @discord.ui.button(label="サブステ3") + async def button_callback_s3(self, button, interaction): + await interaction.response.send_modal(Modals3(title="サブステ3")) + + @discord.ui.button(label="送信", style=discord.ButtonStyle.primary) + async def button_callback_send(self, button, interaction): + attachment = discord.File(fp=io.BytesIO(bytes(weight.model_dump_json(), encoding="utf-8")), filename=f"{chara_id}.json") + await interaction.edit(file=attachment, view=None) + await interaction.message.add_reaction("⭕") + await interaction.message.add_reaction("❌") + await interaction.message.create_thread(name="申請理由など") + + class Modal31(discord.ui.Modal): + def __init__(self, *args, **kwargs) -> None: + super().__init__(*args, **kwargs) + + self.add_item( + discord.ui.InputText(label=i18n.t('message.HPAddedRatio', locale=lang), min_length=3, max_length=3, + value=str(weight.main.w3.HPAddedRatio))) + self.add_item(discord.ui.InputText(label=i18n.t('message.AttackAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w3.AttackAddedRatio))) + self.add_item(discord.ui.InputText(label=i18n.t('message.DefenceAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w3.DefenceAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.CriticalChanceBase', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w3.CriticalChanceBase))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.CriticalDamageBase', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w3.CriticalDamageBase))) + + async def callback(self, interaction: discord.Interaction): + weight.main.w3.HPAddedRatio = float(self.children[0].value) + weight.main.w3.AttackAddedRatio = float(self.children[1].value) + weight.main.w3.DefenceAddedRatio = float(self.children[2].value) + weight.main.w3.CriticalChanceBase = float(self.children[3].value) + weight.main.w3.CriticalDamageBase = float(self.children[4].value) + await update_embed() + await interaction.response.defer() + + class Modal32(discord.ui.Modal): + def __init__(self, *args, **kwargs) -> None: + super().__init__(*args, **kwargs) + + self.add_item( + discord.ui.InputText(label=i18n.t('message.HealRatioBase', locale=lang), min_length=3, max_length=3, + value=str(weight.main.w3.HealRatioBase))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.StatusProbabilityBase', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w3.StatusProbabilityBase))) + + async def callback(self, interaction: discord.Interaction): + weight.main.w3.HealRatioBase = float(self.children[0].value) + weight.main.w3.StatusProbabilityBase = float(self.children[1].value) + await update_embed() + await interaction.response.defer() + + class Modal41(discord.ui.Modal): + def __init__(self, *args, **kwargs) -> None: + super().__init__(*args, **kwargs) + + self.add_item( + discord.ui.InputText(label=i18n.t('message.HPAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w4.HPAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.AttackAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w4.AttackAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.DefenceAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w4.DefenceAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.SpeedDelta', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w4.SpeedDelta))) + + async def callback(self, interaction: discord.Interaction): + weight.main.w4.HPAddedRatio = float(self.children[0].value) + weight.main.w4.AttackAddedRatio = float(self.children[1].value) + weight.main.w4.DefenceAddedRatio = float(self.children[2].value) + weight.main.w4.SpeedDelta = float(self.children[3].value) + await update_embed() + await interaction.response.defer() + + class Modal51(discord.ui.Modal): + def __init__(self, *args, **kwargs) -> None: + super().__init__(*args, **kwargs) + + self.add_item( + discord.ui.InputText(label=i18n.t('message.HPAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w5.HPAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.AttackAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w5.AttackAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.DefenceAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w5.DefenceAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.PhysicalAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w5.PhysicalAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.FireAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w5.FireAddedRatio))) + + async def callback(self, interaction: discord.Interaction): + weight.main.w5.HPAddedRatio = float(self.children[0].value) + weight.main.w5.AttackAddedRatio = float(self.children[1].value) + weight.main.w5.DefenceAddedRatio = float(self.children[2].value) + weight.main.w5.PhysicalAddedRatio = float(self.children[3].value) + weight.main.w5.FireAddedRatio = float(self.children[4].value) + await update_embed() + await interaction.response.defer() + + class Modal52(discord.ui.Modal): + def __init__(self, *args, **kwargs) -> None: + super().__init__(*args, **kwargs) + + self.add_item( + discord.ui.InputText(label=i18n.t('message.IceAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w5.IceAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.ThunderAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w5.ThunderAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.WindAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w5.WindAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.QuantumAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w5.QuantumAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.ImaginaryAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w5.ImaginaryAddedRatio))) + + async def callback(self, interaction: discord.Interaction): + weight.main.w5.IceAddedRatio = float(self.children[0].value) + weight.main.w5.ThunderAddedRatio = float(self.children[1].value) + weight.main.w5.WindAddedRatio = float(self.children[2].value) + weight.main.w5.QuantumAddedRatio = float(self.children[3].value) + weight.main.w5.ImaginaryAddedRatio = float(self.children[4].value) + await update_embed() + await interaction.response.defer() + + class Modal61(discord.ui.Modal): + def __init__(self, *args, **kwargs) -> None: + super().__init__(*args, **kwargs) + + self.add_item( + discord.ui.InputText(label=i18n.t('message.BreakDamageAddedRatioBase', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w6.BreakDamageAddedRatioBase))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.SPRatioBase', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w6.SPRatioBase))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.HPAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w6.HPAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.AttackAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w6.AttackAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.DefenceAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.main.w6.DefenceAddedRatio))) + + async def callback(self, interaction: discord.Interaction): + weight.main.w6.BreakDamageAddedRatioBase = float(self.children[0].value) + weight.main.w6.SPRatioBase = float(self.children[1].value) + weight.main.w6.HPAddedRatio = float(self.children[2].value) + weight.main.w6.AttackAddedRatio = float(self.children[3].value) + weight.main.w6.DefenceAddedRatio = float(self.children[4].value) + await update_embed() + await interaction.response.defer() + + class Modals1(discord.ui.Modal): + def __init__(self, *args, **kwargs) -> None: + super().__init__(*args, **kwargs) + + self.add_item( + discord.ui.InputText(label=i18n.t('message.HPDelta', locale=lang), min_length=3, + max_length=3, value=str(weight.weight.HPDelta))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.AttackDelta', locale=lang), min_length=3, + max_length=3, value=str(weight.weight.AttackDelta))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.DefenceDelta', locale=lang), min_length=3, + max_length=3, value=str(weight.weight.DefenceDelta))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.HPAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.weight.HPAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.AttackAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.weight.AttackAddedRatio))) + + async def callback(self, interaction: discord.Interaction): + weight.weight.HPDelta = float(self.children[0].value) + weight.weight.AttackDelta = float(self.children[1].value) + weight.weight.DefenceDelta = float(self.children[2].value) + weight.weight.HPAddedRatio = float(self.children[3].value) + weight.weight.AttackAddedRatio = float(self.children[4].value) + await update_embed() + await interaction.response.defer() + + class Modals2(discord.ui.Modal): + def __init__(self, *args, **kwargs) -> None: + super().__init__(*args, **kwargs) + + self.add_item( + discord.ui.InputText(label=i18n.t('message.DefenceAddedRatio', locale=lang), min_length=3, + max_length=3, value=str(weight.weight.DefenceAddedRatio))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.SpeedDelta', locale=lang), min_length=3, + max_length=3, value=str(weight.weight.SpeedDelta))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.CriticalChanceBase', locale=lang), min_length=3, + max_length=3, value=str(weight.weight.CriticalChanceBase))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.CriticalDamageBase', locale=lang), min_length=3, + max_length=3, value=str(weight.weight.CriticalDamageBase))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.StatusProbabilityBase', locale=lang), min_length=3, + max_length=3, value=str(weight.weight.StatusProbabilityBase))) + + async def callback(self, interaction: discord.Interaction): + weight.weight.DefenceAddedRatio = float(self.children[0].value) + weight.weight.SpeedDelta = float(self.children[1].value) + weight.weight.CriticalChanceBase = float(self.children[2].value) + weight.weight.CriticalDamageBase = float(self.children[3].value) + weight.weight.StatusProbabilityBase = float(self.children[4].value) + await update_embed() + await interaction.response.defer() + + class Modals3(discord.ui.Modal): + def __init__(self, *args, **kwargs) -> None: + super().__init__(*args, **kwargs) + + self.add_item( + discord.ui.InputText(label=i18n.t('message.StatusResistanceBase', locale=lang), min_length=3, + max_length=3, value=str(weight.weight.StatusResistanceBase))) + self.add_item( + discord.ui.InputText(label=i18n.t('message.BreakDamageAddedRatioBase', locale=lang), min_length=3, + max_length=3, value=str(weight.weight.BreakDamageAddedRatioBase))) + + async def callback(self, interaction: discord.Interaction): + weight.weight.StatusResistanceBase = float(self.children[0].value) + weight.weight.BreakDamageAddedRatioBase = float(self.children[1].value) + await update_embed() + await interaction.response.defer() + + await ctx.send_followup(view=MyView()) + await update_embed() + + +def setup(bot): # this is called by Pycord to setup the cog + bot.add_cog(CreateWeightCommand(bot)) # add the cog to the bot diff --git a/generate/generate.py b/generate/generate.py index 9d15b38..a506f93 100644 --- a/generate/generate.py +++ b/generate/generate.py @@ -21,7 +21,7 @@ async def generate_panel(uid="805477392", chara_id=1, template=1, is_hideUID=Fal if response.status == 200: result_json["img"] = await response.read() - print(response.headers) + #print(response.headers) result_json["header"] = {"score": response.headers.get("x-score"), "top_score": response.headers.get("x-top-score"), "before_score": response.headers.get("x-before-score"), "median": response.headers.get("x-median"), "mean": response.headers.get("x-mean"), "rank": response.headers.get("x-rank"), diff --git a/generate/utils.py b/generate/utils.py index b67c50e..d5bc16e 100644 --- a/generate/utils.py +++ b/generate/utils.py @@ -99,8 +99,9 @@ async def get_json_from_url(uid: str, lang: str): for relic in characters["relicList"]: subaffix_list = [] for subaffix in relic["subAffixList"]: - subaffix_list.append(SubAffixBasicInfo(id=str(subaffix["affixId"]), cnt=subaffix.get("cnt", 0), - step=subaffix.get("step", 0))) + subaffix_list.append( + SubAffixBasicInfo(id=str(subaffix["affixId"]), cnt=subaffix.get("cnt", 0), + step=subaffix.get("step", 0))) basic_relics.append(RelicBasicInfo( id=str(relic["tid"]), level=relic["level"], @@ -264,9 +265,14 @@ def get_mihomo_lang(discord_lang): else: return "en" + weight_dict = {} +async def clear_weight_dict(): + weight_dict.clear() + + async def get_weight(chara_id): """with open(f"{os.path.dirname(os.path.abspath(__file__))}/weight.json") as f: weight_json = json.load(f)""" @@ -278,6 +284,13 @@ async def get_weight(chara_id): return await get_weight(chara_id) +async def get_weight_list(chara_id): + """with open(f"{os.path.dirname(os.path.abspath(__file__))}/weight.json") as f: + weight_json = json.load(f)""" + + return await get_json_from_urlpath(f"/weight_list/{chara_id}") + + def get_score_rank(chara_id, uid, score): json_path = f"{os.path.dirname(os.path.abspath(__file__))}/scores/{chara_id}.json" result = {} diff --git a/i18n/message.en.yml b/i18n/message.en.yml index 9276f07..3cb316b 100644 --- a/i18n/message.en.yml +++ b/i18n/message.en.yml @@ -29,6 +29,15 @@ en: StatusProbabilityBase: "StatusProbabilityBase" StatusResistanceBase: "StatusResistanceBase" BreakDamageAddedRatioBase: "BreakDamageAddedRatioBase" + PhysicalAddedRatio: "PhysicalAddedRatio" + FireAddedRatio: "FireAddedRatio" + IceAddedRatio: "IceAddedRatio" + ThunderAddedRatio: "ThunderAddedRatio" + WindAddedRatio: "WindAddedRatio" + QuantumAddedRatio: "QuantumAddedRatio" + ImaginaryAddedRatio: "ImaginaryAddedRatio" + SPRatioBase: "SPRatioBase" + HealRatioBase: "HealRatioBase" Median: "Median" Mean: "Mean" Rank: "Rank" diff --git a/i18n/message.jp.yml b/i18n/message.jp.yml index 30e7e29..a76242b 100644 --- a/i18n/message.jp.yml +++ b/i18n/message.jp.yml @@ -29,6 +29,15 @@ jp: StatusProbabilityBase: "効果命中" StatusResistanceBase: "効果抵抗" BreakDamageAddedRatioBase: "撃破特攻" + PhysicalAddedRatio: "物理ダメージ%" + FireAddedRatio: "炎ダメージ%" + IceAddedRatio: "氷ダメージ%" + ThunderAddedRatio: "雷ダメージ%" + WindAddedRatio: "風ダメージ%" + QuantumAddedRatio: "量子ダメージ%" + ImaginaryAddedRatio: "虚数ダメージ%" + SPRatioBase: "EP回復効率" + HealRatioBase: "治療量" Median: "中央値" Mean: "平均値" Rank: "順位" diff --git a/main.py b/main.py index 08ab8a6..3066c7c 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,9 @@ +import datetime import io +import json import os +import aiohttp import asyncpg as asyncpg import discord import discord.ext.commands.cog @@ -8,6 +11,7 @@ from dotenv import load_dotenv import backend.backend +import generate.utils import i18n i18n.load_path.append(f"{os.path.dirname(os.path.abspath(__file__))}/i18n") @@ -19,17 +23,37 @@ bot = discord.AutoShardedBot() token = os.environ.get('HONKAI_TOKEN') +characters = [] +characters_name = {} async def init_bot(): await utils.DataBase.init() status_update_task.start() + regi_weight_task.start() os.chdir(f"{os.path.dirname(os.path.abspath(__file__))}/generate") os.system("git clone --filter=blob:none --no-checkout https://github.com/Mar-7th/StarRailRes.git") os.chdir('StarRailRes') os.system("git sparse-checkout set index_min") os.system("git checkout") + with open(f"{os.path.dirname(os.path.abspath(__file__))}/generate/StarRailRes/index_min/jp/characters.json", + encoding="utf-8") as f: + chara_json = json.load(f) + characters.clear() + for key, value in chara_json.items(): + name = value["name"] + if key == "8001": + name = "主人公・壊滅・物理" + elif key == "8003": + name = "主人公・存護・炎" + elif key == "8005": + name = "主人公・調和・虚数" + elif int(key) > 8000: + continue + characters.append(discord.OptionChoice(name=name, value=key)) + characters_name[key] = name + @bot.event async def on_ready(): @@ -42,7 +66,72 @@ async def on_ready(): async def status_update_task(): text = f"Servers: {str(len(bot.guilds))}" await bot.change_presence(activity=discord.CustomActivity(text)) + await generate.utils.clear_weight_dict() + + +@tasks.loop(hours=24) +async def regi_weight_task(): + channel = bot.get_channel(1242779790914752592) + async for mes in channel.history(before=(datetime.datetime.now() + datetime.timedelta(days=-3))): + if len(mes.attachments) == 0: + continue + weight_json = json.loads(await mes.attachments[0].read()) + embed = mes.embeds[0] + embed_title = embed.title + embed_desc = embed.description + reactions = mes.reactions + + if weight_json["lang"]["en"] != "": + chara_id = f"{mes.attachments[0].filename.replace('.json', '')}_{weight_json['lang']['en']}" + else: + chara_id = f"{mes.attachments[0].filename.replace('.json', '')}" + + if embed_desc == "追加申請": + if embed_title.endswith("(投票中)"): + if reactions[0].count >= reactions[1].count: + async with aiohttp.ClientSession() as session: + async with session.post(f"https://hcs.lenlino.com/weight/" + f"{chara_id}" + , json=weight_json) as response: + print(response) + pass + if chara_id.startswith("8"): + async with aiohttp.ClientSession() as session: + async with session.post(f"https://hcs.lenlino.com/weight/" + f"{chara_id.replace(mes.attachments[0].filename.replace('.json', ''), str(int(chara_id)+1))}" + , json=weight_json) as response: + print(response) + pass + embed.title = embed_title.replace("(投票中)", "(承認済)") + embed.colour = discord.Colour.brand_green() + else: + embed.title = embed_title.replace("(投票中)", "(非承認)") + embed.colour = discord.Colour.brand_red() + await mes.edit(embed=embed) + elif embed_desc == "修正申請": + if embed_title.endswith("(投票中)"): + if reactions[0].count >= reactions[1].count: + async with aiohttp.ClientSession() as session: + async with session.put(f"https://hcs.lenlino.com/weight/{chara_id}" + , json=weight_json) as response: + print(await response.text()) + pass + if chara_id.startswith("8"): + async with aiohttp.ClientSession() as session: + async with session.put(f"https://hcs.lenlino.com/weight/" + f"{chara_id.replace(mes.attachments[0].filename.replace('.json', ''), str(int(chara_id)+1))}" + , json=weight_json) as response: + print(await response.text()) + pass + embed.title = embed_title.replace("(投票中)", "(承認済)") + embed.colour = discord.Colour.brand_green() + else: + embed.title = embed_title.replace("(投票中)", "(非承認)") + embed.colour = discord.Colour.brand_red() + await mes.edit(embed=embed) bot.load_extension('commands.CardCommand') +bot.load_extension('commands.CreateWeightCommand') +bot.load_extension('commands.ChangeWeightCommand') bot.run(token) diff --git a/utils/Weight.py b/utils/Weight.py new file mode 100644 index 0000000..034be6f --- /dev/null +++ b/utils/Weight.py @@ -0,0 +1,83 @@ +from pydantic import BaseModel + + +class Weight1(BaseModel): + HPDelta: float = 0.0 + + +class Weight2(BaseModel): + AttackDelta: float = 0.0 + + +class Weight3(BaseModel): + HPAddedRatio: float = 0.0 + AttackAddedRatio: float = 0.0 + DefenceAddedRatio: float = 0.0 + CriticalChanceBase: float = 0.0 + CriticalDamageBase: float = 0.0 + HealRatioBase: float = 0.0 + StatusProbabilityBase: float = 0.0 + + +class Weight4(BaseModel): + HPAddedRatio: float = 0.0 + AttackAddedRatio: float = 0.0 + DefenceAddedRatio: float = 0.0 + SpeedDelta: float = 0.0 + + +class Weight5(BaseModel): + HPAddedRatio: float = 0.0 + AttackAddedRatio: float = 0.0 + DefenceAddedRatio: float = 0.0 + PhysicalAddedRatio: float = 0.0 + FireAddedRatio: float = 0.0 + IceAddedRatio: float = 0.0 + ThunderAddedRatio: float = 0.0 + WindAddedRatio: float = 0.0 + QuantumAddedRatio: float = 0.0 + ImaginaryAddedRatio: float = 0.0 + + +class Weight6(BaseModel): + BreakDamageAddedRatioBase: float = 0.0 + SPRatioBase: float = 0.0 + HPAddedRatio: float = 0.0 + AttackAddedRatio: float = 0.0 + DefenceAddedRatio: float = 0.0 + + +class WeightSub(BaseModel): + HPDelta: float = 0.0 + AttackDelta: float = 0.0 + DefenceDelta: float = 0.0 + HPAddedRatio: float = 0.0 + AttackAddedRatio: float = 0.0 + DefenceAddedRatio: float = 0.0 + SpeedDelta: float = 0.0 + CriticalChanceBase: float = 0.0 + CriticalDamageBase: float = 0.0 + StatusProbabilityBase: float = 0.0 + StatusResistanceBase: float = 0.0 + BreakDamageAddedRatioBase: float = 0.0 + + +class WeightMain(BaseModel): + w1: Weight1 = Weight1() + w2: Weight2 = Weight2() + w3: Weight3 = Weight3() + w4: Weight4 = Weight4() + w5: Weight5 = Weight5() + w6: Weight6 = Weight6() + + +class Lang(BaseModel): + jp: str = "" + en: str = "" + + +class Weight(BaseModel): + main: WeightMain = WeightMain() + weight: WeightSub = WeightSub() + max: float = 0.0 + lang: Lang = Lang()