feat: draw vertical or, fix horizontal or for more than 2
release-tag / release-image (push) Successful in 15s

This commit is contained in:
2024-08-05 15:50:57 +02:00
parent 2d03a3b36a
commit b7abbb646d
+34 -10
View File
@@ -213,17 +213,17 @@ resourceIcons = {
# 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")
@@ -250,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")
@@ -346,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",
@@ -358,10 +385,7 @@ def create_effect_row(effects: list[Effect], type: str, height: int, width: int)
},
)
)
is_mutex = False
if 'mutex' in effects[0]:
print("mutex exists for a card")
is_mutex = True
icon_radius = min(height / 3, stats_radius)
@@ -387,8 +411,8 @@ def create_effect_row(effects: list[Effect], type: str, height: int, width: int)
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 * icon_radius * 3),
# 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",