diff --git a/img/heal_icon.svg b/img/heal_icon.svg new file mode 100644 index 0000000..fed5d8d --- /dev/null +++ b/img/heal_icon.svg @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/img/missing.png b/img/missing.png new file mode 100644 index 0000000..26a5882 Binary files /dev/null and b/img/missing.png differ diff --git a/output/heron/001.svg b/output/heron/001.svg new file mode 100644 index 0000000..80ff7d3 --- /dev/null +++ b/output/heron/001.svg @@ -0,0 +1,2 @@ + +Arkus, Imperial DragonChampion856Garde6 \ No newline at end of file diff --git a/output/heron/010.svg b/output/heron/010.svg index e9fb420..c7297a7 100644 --- a/output/heron/010.svg +++ b/output/heron/010.svg @@ -1,2 +1,2 @@ -Rallier les TroupesAction, Charme455Mobilisez un champion. \ No newline at end of file +Rallier les TroupesAction, Charme455Mobilisez un champion. \ No newline at end of file diff --git a/src/data/cards_data.json b/src/data/cards_data.json index 8a9d32f..55a841d 100644 --- a/src/data/cards_data.json +++ b/src/data/cards_data.json @@ -1,5 +1,33 @@ { "cards": [ + { + "id": 1, + "role": "market", + "card_type": "champion", + "faction": "yellow", + "name": "Arkus, Imperial Dragon", + "cost": 8, + "defense": 6, + "guard": true, + "init_amount": 1, + "effects": [ + { + "effect": "draw", + "amount": 1, + "effect_type": "champion_action" + }, + { + "effect": "damage", + "amount": 5, + "effect_type": "champion_action" + }, + { + "effect": "heal", + "amount": 6, + "effect_type": "faction_combo" + } + ] + }, { "id": 13, "role": "market", diff --git a/src/data/heron_skin.json b/src/data/heron_skin.json index 5aea6f8..cff831e 100644 --- a/src/data/heron_skin.json +++ b/src/data/heron_skin.json @@ -2,12 +2,12 @@ "skin_name": "heron", "10": { "title": "Rallier les Troupes", - "type": "Action, Charme", - "image_path": "img/skins/heron/010.png" + "flavor_text_type": "Charme", + "image_path": "../../img/skins/heron/010.png" }, "13": { "title": "Caprisun", - "type": "Action, 20cl", + "flavor_text_type": "20cl", "image_path": "lancersiz3.png" } } diff --git a/src/draw.py b/src/draw.py index 321aa78..1396460 100644 --- a/src/draw.py +++ b/src/draw.py @@ -1,4 +1,5 @@ from typing import List +from math import sin, cos, pi stats_radius = 22 @@ -34,3 +35,11 @@ def draw_effects_resources_for_row(dwg, effects: List, y: int, x_width: int): dwg.add(dwg.circle(center=(x_effect_pos, y + stats_radius), r=stats_radius, fill='green')) dwg.add(dwg.text(str(effect.get('amount')), insert=(x_effect_pos, y + stats_radius + 9), text_anchor='middle', fill='white', font_size='24px', font_weight="bold", font_family='Helvetica')) row_1_nb_effects_applied += 1 + +def create_pentagon(center, radius): + points = [] + for i in range(5): + x = center[0] + radius * cos(2 * pi * i / 5 + (pi / 2)) + y = center[1] + radius * sin(2 * pi * i / 5 + (pi / 2)) + points.append((x, y)) + return points diff --git a/src/generate_cards_mvp.py b/src/generate_cards_mvp.py index f9df416..a28e9f7 100644 --- a/src/generate_cards_mvp.py +++ b/src/generate_cards_mvp.py @@ -3,7 +3,7 @@ import json from typing import List import os -from draw import draw_effects_resources_for_row +from draw import create_pentagon, draw_effects_resources_for_row with open('src/data/heron_skin.json') as f: @@ -17,6 +17,7 @@ border_width_y = 17 border_upper_offset = 5 title_y_offset = 24 title_font_size = 19 +title_font_size_small = 16 subtitle_font_size = 13 cost_right_offset = 38 effect_text_size = 14 @@ -50,7 +51,11 @@ with open('src/data/cards_data.json') as f: for card_data in cards: # Get card skin data - card_skin_data = all_skin_data[str(card_data['id'])] + try: + card_skin_data = all_skin_data[str(card_data['id'])] + except KeyError: + print('Missing skin data for card id:', card_data['id'], 'using default skin data') + card_skin_data = { 'title': card_data['name'], 'image_path': '../../img/missing.png'} # Create a new SVG drawing output_dir = 'output/' + all_skin_data['skin_name'] @@ -83,10 +88,23 @@ for card_data in cards: # Draw title area # dwg.add(dwg.rect(insert=(0, 0), size=(str(x_width) + 'px', '50px'), fill='white')) - dwg.add(dwg.text(card_skin_data['title'], insert=(x_width/2, title_y_offset + border_width_y - border_upper_offset), text_anchor='middle', fill='black', font_size=str(title_font_size) + 'px', font_weight="bold", font_family='Helvetica')) + card_title = card_skin_data['title'] + temp_title_font_size = title_font_size + if len(card_title) > 20: + temp_title_font_size = title_font_size_small + if len(card_title) > 23: + temp_title_font_size = title_font_size_small - 2 + dwg.add(dwg.text(card_skin_data['title'], insert=(x_width/2, title_y_offset + border_width_y - border_upper_offset), text_anchor='middle', fill='black', font_size=str(temp_title_font_size) + 'px', font_weight="bold", font_family='Helvetica')) # Draw type area - dwg.add(dwg.text(card_skin_data['type'], insert=(x_width/2, title_y_offset + title_font_size + 10), text_anchor='middle', fill='black', font_size=str(subtitle_font_size) + 'px', font_family='Helvetica')) + card_type_text = "" + if card_data['card_type'] == 'champion': + card_type_text = "Champion" + elif card_data['card_type'] == 'action': + card_type_text = "Action" + if 'flavor_text_type' in card_skin_data.keys(): + card_type_text += ', ' + card_skin_data['flavor_text_type'] + dwg.add(dwg.text(card_type_text, insert=(x_width/2, title_y_offset + title_font_size + 10), text_anchor='middle', fill='black', font_size=str(subtitle_font_size) + 'px', font_family='Helvetica')) # Draw faction icon dwg.add(dwg.circle(center=(border_width_x + 23 + 1, border_width_y - border_upper_offset + 20 + 4 + 1), r=20, fill='black')) @@ -104,6 +122,12 @@ for card_data in cards: dwg.add(dwg.rect(insert=(border_width_x, 265), size=(str(30) + 'px', str(y_height - 265 - border_width_y) + 'px'), fill='url(#grad1)')) + # If champion, draw champion action icon + if card_data['card_type'] == 'champion': + row_1_icon_x = border_width_x + 35 + dwg.add(dwg.circle(center=(row_1_icon_x + 1, row_1_base_y + 20 + 1), r=15, fill='#111')) + dwg.add(dwg.circle(center=(row_1_icon_x, row_1_base_y + 20), r=15, fill='#555')) + # TODO: figure out nb of effects and adjust row_1_x_offset accordingly def is_base_effect(array: List): return not 'effect_type' in array.keys() or array['effect_type'] == 'champion_action' @@ -117,6 +141,9 @@ for card_data in cards: # Draw row 1 stats draw_effects_resources_for_row(dwg, base_effects, row_1_base_y, x_width) + # Draw row 1 text + effect_text_1 = "" + if other_effects: # Draw row 1 to row 2 separator @@ -139,5 +166,25 @@ for card_data in cards: effect_text_2 = "Mobilisez un champion." dwg.add(dwg.text(effect_text_2, insert=(x_width/2, row_2_base_y), text_anchor='middle', fill='black', font_size=str(effect_text_size) + 'px', font_family='Helvetica')) + # If champion, draw champion shield with defense + if card_data['card_type'] == 'champion': + if not card_data['guard']: + pentagon_points = create_pentagon(center=(x_width - border_width_x - 15, y_height - 30), radius=28) + dwg.add(dwg.polygon(points=pentagon_points, fill='darkgrey', stroke='#eee', stroke_width=1)) + # dwg.add(dwg.circle(center=(x_width - border_width_x - 15, y_height - 30), r=27, fill='darkgrey')) + # dwg.add(dwg.circle(center=(x_width - border_width_x - 15, y_height - 30), r=25, fill='lightgrey')) + dwg.add(dwg.text(str(card_data['defense']), insert=(x_width - border_width_x - 15, y_height - 20), text_anchor='middle', fill='black', font_size='28px', font_weight="bold", font_family='Helvetica')) + else: + pentagon_points = create_pentagon(center=(x_width - border_width_x - 15, y_height - 30), radius=28) + dwg.add(dwg.polygon(points=pentagon_points, fill='black', stroke='lightgrey', stroke_width=1)) + # dwg.add(dwg.circle(center=(x_width - border_width_x - 15, y_height - 30), r=27, fill='lightgrey')) + # dwg.add(dwg.circle(center=(x_width - border_width_x - 15, y_height - 30), r=25, fill='#111')) + # Draw guard rectangle with text inside, above the shield + dwg.add(dwg.rect(insert=(x_width - border_width_x - 40, y_height - 72), size=(49, 17), fill='lightgrey')) + dwg.add(dwg.rect(insert=(x_width - border_width_x - 39, y_height - 71), size=(47, 15), fill='#111')) + dwg.add(dwg.text('Garde', insert=(x_width - border_width_x - 15, y_height - 59), text_anchor='middle', fill='white', font_size='12px', font_weight="bold", font_family='Helvetica')) + dwg.add(dwg.text(str(card_data['defense']), insert=(x_width - border_width_x - 15, y_height - 20), text_anchor='middle', fill='white', font_size='28px', font_weight="bold", font_family='Helvetica')) + + # Save the SVG file dwg.save()