This commit is contained in:
+47
-24
@@ -213,7 +213,13 @@ resourceIcons = {
|
|||||||
# return group
|
# 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 = []
|
group = []
|
||||||
|
|
||||||
effect_text = ""
|
effect_text = ""
|
||||||
@@ -223,9 +229,15 @@ def create_effect_text(card: Card, effects: list[Effect], height: float, width:
|
|||||||
effect_text += " "
|
effect_text += " "
|
||||||
per = e.get("per")
|
per = e.get("per")
|
||||||
if per is not None:
|
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 = 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:
|
elif e.get("amount", 1) > 1:
|
||||||
translation = (
|
translation = (
|
||||||
translation_fr.get("effects")
|
translation_fr.get("effects")
|
||||||
@@ -254,11 +266,15 @@ def create_effect_text(card: Card, effects: list[Effect], height: float, width:
|
|||||||
effect_text += translation
|
effect_text += translation
|
||||||
|
|
||||||
# Handle sub_effects
|
# Handle sub_effects
|
||||||
if (len(e.get('sub_effects', [])) > 0):
|
if len(e.get("sub_effects", [])) > 0:
|
||||||
effect_text += "\nSi vous le faites, gagnez "
|
effect_text += "\nSi vous le faites, gagnez "
|
||||||
for se in e.get('sub_effects'):
|
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 += (
|
||||||
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:
|
if has_mutex and i is not len(effects) - 1:
|
||||||
effect_text += "\nou"
|
effect_text += "\nou"
|
||||||
@@ -298,7 +314,9 @@ def create_effect_text(card: Card, effects: list[Effect], height: float, width:
|
|||||||
return group
|
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"})
|
group = dw.Group(**{"class": "svg_effect"})
|
||||||
has_icon = False
|
has_icon = False
|
||||||
if type == "faction_combo":
|
if type == "faction_combo":
|
||||||
@@ -308,7 +326,7 @@ def create_effect_row(card: Card, effects: list[Effect], type: str, height: int,
|
|||||||
cx=30,
|
cx=30,
|
||||||
cy=height / 2,
|
cy=height / 2,
|
||||||
r=15,
|
r=15,
|
||||||
fill="url(#grad2)",
|
fill=f'url(#grad2-{card["id"]})',
|
||||||
filter="url(#drop-shadow)",
|
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
|
text_width = width - 70
|
||||||
|
|
||||||
is_mutex = False
|
is_mutex = False
|
||||||
if 'mutex' in effects[0]:
|
if "mutex" in effects[0]:
|
||||||
print("mutex exists for a card")
|
print("mutex exists for a card")
|
||||||
is_mutex = True
|
is_mutex = True
|
||||||
|
|
||||||
@@ -383,11 +401,8 @@ def create_effect_row(card: Card, effects: list[Effect], type: str, height: int,
|
|||||||
font_style="italic",
|
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
|
text_y_pos = text_y_pos + 7
|
||||||
elif len(effect_with_text) > 1:
|
elif len(effect_with_text) > 1:
|
||||||
@@ -399,7 +414,7 @@ def create_effect_row(card: Card, effects: list[Effect], type: str, height: int,
|
|||||||
effects=effect_with_text,
|
effects=effect_with_text,
|
||||||
height=text_height,
|
height=text_height,
|
||||||
width=text_width,
|
width=text_width,
|
||||||
has_mutex=has_text_mutex
|
has_mutex=has_text_mutex,
|
||||||
),
|
),
|
||||||
transform=f"translate({width / 2},{text_y_pos})",
|
transform=f"translate({width / 2},{text_y_pos})",
|
||||||
**{
|
**{
|
||||||
@@ -410,8 +425,6 @@ def create_effect_row(card: Card, effects: list[Effect], type: str, height: int,
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
icon_radius = min(height / 3, stats_radius)
|
icon_radius = min(height / 3, stats_radius)
|
||||||
for [i, e] in enumerate(effect_with_icons):
|
for [i, e] in enumerate(effect_with_icons):
|
||||||
f = resourceIcons.get(e.get("effect"))
|
f = resourceIcons.get(e.get("effect"))
|
||||||
@@ -438,7 +451,11 @@ def create_effect_row(card: Card, effects: list[Effect], type: str, height: int,
|
|||||||
dw.Text(
|
dw.Text(
|
||||||
"ou",
|
"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,
|
||||||
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,
|
y=icon_y_pos + 3,
|
||||||
text_anchor="middle",
|
text_anchor="middle",
|
||||||
fill="black",
|
fill="black",
|
||||||
@@ -446,9 +463,7 @@ def create_effect_row(card: Card, effects: list[Effect], type: str, height: int,
|
|||||||
font_family="Helvetica",
|
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]],
|
effects=grouped_effects[effect_types[0]],
|
||||||
type=effect_types[0],
|
type=effect_types[0],
|
||||||
height=height,
|
height=height,
|
||||||
width=width
|
width=width,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
if len(grouped_effects) == 2:
|
if len(grouped_effects) == 2:
|
||||||
@@ -509,7 +524,11 @@ def create_effects(card: Card, effects: list[Effect], height: int, width: int):
|
|||||||
)
|
)
|
||||||
group.append(
|
group.append(
|
||||||
create_effect_row(
|
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(
|
group.append(
|
||||||
create_effect_row(
|
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"],
|
"base": ["#8899aa", "#aa9988"],
|
||||||
}
|
}
|
||||||
|
|
||||||
fullscreen_card_ids = [
|
fullscreen_card_ids = [56, 57, 58, 59, 84, 85]
|
||||||
56, 57, 58, 59, 84, 85
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
shadowFilter = dw.Filter(id="drop-shadow")
|
shadowFilter = dw.Filter(id="drop-shadow")
|
||||||
shadowFilter.append(dw.FilterItem("feDropShadow", dx=1, dy=1, stdDeviation=0))
|
shadowFilter.append(dw.FilterItem("feDropShadow", dx=1, dy=1, stdDeviation=0))
|
||||||
# Draw faction icon
|
# 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:
|
for card_data in cards:
|
||||||
# Get card skin data
|
# Get card skin data
|
||||||
@@ -114,6 +103,17 @@ for card_data in cards:
|
|||||||
)
|
)
|
||||||
d.append(shadowFilter)
|
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
|
# Define linear colored gradient
|
||||||
gradient = dw.LinearGradient(
|
gradient = dw.LinearGradient(
|
||||||
0, 0, 1, 0, gradientUnits="objectBoundingBox", id="grad1"
|
0, 0, 1, 0, gradientUnits="objectBoundingBox", id="grad1"
|
||||||
@@ -124,7 +124,7 @@ for card_data in cards:
|
|||||||
|
|
||||||
# Define linear colored gradient for faction icon
|
# Define linear colored gradient for faction icon
|
||||||
gradient_faction_icon = dw.LinearGradient(
|
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(0, icon_colors[card_data["faction"]][0], opacity=1)
|
||||||
gradient_faction_icon.add_stop(1, icon_colors[card_data["faction"]][1], 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)
|
d.append(title)
|
||||||
|
|
||||||
# Draw faction icon if not a base card
|
# Draw faction icon if not a base card
|
||||||
if card_data['faction'] != 'base':
|
if card_data["faction"] != "base":
|
||||||
d.append(
|
d.append(
|
||||||
dw.Group(
|
dw.Group(
|
||||||
children=[faction_icon],
|
children=[faction_icon],
|
||||||
@@ -226,7 +226,11 @@ for card_data in cards:
|
|||||||
|
|
||||||
# Draw image
|
# Draw image
|
||||||
d.append(dw.Rectangle(x=1, y=65, width=x_width - 2, height=200))
|
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(
|
d.append(
|
||||||
dw.Image(
|
dw.Image(
|
||||||
x=border_width_x,
|
x=border_width_x,
|
||||||
@@ -251,8 +255,10 @@ for card_data in cards:
|
|||||||
# Draw effects
|
# Draw effects
|
||||||
effects = card_data.get("effects")
|
effects = card_data.get("effects")
|
||||||
if effects is not None:
|
if effects is not None:
|
||||||
effects_height = 265 if card_data['id'] not in fullscreen_card_ids else 220
|
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(
|
||||||
|
card=card_data, effects=effects, height=135, width=x_internal_width
|
||||||
|
)
|
||||||
d.append(
|
d.append(
|
||||||
dw.Group(
|
dw.Group(
|
||||||
effects,
|
effects,
|
||||||
|
|||||||
Reference in New Issue
Block a user