From c065e23708495e5892bfeeadae353abcf9fe9354 Mon Sep 17 00:00:00 2001 From: legonzaur Date: Sun, 7 Jul 2024 19:50:40 +0200 Subject: [PATCH] Fix : quotes conflict on fstring --- src/generate_cards_mvp.py | 86 ++++++++++++++++++++++++++++----------- 1 file changed, 63 insertions(+), 23 deletions(-) diff --git a/src/generate_cards_mvp.py b/src/generate_cards_mvp.py index 380ed30..d66c35b 100644 --- a/src/generate_cards_mvp.py +++ b/src/generate_cards_mvp.py @@ -18,7 +18,7 @@ with open("src/data/heron_skin.json", encoding="utf-8") as f: all_skin_data: SkinFile = json.load(f) cards: list[Card] = [] -for p in Path('src/data/cards').glob('*.json'): +for p in Path("src/data/cards").glob("*.json"): with open(p, encoding="utf-8") as f: temp: list[Card] = json.load(f)["cards"] cards.extend(temp) @@ -29,7 +29,7 @@ y_height = 417 border_width_x = 12 border_width_y = 17 -x_internal_width = x_width - (border_width_x*2) +x_internal_width = x_width - (border_width_x * 2) border_upper_offset = 5 title_y_offset = 24 @@ -46,15 +46,21 @@ background_colors = { "base": "lightgrey", } -gradient_colors = {"red": "red", "blue": "blue", "yellow": "yellow", "green": "green", "base":"gray"} +gradient_colors = { + "red": "red", + "blue": "blue", + "yellow": "yellow", + "green": "green", + "base": "gray", +} icon_colors = { "yellow": ["#ff9935", "#ffe744"], "blue": ["#ff9935", "#ffe744"], "red": ["#ff9935", "#ffe744"], "green": ["#ff9935", "#ffe744"], - "base": ["#ff9935", "#ffe744"] - } + "base": ["#ff9935", "#ffe744"], +} shadowFilter = dw.Filter(id="drop-shadow") @@ -76,7 +82,9 @@ for card_data in cards: try: card_skin_data = all_skin_data["cards"][str(card_data["id"])] except KeyError: - print("Missing skin data for card id:", card_data["id"], "using default skin data") + print( + "Missing skin data for card id:", card_data["id"], "using default skin data" + ) card_skin_data = SkinData( title=card_data["name"], image_path="../../img/missing.png", @@ -85,7 +93,17 @@ for card_data in cards: # Create a new SVG drawing output_dir = "output/" + all_skin_data["skin_name"] os.makedirs(output_dir, exist_ok=True) - d = Drawing(x_width, y_height, id="card"+str(card_data["id"]), id_prefix=str(card_data.get('id')) + "_", **{'class':'card', 'xmlns:v-bind':"https://vuejs.org/guide/essentials/class-and-style.html",'xmlns:v-on':"https://vuejs.org/guide/essentials/event-handling.html"}) + d = Drawing( + x_width, + y_height, + id="card" + str(card_data["id"]), + id_prefix=str(card_data.get("id")) + "_", + **{ + "class": "card", + "xmlns:v-bind": "https://vuejs.org/guide/essentials/class-and-style.html", + "xmlns:v-on": "https://vuejs.org/guide/essentials/event-handling.html", + }, + ) d.append(shadowFilter) # Define linear colored gradient @@ -106,7 +124,19 @@ for card_data in cards: # Draw card background background = dw.Group(id="background") - background.append(dw.Rectangle(0, 0, x_width, y_height, rx=15, ry=18, fill="black", stroke="white", stroke_width=1)) + background.append( + dw.Rectangle( + 0, + 0, + x_width, + y_height, + rx=15, + ry=18, + fill="black", + stroke="white", + stroke_width=1, + ) + ) background.append( dw.Rectangle( border_width_x, @@ -161,41 +191,51 @@ for card_data in cards: ) d.append(title) - # Draw faction icon d.append( - dw.Group(children=[faction_icon],transform=f"translate({border_width_x + 23 + 1},{border_width_y - border_upper_offset + 20 + 4 + 1})") + dw.Group( + children=[faction_icon], + transform=f"translate({border_width_x + 23 + 1},{border_width_y - border_upper_offset + 20 + 4 + 1})", + ) ) # Draw card cost if card_data.get("cost") is not None: d.append( - dw.Group(children=[create_gold_icon(cast(int,card_data.get("cost")))],transform=f"translate({x_width - cost_right_offset},{19 + border_width_y})") + dw.Group( + children=[create_gold_icon(cast(int, card_data.get("cost")))], + transform=f"translate({x_width - cost_right_offset},{19 + border_width_y})", + ) ) d.append(dw.Rectangle(x=0, y=65, width=x_width, height=200)) - d.append(dw.Image(x=0, y=65, width=x_width, height=200,path=card_skin_data["image_path"])) - + d.append( + dw.Image( + x=0, y=65, width=x_width, height=200, path=card_skin_data["image_path"] + ) + ) # Draw effects effects = card_data.get("effects") if effects is not None: - effects = create_effects( - effects=effects, - height=135, - width=x_internal_width - ) - d.append(dw.Group( + effects = create_effects(effects=effects, height=135, width=x_internal_width) + d.append( + dw.Group( effects, transform=f"translate({border_width_x},{265})", - )) + ) + ) # If champion, draw champion shield with defense if card_data["card_type"] == "champion": shield = draw_champion_shield(card_data, border_width_x) - d.append(dw.Group( + d.append( + dw.Group( shield, transform=f"translate({x_width-30},{y_height})", - )) + ) + ) # Save the SVG file - d.save_svg(f"output/{all_skin_data['skin_name']}/{str(card_data["id"]).zfill(3)}.svg") + d.save_svg( + f"output/{all_skin_data['skin_name']}/{str(card_data['id']).zfill(3)}.svg" + )