Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2e9b8a0e1e |
@@ -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
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 963 KiB |
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
+1
-3
@@ -1,3 +1 @@
|
||||
drawsvg==2.4.0
|
||||
pillow==10.4.0
|
||||
--extra-index-url=https://packagecloud.io/github/git-lfs/pypi/simple
|
||||
drawsvg==2.4.0
|
||||
@@ -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,10 +298,6 @@
|
||||
|
||||
"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"
|
||||
|
||||
@@ -12,21 +12,14 @@
|
||||
"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",
|
||||
"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":"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."
|
||||
"prepare":"Mobilisez un Champion"
|
||||
},
|
||||
"per":{
|
||||
"champion":"pour chaque Champion\nque vous avez en jeu",
|
||||
|
||||
+4
-66
@@ -192,38 +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(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:
|
||||
translation = f"+ {e.get('amount', '1')} {translation_fr.get('per').get(per)}"
|
||||
translation = f"+ x {translation_fr.get('per').get(per)}"
|
||||
elif e.get("amount", 1) > 1:
|
||||
translation = (
|
||||
translation_fr.get("effects")
|
||||
@@ -250,8 +230,6 @@ def create_effect_text(effects: list[Effect], height: float, width: int, has_mut
|
||||
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")
|
||||
@@ -348,35 +326,10 @@ 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, 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",
|
||||
@@ -385,8 +338,6 @@ 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):
|
||||
@@ -407,19 +358,6 @@ 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
|
||||
|
||||
|
||||
+23
-39
@@ -8,7 +8,6 @@ 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
|
||||
|
||||
@@ -213,45 +212,16 @@ for card_data in cards:
|
||||
)
|
||||
|
||||
# Draw image
|
||||
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",
|
||||
}
|
||||
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"],
|
||||
)
|
||||
)
|
||||
|
||||
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(
|
||||
@@ -274,6 +244,20 @@ for card_data in cards:
|
||||
)
|
||||
)
|
||||
|
||||
# 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",
|
||||
)
|
||||
)
|
||||
|
||||
# If champion, draw champion shield with defense
|
||||
if card_data["card_type"] == "champion":
|
||||
shield = draw_champion_shield(card_data, border_width_x)
|
||||
|
||||
Reference in New Issue
Block a user