Author SHA1 Message Date
Erzangel 0fb1c77907 feat: llm crimes
release-tag / release-image (push) Successful in 18s
2024-08-05 18:23:36 +02:00
Erzangel b7abbb646d feat: draw vertical or, fix horizontal or for more than 2
release-tag / release-image (push) Successful in 15s
2024-08-05 15:50:57 +02:00
Erzangel 2d03a3b36a Merge branch 'main' of git.legonzaur.fr:heronfief/cards-gen
release-tag / release-image (push) Successful in 13s
2024-08-04 17:33:56 +02:00
Erzangel 5b72b60aa2 fix: or condition, effects translation for upcoming cards 2024-08-04 17:33:34 +02:00
legonzaur f766c559d6 ci : Include images in image
release-tag / release-image (push) Successful in 14s
2024-08-03 16:47:00 +02:00
Erzangel 1a3219e6e6 feat(img): provide imgs for all of base game
release-tag / release-image (push) Successful in 12s
2024-08-03 12:56:08 +02:00
15 changed files with 144 additions and 17 deletions
+1
View File
@@ -8,4 +8,5 @@ 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.

After

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.
Binary file not shown.
BIN
View File
Binary file not shown.
+2
View File
@@ -1 +1,3 @@
drawsvg==2.4.0
pillow==10.4.0
--extra-index-url=https://packagecloud.io/github/git-lfs/pypi/simple
+5 -1
View File
@@ -94,7 +94,7 @@
"19": {
"title": "Niko Incendiaire",
"flavor_text_type": "gfhd;spfgljh.-",
"image_path": "../../img/skins/heron/019.png"
"image_path": "../../img/skins/heron/019.gif"
},
"20": {
"title": "Tit job",
@@ -296,6 +296,10 @@
"image_path": "../../img/skins/heron/059.png"
},
"68": {
"title": "Confisquer",
"image_path": "../../img/skins/heron/068.png"
},
"71": {
"title": "Rosser",
"image_path": "../../img/skins/heron/071.png"
+9 -2
View File
@@ -12,14 +12,21 @@
"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_champion":"Mettez un champion de votre défausse\nau dessus de votre pioche.",
"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.",
"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",
"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":"Mobilisez un Champion",
"prepare_all_champions":"Mobilisez vos Champions.",
"prepare_another_champion":"Mobilisez un autre Champion.",
"cheaper_champions_passive":"Le prochain Champion que vous achetez\nvous coûte 1 de moins ce tour-ci.",
"control_opposing_champion_passive":"Prenez le contrôle d'un Champion\nennemi jusqu'à la fin du tour."
},
"per":{
"champion":"pour chaque Champion\nque vous avez en jeu",
+66 -4
View File
@@ -192,18 +192,38 @@ 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(effects: list[Effect], height: float, width: int):
def create_effect_text(effects: list[Effect], height: float, width: int, has_mutex: bool = False):
group = []
effect_text = ""
for e in effects:
for [i, e] in enumerate(effects):
if effect_text != "":
effect_text += " "
per = e.get("per")
if per is not None:
translation = f"+ x {translation_fr.get('per').get(per)}"
translation = f"+ {e.get('amount', '1')} {translation_fr.get('per').get(per)}"
elif e.get("amount", 1) > 1:
translation = (
translation_fr.get("effects")
@@ -230,6 +250,8 @@ def create_effect_text(effects: list[Effect], height: float, width: int):
if len(effect_text) > 20:
effect_text += "\n"
effect_text += translation
if has_mutex and i is not len(effects) - 1:
effect_text += "\nou"
if width < 250:
effect_text = effect_text.replace("%n", "\n")
@@ -326,10 +348,35 @@ def create_effect_row(effects: list[Effect], type: str, height: int, width: int)
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.Text(
"ou",
font_size=14,
x=width / 2,
y=text_y_pos-19,
text_anchor="middle",
fill="black",
font_family="Helvetica",
font_style="italic",
)
)
text_y_pos = text_y_pos + 7
elif len (effect_with_text) > 1:
has_text_mutex = True
group.append(
dw.Group(
create_effect_text(effect_with_text, text_height, text_width),
create_effect_text(effect_with_text, text_height, text_width, has_mutex=has_text_mutex),
transform=f"translate({width / 2},{text_y_pos})",
**{
"class": "svg_effect",
@@ -339,6 +386,8 @@ def create_effect_row(effects: list[Effect], type: str, height: int, width: int)
)
)
icon_radius = min(height / 3, stats_radius)
for [i, e] in enumerate(effect_with_icons):
f = resourceIcons.get(e.get("effect"))
@@ -358,6 +407,19 @@ def create_effect_row(effects: list[Effect], type: str, height: int, width: int)
},
)
)
if is_mutex and i!=0:
group.append(
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",
),
)
return group
+39 -9
View File
@@ -8,6 +8,7 @@ from draw_functions import create_gold_icon, create_effects, draw_champion_shiel
from card_types import Card, SkinData, SkinFile, Translation
from drawsvg.drawing import Drawing
from PIL import Image
from edit_card import finish_card
@@ -212,16 +213,45 @@ for card_data in cards:
)
# Draw image
d.append(dw.Rectangle(x=1, y=65, width=x_width - 2, height=200))
d.append(
dw.Image(
x=border_width_x,
y=65,
width=x_width - (border_width_x * 2),
height=200,
path=card_skin_data["image_path"],
)
image_area_width = x_width - (2 * border_width_x)
image_area_height = 200
d.append(dw.Rectangle(x=1, y=65, width=x_width - 2, height=image_area_height))
image = Image.open(card_skin_data['image_path'].replace('../../', ''))
image_natural_width, image_natural_height = image.size
image_ratio = image_natural_width / image_natural_height
area_ratio = image_area_width / image_area_height
print(image_natural_width)
print(image_area_width)
print(image_ratio)
print(area_ratio)
if image_ratio > area_ratio:
# Wider image
scale = image_area_height / image_natural_height
new_width = image_natural_width * scale
translate_x = (image_area_width - new_width) / 2
transform = f"translate({translate_x}, 0) scale ({scale})"
print(transform)
else:
# Taller image
scale = image_area_width / image_natural_width
new_height = image_natural_height * scale
translate_y = (image_area_height - new_height) / 2
transform = f"translate(0, {translate_y}) scale({scale})"
card_image = dw.Image(
x=border_width_x,
y=65,
width=x_width - (border_width_x * 2),
height=200,
path=card_skin_data["image_path"],
**{
"object-fit": "cover",
}
)
card_image.args['transform'] = transform
d.append(card_image)
d.append(dw.Rectangle(x=2, y=65 - 1, width=border_width_x - 2, height=200 + 2))
# d.append(dw.Rectangle(x=0, y=65+1, width=1, height=200+2, fill='white'))
d.append(