This commit is contained in:
+50
-27
@@ -213,7 +213,13 @@ resourceIcons = {
|
||||
# return group
|
||||
|
||||
|
||||
def create_effect_text(card: Card, effects: list[Effect], height: float, width: int, has_mutex: bool = False):
|
||||
def create_effect_text(
|
||||
card: Card,
|
||||
effects: list[Effect],
|
||||
height: float,
|
||||
width: int,
|
||||
has_mutex: bool = False,
|
||||
):
|
||||
group = []
|
||||
|
||||
effect_text = ""
|
||||
@@ -223,9 +229,15 @@ def create_effect_text(card: Card, effects: list[Effect], height: float, width:
|
||||
effect_text += " "
|
||||
per = e.get("per")
|
||||
if per is not None:
|
||||
print(e.get('effect'))
|
||||
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 = translation.replace(
|
||||
"%c",
|
||||
translation_fr.get("colors").get(
|
||||
card.get("faction"), card.get("faction")
|
||||
)
|
||||
+ " ",
|
||||
) # FIXME: card color is needed here
|
||||
elif e.get("amount", 1) > 1:
|
||||
translation = (
|
||||
translation_fr.get("effects")
|
||||
@@ -254,11 +266,15 @@ def create_effect_text(card: Card, effects: list[Effect], height: float, width:
|
||||
effect_text += translation
|
||||
|
||||
# Handle sub_effects
|
||||
if (len(e.get('sub_effects', [])) > 0):
|
||||
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 += '.'
|
||||
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"
|
||||
@@ -298,7 +314,9 @@ def create_effect_text(card: Card, effects: list[Effect], height: float, width:
|
||||
return group
|
||||
|
||||
|
||||
def create_effect_row(card: Card, effects: list[Effect], type: str, height: int, width: int):
|
||||
def create_effect_row(
|
||||
card: Card, effects: list[Effect], type: str, height: int, width: int
|
||||
):
|
||||
group = dw.Group(**{"class": "svg_effect"})
|
||||
has_icon = False
|
||||
if type == "faction_combo":
|
||||
@@ -308,7 +326,7 @@ def create_effect_row(card: Card, effects: list[Effect], type: str, height: int,
|
||||
cx=30,
|
||||
cy=height / 2,
|
||||
r=15,
|
||||
fill="url(#grad2)",
|
||||
fill=f'url(#grad2-{card["id"]})',
|
||||
filter="url(#drop-shadow)",
|
||||
)
|
||||
)
|
||||
@@ -360,7 +378,7 @@ def create_effect_row(card: Card, effects: list[Effect], type: str, height: int,
|
||||
text_width = width - 70
|
||||
|
||||
is_mutex = False
|
||||
if 'mutex' in effects[0]:
|
||||
if "mutex" in effects[0]:
|
||||
print("mutex exists for a card")
|
||||
is_mutex = True
|
||||
|
||||
@@ -376,21 +394,18 @@ def create_effect_row(card: Card, effects: list[Effect], type: str, height: int,
|
||||
"ou",
|
||||
font_size=14,
|
||||
x=width / 2,
|
||||
y=text_y_pos-19,
|
||||
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}}"
|
||||
}
|
||||
**{"v-bind:class": f"{{used:used_effects_indexes.length > 0}}"},
|
||||
)
|
||||
|
||||
)
|
||||
text_y_pos = text_y_pos + 7
|
||||
elif len (effect_with_text) > 1:
|
||||
elif len(effect_with_text) > 1:
|
||||
has_text_mutex = True
|
||||
group.append(
|
||||
dw.Group(
|
||||
@@ -399,7 +414,7 @@ def create_effect_row(card: Card, effects: list[Effect], type: str, height: int,
|
||||
effects=effect_with_text,
|
||||
height=text_height,
|
||||
width=text_width,
|
||||
has_mutex=has_text_mutex
|
||||
has_mutex=has_text_mutex,
|
||||
),
|
||||
transform=f"translate({width / 2},{text_y_pos})",
|
||||
**{
|
||||
@@ -409,8 +424,6 @@ def create_effect_row(card: Card, effects: list[Effect], type: str, height: int,
|
||||
},
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
icon_radius = min(height / 3, stats_radius)
|
||||
for [i, e] in enumerate(effect_with_icons):
|
||||
@@ -431,14 +444,18 @@ def create_effect_row(card: Card, effects: list[Effect], type: str, height: int,
|
||||
},
|
||||
)
|
||||
)
|
||||
if is_mutex and i!=0:
|
||||
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),
|
||||
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",
|
||||
@@ -446,9 +463,7 @@ def create_effect_row(card: Card, effects: list[Effect], type: str, height: int,
|
||||
font_family="Helvetica",
|
||||
),
|
||||
],
|
||||
**{
|
||||
"v-bind:class": f"{{used:used_effects_indexes.length > 0}}"
|
||||
}
|
||||
**{"v-bind:class": f"{{used:used_effects_indexes.length > 0}}"},
|
||||
)
|
||||
)
|
||||
|
||||
@@ -500,7 +515,7 @@ def create_effects(card: Card, effects: list[Effect], height: int, width: int):
|
||||
effects=grouped_effects[effect_types[0]],
|
||||
type=effect_types[0],
|
||||
height=height,
|
||||
width=width
|
||||
width=width,
|
||||
),
|
||||
)
|
||||
if len(grouped_effects) == 2:
|
||||
@@ -509,7 +524,11 @@ 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
|
||||
card=card,
|
||||
effects=grouped_effects[effect_types[0]],
|
||||
type=effect_types[0],
|
||||
height=80,
|
||||
width=width,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -537,7 +556,11 @@ 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
|
||||
card=card,
|
||||
effects=grouped_effects[effect_types[0]],
|
||||
type=effect_types[0],
|
||||
height=45,
|
||||
width=width,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
+24
-18
@@ -62,24 +62,13 @@ icon_colors = {
|
||||
"base": ["#8899aa", "#aa9988"],
|
||||
}
|
||||
|
||||
fullscreen_card_ids = [
|
||||
56, 57, 58, 59, 84, 85
|
||||
]
|
||||
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
|
||||
@@ -114,6 +103,17 @@ 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,7 +124,7 @@ for card_data in cards:
|
||||
|
||||
# Define linear colored gradient for faction icon
|
||||
gradient_faction_icon = dw.LinearGradient(
|
||||
0, 1, 0, 0, gradientUnits="objectBoundingBox", id="grad2"
|
||||
0, 1, 0, 0, gradientUnits="objectBoundingBox", id=f'grad2-{card_data["id"]}'
|
||||
)
|
||||
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)
|
||||
@@ -208,7 +208,7 @@ for card_data in cards:
|
||||
d.append(title)
|
||||
|
||||
# Draw faction icon if not a base card
|
||||
if card_data['faction'] != 'base':
|
||||
if card_data["faction"] != "base":
|
||||
d.append(
|
||||
dw.Group(
|
||||
children=[faction_icon],
|
||||
@@ -226,7 +226,11 @@ 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
|
||||
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,
|
||||
@@ -251,8 +255,10 @@ 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_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
|
||||
)
|
||||
d.append(
|
||||
dw.Group(
|
||||
effects,
|
||||
|
||||
Reference in New Issue
Block a user