Author SHA1 Message Date
Erzangel 2e9b8a0e1e feat(wip): draw flavor text in a placeholder spot
release-tag / release-image (push) Successful in 11s
2024-08-03 12:23:06 +02:00
31 changed files with 84 additions and 329 deletions
-1
View File
@@ -1,4 +1,3 @@
*.png filter=lfs diff=lfs merge=lfs -text
*.jpg filter=lfs diff=lfs merge=lfs -text
*.jpeg filter=lfs diff=lfs merge=lfs -text
*.psd filter=lfs diff=lfs merge=lfs -text
-1
View File
@@ -8,5 +8,4 @@ RUN pip install -r requirements.txt
# étape de production
COPY src ./src
COPY img ./img
CMD ["python3", "-u", "./src/generate_cards_mvp.py"]
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 963 KiB

BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+3 -41
View File
@@ -19,6 +19,7 @@
"4": {
"title": "Saki, Pégase de Guerre",
"flavor_text_type": "Cowboy",
"flavor_text_bottom": "Howdy!",
"image_path": "../../img/skins/heron/004.png"
},
"5": {
@@ -94,7 +95,7 @@
"19": {
"title": "Niko Incendiaire",
"flavor_text_type": "gfhd;spfgljh.-",
"image_path": "../../img/skins/heron/019.gif"
"image_path": "../../img/skins/heron/019.png"
},
"20": {
"title": "Tit job",
@@ -204,6 +205,7 @@
"41": {
"title": "Battler, Maître du jeu",
"flavor_text_type": "Sorcier Infini",
"flavor_text_bottom": "Please excuse my dope ass swag",
"image_path": "../../img/skins/heron/041.png"
},
"42": {
@@ -296,49 +298,9 @@
"image_path": "../../img/skins/heron/059.png"
},
"61": {
"title": "Forethought",
"image_path": "../../img/skins/heron/061.png"
},
"62": {
"title": "Festival de Watanagashi",
"image_path": "../../img/skins/heron/062.png"
},
"65": {
"title": "Starlight Convergence",
"image_path": "../../img/skins/heron/065.png"
},
"68": {
"title": "Confisquer",
"image_path": "../../img/skins/heron/068.png"
},
"70": {
"title": "Jus de Prune",
"image_path": "../../img/skins/heron/070.png"
},
"71": {
"title": "Rosser",
"image_path": "../../img/skins/heron/071.png"
},
"72": {
"title": "Rakiie Swiftkick",
"image_path": "../../img/skins/heron/072.png"
},
"73": {
"title": "Trading Card",
"image_path": "../../img/skins/heron/073.png"
},
"74": {
"title": "Scout, Nain de DRG",
"image_path": "../../img/skins/heron/074.png"
},
"84": {
"title": "ULTRAKILL",
"image_path": "../../img/skins/heron/084.png"
},
"85": {
"title": "Ultralive",
"image_path": "../../img/skins/heron/085.png"
}
}
+11 -37
View File
@@ -1,59 +1,33 @@
{
"card_type":{
"action":"Action",
"champion":"Champion",
"item": "Objet"
},
"colors":{
"red": "rouge",
"green": "verte",
"blue": "bleu",
"yellow": "jaune"
"champion":"Champion"
},
"numbers":{
"1": "une",
"2": "deux",
"3": "trois",
"4": "quatre"
"2": "deux"
},
"effects":{
"draw":"Piochez une carte.",
"draw_amount":"Piochez %a cartes.",
"stun":"Assomez le champion ciblé.",
"stack_next_card_bought":"Mettez la prochaine carte dont\nvous faites l'acquisition ce tour-ci\nau dessus de votre pioche.",
"stack_next_action_bought": "Mettez la prochaine action dont\nvous faites l'acquisition ce tour-ci\nau dessus de votre pioche.",
"sacrifice":"Vous pouvez sacrifier une carte\nde votre main ou de votre défausse.",
"sacrifice_times":"Vous pouvez sacrifier jusqu'à %a\ncartes de votre main et/ou de votre défausse.",
"restack_discarded_card": "Vous pouvez mettre une carte de votre défausse\nau dessus de votre pioche.",
"restack_discarded_champion":"Mettez un champion de\nvotre défausse au dessus\nde votre pioche.",
"restack_discarded_action":"Mettez une action de\nvotre défausse au dessus\nde votre pioche.",
"restack_discarded_champion":"Mettez un champion de votre défausse\nau dessus de votre pioche.",
"make_discard":"L'adversaire ciblé%nse défausse d'une carte.",
"draw_and_discard":"Vous pouvez piocher une carte, puis\n vous défausser d'une carte.",
"draw_and_discard_times":"Vous pouvez piocher jusqu'à %a cartes,\ndéfaussez-vous ensuite d'autant de cartes.",
"draw_and_discard_times":"Vous pouvez piocher jusqu'à %a cartes,\ndéfaussez-vous ensuite d'autant de cartes",
"play_next_card_bought":"Mettez la prochaine carte dont\nvous faites l'acquisition ce tour-ci\n dans votre main.",
"prepare":"Mobilisez un Champion.",
"prepare_all_champions":"Mobilisez vos Champions.",
"prepare_another_champion":"Mobilisez un autre Champion.",
"cheaper_champions_passive":"Les Champions que vous achetez ce tour-ci\nvous coûtent 1 de moins.",
"cheaper_champion": "Le prochain Champion que vous achetez\nvous coûte 1 de moins.",
"control_opposing_champion_passive":"Prenez le contrôle d'un Champion\nennemi jusqu'à la fin du tour.",
"buy_for_free_amount":"Vous pouvez acquérir gratuitement\nune carte de coût %a ou moins.",
"damage_all_champions_amount":"Infligez %a dégats à tous\nles Champions adverses.",
"discard_x_and_draw_x":"Vous pouvez vous défausser de\nn'importe quel nombre de cartes\net en piocher autant."
"prepare":"Mobilisez un Champion"
},
"per":{
"champion":"pour chaque Champion\nque vous avez en jeu.",
"other_champion":"pour chaque autre\nChampion que vous avez\nen jeu.",
"other_guard":"pour chaque autre\nGarde que vous avez en jeu.",
"other_card_of_same_faction":"pour chaque autre\n carte %c que vous avez\nen jeu.",
"champion_of_same_faction":"pour chaque \nChampion %c que vous\navez en jeu.",
"other_knife_played":"pour chaque autre Couteau\nque vous avez en jeu.",
"stunned_champion": "pour chaque Champion\nassommé ce tour-ci."
},
"per_effect":{
"damage":"dégats",
"heal":"PV",
"gold":"$"
"champion":"pour chaque Champion\nque vous avez en jeu",
"other_champion":"pour chaque autre Champion\nque vous avez en jeu",
"other_guard":"pour chaque autre\nGarde que vous avez en jeu",
"other_card_of_same_faction":"pour chaque autre x\nque vous avez en jeu",
"champion_of_same_faction":"pour chaque Champion x\nque vous avez en jeu",
"other_knife_played":"pour chaque autre Couteau\nque vous avez en jeu"
}
}
+23 -146
View File
@@ -192,52 +192,18 @@ resourceIcons = {
"damage": create_damage_icon,
}
### This went unused, but I left it commented cause it might be cool as a card background? idk
# def create_background_with_text(x_length: int, height: int, color: str):
# font_size = 8
# gap = 11
# group = []
# y_offset = int((height % gap)/2)
# for i in range(int(height/gap)):
# group.append(
# dw.Text(
# f"{'choose' if i%2==0 else ''} one choose one choose one choose one{' choose' if i%2==1 else ''}",
# x=0,
# y=-18 + gap*i + y_offset,
# text_anchor="middle",
# fill=color,
# font_size=font_size,
# font_family="Helvetica",
# )
# )
# return group
def create_effect_text(
card: Card,
effects: list[Effect],
height: float,
width: int,
has_mutex: bool = False,
):
def create_effect_text(effects: list[Effect], height: float, width: int):
group = []
effect_text = ""
for [i, e] in enumerate(effects):
for e in effects:
if effect_text != "":
effect_text += " "
per = e.get("per")
if per is not None:
print(e.get("effect"))
translation = f"+ {e.get('amount', '1')} {translation_fr.get('per_effect').get(e.get('effect'))} {translation_fr.get('per').get(per)}"
translation = translation.replace(
"%c",
translation_fr.get("colors").get(
card.get("faction"), card.get("faction")
)
+ " ",
) # FIXME: card color is needed here
translation = f"+ x {translation_fr.get('per').get(per)}"
elif e.get("amount", 1) > 1:
translation = (
translation_fr.get("effects")
@@ -265,20 +231,6 @@ def create_effect_text(
effect_text += "\n"
effect_text += translation
# Handle sub_effects
if len(e.get("sub_effects", [])) > 0:
effect_text += "\nSi vous le faites, gagnez "
for se in e.get("sub_effects"):
effect_text += (
str(se.get("amount", 1))
+ " "
+ translation_fr.get("per_effect").get(se.get("effect"))
)
effect_text += "."
if has_mutex and i is not len(effects) - 1:
effect_text += "\nou"
if width < 250:
effect_text = effect_text.replace("%n", "\n")
else:
@@ -314,9 +266,7 @@ def create_effect_text(
return group
def create_effect_row(
card: Card, effects: list[Effect], type: str, height: int, width: int
):
def create_effect_row(effects: list[Effect], type: str, height: int, width: int):
group = dw.Group(**{"class": "svg_effect"})
has_icon = False
if type == "faction_combo":
@@ -326,7 +276,7 @@ def create_effect_row(
cx=30,
cy=height / 2,
r=15,
fill=f'url(#grad2-{card["id"]})',
fill="url(#grad2)",
filter="url(#drop-shadow)",
)
)
@@ -337,7 +287,7 @@ def create_effect_row(
cx=30,
cy=height / 2,
r=15,
fill="url(#gradient_suicide)",
fill="black",
filter="url(#drop-shadow)",
)
)
@@ -376,46 +326,10 @@ def create_effect_row(
text_width = width
if has_icon:
text_width = width - 70
is_mutex = False
if "mutex" in effects[0]:
print("mutex exists for a card")
is_mutex = True
if len(effect_with_text) > 0:
has_text_mutex = False
if is_mutex:
if len(effect_with_icons) > 0:
icon_y_pos = icon_y_pos - 15
group.append(
dw.Group(
[
dw.Text(
"ou",
font_size=14,
x=width / 2,
y=text_y_pos - 19,
text_anchor="middle",
fill="black",
font_family="Helvetica",
font_style="italic",
),
],
**{"v-bind:class": f"{{used:used_effects_indexes.length > 0}}"},
)
)
text_y_pos = text_y_pos + 7
elif len(effect_with_text) > 1:
has_text_mutex = True
group.append(
dw.Group(
create_effect_text(
card=card,
effects=effect_with_text,
height=text_height,
width=text_width,
has_mutex=has_text_mutex,
),
create_effect_text(effect_with_text, text_height, text_width),
transform=f"translate({width / 2},{text_y_pos})",
**{
"class": "svg_effect",
@@ -444,28 +358,6 @@ def create_effect_row(
},
)
)
if is_mutex and i != 0:
group.append(
dw.Group(
[
dw.Text(
"ou",
# x=(width/2) - ((len(effect_with_icons) - 1) * icon_radius * 1.5) + icon_radius + 10,
x=(width / 2)
- ((len(effect_with_icons) - 1) * icon_radius * 1.5)
+ icon_radius
+ 10
+ ((i - 1) * icon_radius * 3),
y=icon_y_pos + 3,
text_anchor="middle",
fill="black",
font_size=12,
font_family="Helvetica",
),
],
**{"v-bind:class": f"{{used:used_effects_indexes.length > 0}}"},
)
)
return group
@@ -493,7 +385,7 @@ def generate_subeffect_index(effect: Effect):
generate_subeffect_index(e)
def create_effects(card: Card, effects: list[Effect], height: int, width: int):
def create_effects(effects: list[Effect], height: int, width: int):
for [i, e] in enumerate(effects):
e["index"] = str(i)
generate_subeffect_index(e)
@@ -511,11 +403,7 @@ def create_effects(card: Card, effects: list[Effect], height: int, width: int):
if len(grouped_effects) == 1:
group.append(
create_effect_row(
card=card,
effects=grouped_effects[effect_types[0]],
type=effect_types[0],
height=height,
width=width,
grouped_effects[effect_types[0]], effect_types[0], height, width
),
)
if len(grouped_effects) == 2:
@@ -524,11 +412,7 @@ def create_effects(card: Card, effects: list[Effect], height: int, width: int):
)
group.append(
create_effect_row(
card=card,
effects=grouped_effects[effect_types[0]],
type=effect_types[0],
height=80,
width=width,
grouped_effects[effect_types[0]], effect_types[0], 80, width
),
)
@@ -536,11 +420,10 @@ def create_effects(card: Card, effects: list[Effect], height: int, width: int):
dw.Group(
[
create_effect_row(
card=card,
effects=grouped_effects[effect_types[1]],
type=effect_types[1],
height=height - 80,
width=width,
grouped_effects[effect_types[1]],
effect_types[1],
height - 80,
width,
)
],
transform=f"translate({0},{80})",
@@ -556,11 +439,7 @@ def create_effects(card: Card, effects: list[Effect], height: int, width: int):
)
group.append(
create_effect_row(
card=card,
effects=grouped_effects[effect_types[0]],
type=effect_types[0],
height=45,
width=width,
grouped_effects[effect_types[0]], effect_types[0], 45, width
)
)
@@ -568,11 +447,10 @@ def create_effects(card: Card, effects: list[Effect], height: int, width: int):
dw.Group(
[
create_effect_row(
card=card,
effects=grouped_effects[effect_types[1]],
type=effect_types[1],
height=45,
width=width,
grouped_effects[effect_types[1]],
effect_types[1],
45,
width,
)
],
transform=f"translate({0},{45})",
@@ -583,11 +461,10 @@ def create_effects(card: Card, effects: list[Effect], height: int, width: int):
dw.Group(
[
create_effect_row(
card=card,
effects=grouped_effects[effect_types[2]],
type=effect_types[2],
height=45,
width=width,
grouped_effects[effect_types[2]],
effect_types[2],
45,
width,
)
],
transform=f"translate({0},{90})",
+39 -47
View File
@@ -41,7 +41,7 @@ cost_right_offset = 38
background_colors = {
"blue": "lightblue",
"red": "lightcoral",
"yellow": "rgb(247, 227, 175)",
"yellow": "rgb(206, 182, 167)",
"green": "lightgreen",
"base": "lightgrey",
}
@@ -56,19 +56,26 @@ gradient_colors = {
icon_colors = {
"yellow": ["#ff9935", "#ffe744"],
"blue": ["#3399ff", "#aa44ff"],
"red": ["#ff99ff", "#ffe744"],
"green": ["#009935", "#35dd35"],
"base": ["#8899aa", "#aa9988"],
"blue": ["#ff9935", "#ffe744"],
"red": ["#ff9935", "#ffe744"],
"green": ["#ff9935", "#ffe744"],
"base": ["#ff9935", "#ffe744"],
}
fullscreen_card_ids = [56, 57, 58, 59, 84, 85]
shadowFilter = dw.Filter(id="drop-shadow")
shadowFilter.append(dw.FilterItem("feDropShadow", dx=1, dy=1, stdDeviation=0))
# Draw faction icon
faction_icon = dw.Group(id="faction_icon")
faction_icon.append(dw.Circle(cx=1, cy=1, r=20, fill="black", filter=shadowFilter))
faction_icon.append(
dw.Circle(
cx=0,
cy=0,
r=20,
fill="url(#grad2)",
)
)
for card_data in cards:
# Get card skin data
@@ -103,17 +110,6 @@ for card_data in cards:
)
d.append(shadowFilter)
faction_icon = dw.Group(id="faction_icon")
faction_icon.append(dw.Circle(cx=1, cy=1, r=20, fill="black", filter=shadowFilter))
faction_icon.append(
dw.Circle(
cx=0,
cy=0,
r=20,
fill=f'url(#grad2-{card_data["id"]})',
)
)
# Define linear colored gradient
gradient = dw.LinearGradient(
0, 0, 1, 0, gradientUnits="objectBoundingBox", id="grad1"
@@ -124,20 +120,12 @@ for card_data in cards:
# Define linear colored gradient for faction icon
gradient_faction_icon = dw.LinearGradient(
0, 1, 0, 0, gradientUnits="objectBoundingBox", id=f'grad2-{card_data["id"]}'
0, 1, 0, 0, gradientUnits="objectBoundingBox", id="grad2"
)
gradient_faction_icon.add_stop(0, icon_colors[card_data["faction"]][0], opacity=1)
gradient_faction_icon.add_stop(1, icon_colors[card_data["faction"]][1], opacity=1)
d.append_def(gradient_faction_icon)
# Define linear colored gradient for suicide icon
gradient_suicide = dw.LinearGradient(
0, 1, 0, 0, gradientUnits="objectBoundingBox", id="gradient_suicide"
)
gradient_suicide.add_stop(0, "#8a8a8a", opacity=1)
gradient_suicide.add_stop(1, "#ddeedd", opacity=1)
d.append_def(gradient_suicide)
print(card_data)
# Draw card background
background = dw.Group(id="background")
background.append(
@@ -207,14 +195,13 @@ for card_data in cards:
)
d.append(title)
# Draw faction icon if not a base card
if card_data["faction"] != "base":
d.append(
dw.Group(
children=[faction_icon],
transform=f"translate({border_width_x + 23 + 1},{border_width_y - border_upper_offset + 20 + 4 + 1})",
)
# Draw faction icon
d.append(
dw.Group(
children=[faction_icon],
transform=f"translate({border_width_x + 23 + 1},{border_width_y - border_upper_offset + 20 + 4 + 1})",
)
)
# Draw card cost
if card_data.get("cost") is not None:
d.append(
@@ -226,19 +213,13 @@ for card_data in cards:
# Draw image
d.append(dw.Rectangle(x=1, y=65, width=x_width - 2, height=200))
image_height = (
200
if card_data["id"] not in fullscreen_card_ids
else y_height - 65 - border_width_y
)
d.append(
dw.Image(
x=border_width_x,
y=65,
width=x_width - (border_width_x * 2),
height=image_height,
height=200,
path=card_skin_data["image_path"],
preserveAspectRatio="xMidYMid slice",
)
)
d.append(dw.Rectangle(x=2, y=65 - 1, width=border_width_x - 2, height=200 + 2))
@@ -255,14 +236,25 @@ for card_data in cards:
# Draw effects
effects = card_data.get("effects")
if effects is not None:
effects_height = 265 if card_data["id"] not in fullscreen_card_ids else 220
effects = create_effects(
card=card_data, effects=effects, height=135, width=x_internal_width
)
effects = create_effects(effects=effects, height=135, width=x_internal_width)
d.append(
dw.Group(
effects,
transform=f"translate({border_width_x},{effects_height})",
transform=f"translate({border_width_x},{265})",
)
)
# If it has a flavor text, draw flavor text
if "flavor_text_bottom" in card_skin_data:
d.append(
dw.Text(
text='"' + card_skin_data["flavor_text_bottom"] + '"',
font_size=8,
x=x_width/2,
y=y_height-20,
text_anchor="middle",
fill="black",
font_family="Helvetica",
)
)