Add Transformative Damage Support

This commit is contained in:
luoshuijs 2023-10-24 12:05:08 +08:00 committed by GitHub
parent 028fa3a6f6
commit 14a9b8a55c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 12 deletions

View File

@ -40,8 +40,7 @@ from utils.log import logger
from utils.uid import mask_number from utils.uid import mask_number
try: try:
from python_genshin_artifact.calculator import get_damage_analysis from python_genshin_artifact.calculator import get_damage_analysis, get_transformative_damage
from python_genshin_artifact.enka.characters import characters_map
from python_genshin_artifact.enka.enka_parser import enka_parser from python_genshin_artifact.enka.enka_parser import enka_parser
from python_genshin_artifact.models.calculator import CalculatorConfig from python_genshin_artifact.models.calculator import CalculatorConfig
from python_genshin_artifact.models.skill import SkillInfo from python_genshin_artifact.models.skill import SkillInfo
@ -49,11 +48,10 @@ try:
GENSHIN_ARTIFACT_FUNCTION_AVAILABLE = True GENSHIN_ARTIFACT_FUNCTION_AVAILABLE = True
except ImportError as exc: except ImportError as exc:
get_damage_analysis = None get_damage_analysis = None
characters_map = {} get_transformative_damage = None
enka_parser = None enka_parser = None
CalculatorConfig = None CalculatorConfig = None
SkillInfo = None SkillInfo = None
Assets = None
GENSHIN_ARTIFACT_FUNCTION_AVAILABLE = False GENSHIN_ARTIFACT_FUNCTION_AVAILABLE = False
@ -622,11 +620,17 @@ class RenderTemplate:
skill=skill_info, skill=skill_info,
artifact_config=artifact_config, artifact_config=artifact_config,
) )
damage_analysis = get_damage_analysis(calculator_config)
damage_key = skill.get("damage_key") damage_key = skill.get("damage_key")
transformative_damage_key = skill.get("transformative_damage_key")
damage_info = {"skill_info": skill, "damage": None, "transformative_damage": None}
if damage_key is not None:
damage_analysis = get_damage_analysis(calculator_config)
damage_value = getattr(damage_analysis, damage_key) damage_value = getattr(damage_analysis, damage_key)
if damage_value is not None: damage_info["damage"] = damage_value
damage_info = {"damage": damage_value, "skill_info": skill} if transformative_damage_key is not None:
transformative_damage = get_transformative_damage(calculator_config)
transformative_damage_value = getattr(transformative_damage, transformative_damage_key)
damage_info["transformative_damage"] = transformative_damage_value
damage.append(damage_info) damage.append(damage_info)
return damage return damage

View File

@ -10,8 +10,18 @@
{% for item in damage_info %} {% for item in damage_info %}
<tr class="text-center odd:bg-white odd:bg-opacity-10"> <tr class="text-center odd:bg-white odd:bg-opacity-10">
<td class="border px-4 py-2">{{ item.skill_info.name }}</td> <td class="border px-4 py-2">{{ item.skill_info.name }}</td>
{%- if item.damage != None -%}
{%- if item.damage.is_heal or item.damage.is_shield -%}
<td class="border px-4 py-2 " colspan="2">{{ item.damage.expectation|round|int }}</td>
{%- else -%}
<td class="border px-4 py-2">{{ item.damage.critical|round|int }}</td> <td class="border px-4 py-2">{{ item.damage.critical|round|int }}</td>
<td class="border px-4 py-2">{{ item.damage.expectation|round|int }}</td> <td class="border px-4 py-2">{{ item.damage.expectation|round|int }}</td>
{%- endif -%}
{%- elif item.transformative_damage != None -%}
<td class="border px-4 py-2 " colspan="2">{{ item.transformative_damage|round|int }}</td>
{%- else -%}
<td class="border px-4 py-2" colspan="2"></td>
{%- endif -%}
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>