Nice cards templates
CI / quality (3.11) (push) Has been cancelled
CI / quality (3.12) (push) Has been cancelled

This commit is contained in:
2026-10-16 02:37:28 +02:00
parent 3b886acaba
commit 89855f78f3
11 changed files with 564 additions and 304 deletions
+77 -2
View File
@@ -5,6 +5,7 @@ from __future__ import annotations
from pathlib import Path
from genshin_tcg.data.catalog import Catalog
from genshin_tcg.models import parse_catalog
from genshin_tcg.rendering.context import (
ActionView,
CharacterView,
@@ -62,6 +63,80 @@ def test_character_tags_include_element_and_weapon(sample_catalog: Catalog) -> N
assert view.tags[1].label == "Épée à deux mains"
def test_character_tag_order_matches_the_official_print(
tmp_path: Path, sample_catalog: Catalog
) -> None:
"""The official layout stacks element, nation/faction, then weapon."""
view = build_view(
sample_catalog.get("test_pyro"),
assets_dir=tmp_path / "assets",
html_dir=tmp_path / "build" / "html",
factions={"test_pyro": "liyue"},
width_px=744,
height_px=1039,
)
assert isinstance(view, CharacterView)
assert [tag.kind for tag in view.tags] == ["element", "faction", "weapon"]
def test_none_token_labels_do_not_collide(tmp_path: Path) -> None:
"""``WeaponType.NONE`` ("other weapon") and ``CardType.NONE`` ("event card")
share the ``"none"`` token but must not share a label."""
catalog = Catalog(
cards=tuple(
parse_catalog(
[
{
"_id": 1,
"id": "monster",
"type": "character",
"name": "Monstre",
"hp": 8,
"energy": 0,
"element": "hydro",
"weapon": "none",
"skills": [
{
"_id": 11,
"type": "Attaque normale",
"name": "Charge",
"desc": "Inflige 2 pts de DGT physiques.",
"cost": [{"type": "hydro", "count": 1}],
}
],
},
{
"_id": 2,
"id": "event",
"type": "none",
"name": "Événement",
"skills": {"cost": [], "desc": "Rien."},
},
]
)
)
)
monster = build_view(
catalog.get("monster"),
assets_dir=tmp_path / "assets",
html_dir=tmp_path / "build" / "html",
width_px=744,
height_px=1039,
)
event = build_view(
catalog.get("event"),
assets_dir=tmp_path / "assets",
html_dir=tmp_path / "build" / "html",
width_px=744,
height_px=1039,
)
assert isinstance(monster, CharacterView)
assert isinstance(event, ActionView)
assert monster.weapon_label == "Autre arme"
assert [tag.label for tag in monster.tags if tag.kind == "weapon"] == ["Autre arme"]
assert event.type_label == "Événement"
def test_character_skills_and_costs(sample_catalog: Catalog) -> None:
view = _character(sample_catalog)
assert len(view.skills) == 3
@@ -76,7 +151,7 @@ def test_character_skills_and_costs(sample_catalog: Catalog) -> None:
def test_character_description_is_cleaned_and_highlighted(sample_catalog: Catalog) -> None:
view = _character(sample_catalog)
assert "<br/>" in view.skills[0].description_html
assert '<span style="color: #FFFFFFFF">DGT ' in view.skills[1].description_html
assert '<span style="color: #3a332a">DGT ' in view.skills[1].description_html
assert "inline-die" in view.skills[1].description_html
assert view.skills[1].sub_name == "Flamme éternelle"
assert view.skills[1].sub_description_html is not None
@@ -107,7 +182,7 @@ def test_action_view_fields(sample_catalog: Catalog) -> None:
assert view.requirement == "test_pyro"
assert [die.count for die in view.cost] == [4]
assert "<br/>" in view.description_html
assert '<span style="color: #FFD700">Action de combat</span>' in view.description_html
assert '<span style="color: #988316">Action de combat</span>' in view.description_html
def test_action_without_cost_gets_placeholder_die(sample_catalog: Catalog) -> None: