feat(wip): actually read from json
This commit is contained in:
+6
-12
@@ -1,15 +1,9 @@
|
||||
{
|
||||
"title": "Rallier les Troupes",
|
||||
"type": "Action, Charme",
|
||||
"faction": "yellow",
|
||||
"cost": 4,
|
||||
"image_path": "lancersiz3.png",
|
||||
"row_1": {
|
||||
"damage": 5,
|
||||
"heal": 5
|
||||
},
|
||||
"row_2": {
|
||||
"effect": "Mobilisez un Champion."
|
||||
"10": {
|
||||
"title": "Rallier les Troupes",
|
||||
"type": "Action, Charme",
|
||||
"image_path": "lancersiz3.png"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+33
-17
@@ -64,10 +64,11 @@
|
||||
|
||||
import svgwrite
|
||||
import json
|
||||
from typing import Array
|
||||
|
||||
|
||||
# Load card data from JSON file
|
||||
with open('src/card_data.json') as f:
|
||||
card_data = json.load(f)
|
||||
all_skin_data = json.load(f)
|
||||
|
||||
# Params
|
||||
x_width = 298
|
||||
@@ -105,6 +106,12 @@ icon_colors = {
|
||||
'yellow': ['#ff9935', '#ffe744']
|
||||
}
|
||||
|
||||
# Load card data from JSON file
|
||||
with open('src/actual_card_data.json') as f:
|
||||
card_data = json.load(f)
|
||||
|
||||
card_skin_data = all_skin_data['id']
|
||||
|
||||
|
||||
# Create a new SVG drawing
|
||||
dwg = svgwrite.Drawing('card.svg', profile='tiny', size=(str(x_width) + 'px', str(y_height) + 'px'))
|
||||
@@ -135,10 +142,10 @@ dwg.add(dwg.rect(insert=(border_width_x, border_width_y - border_upper_offset),
|
||||
|
||||
# Draw title area
|
||||
# dwg.add(dwg.rect(insert=(0, 0), size=(str(x_width) + 'px', '50px'), fill='white'))
|
||||
dwg.add(dwg.text(card_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'))
|
||||
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'))
|
||||
|
||||
# Draw type area
|
||||
dwg.add(dwg.text(card_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'))
|
||||
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'))
|
||||
|
||||
# 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'))
|
||||
@@ -152,13 +159,20 @@ dwg.add(dwg.text(str(card_data['cost']), insert=(x_width - cost_right_offset, 26
|
||||
|
||||
# Draw image area
|
||||
dwg.add(dwg.rect(insert=(0, 65), size=(str(x_width) + 'px', '200px'), fill='black'))
|
||||
dwg.add(dwg.image(card_data['image_path'], insert=(0, 65), size=(x_width, 200)))
|
||||
dwg.add(dwg.image(card_skin_data['image_path'], insert=(0, 65), size=(x_width, 200)))
|
||||
|
||||
dwg.add(dwg.rect(insert=(border_width_x, 265), size=(str(30) + 'px', str(y_height - 265 - border_width_y) + 'px'), fill='url(#grad1)'))
|
||||
|
||||
# TODO: figure out nb of effects and adjust row_1_x_offset accordingly
|
||||
card_effects = card_data['row_1']
|
||||
row_1_nb_effects = len(card_data['row_1'].keys())
|
||||
def is_base_effect(array: Array):
|
||||
return array['effect_type'] == 'champion_action' or not array['effect_type']
|
||||
|
||||
card_effects: Array = card_data['effects']
|
||||
base_effects = list(filter(is_base_effect, card_effects))
|
||||
other_effects = list(filter(lambda x: not is_base_effect(x), card_effects))
|
||||
# card_effects = card_data['row_1']
|
||||
# row_1_nb_effects = len(card_data['row_1'].keys())
|
||||
row_1_nb_effects = len(base_effects)
|
||||
|
||||
row_1_x_offset = -20
|
||||
row_1_x_step = 60
|
||||
@@ -171,17 +185,19 @@ elif row_1_nb_effects == 3:
|
||||
row_1_nb_effects_applied = 0
|
||||
|
||||
# Draw row 1 stats
|
||||
if card_effects.get('damage'):
|
||||
x_effect_pos = x_width/2 + row_1_x_offset + row_1_x_step*row_1_nb_effects_applied
|
||||
dwg.add(dwg.circle(center=(x_effect_pos, row_1_base_y + stats_radius), r=stats_radius, fill='red'))
|
||||
dwg.add(dwg.text(str(card_data['row_1']['damage']), insert=(x_effect_pos, row_1_base_y + stats_radius + 9), text_anchor='middle', fill='white', font_size='24px', font_weight="bold", font_family='Helvetica'))
|
||||
row_1_nb_effects_applied += 1
|
||||
for effect in base_effects:
|
||||
if effect.get('effect') == 'damage':
|
||||
# if card_effects.get('damage'):
|
||||
x_effect_pos = x_width/2 + row_1_x_offset + row_1_x_step*row_1_nb_effects_applied
|
||||
dwg.add(dwg.circle(center=(x_effect_pos, row_1_base_y + stats_radius), r=stats_radius, fill='red'))
|
||||
dwg.add(dwg.text(str(effect.get('amount')), insert=(x_effect_pos, row_1_base_y + stats_radius + 9), text_anchor='middle', fill='white', font_size='24px', font_weight="bold", font_family='Helvetica'))
|
||||
row_1_nb_effects_applied += 1
|
||||
|
||||
if card_effects.get('gold'):
|
||||
x_effect_pos = x_width/2 + row_1_x_offset + row_1_x_step*row_1_nb_effects_applied
|
||||
dwg.add(dwg.circle(center=(x_effect_pos, row_1_base_y + stats_radius), r=stats_radius, fill='yellow'))
|
||||
dwg.add(dwg.text(str(card_data['row_1']['gold']), insert=(x_effect_pos, row_1_base_y + stats_radius + 9), text_anchor='middle', fill='black', font_size='24px', font_weight="bold", font_family='Helvetica'))
|
||||
row_1_nb_effects_applied += 1
|
||||
if effect.get('effect') == 'gold':
|
||||
x_effect_pos = x_width/2 + row_1_x_offset + row_1_x_step*row_1_nb_effects_applied
|
||||
dwg.add(dwg.circle(center=(x_effect_pos, row_1_base_y + stats_radius), r=stats_radius, fill='yellow'))
|
||||
dwg.add(dwg.text(str(card_data['row_1']['gold']), insert=(x_effect_pos, row_1_base_y + stats_radius + 9), text_anchor='middle', fill='black', font_size='24px', font_weight="bold", font_family='Helvetica'))
|
||||
row_1_nb_effects_applied += 1
|
||||
|
||||
if card_effects.get('heal'):
|
||||
x_effect_pos = x_width/2 + row_1_x_offset + row_1_x_step*row_1_nb_effects_applied
|
||||
|
||||
@@ -0,0 +1,366 @@
|
||||
{
|
||||
"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": 2,
|
||||
"role": "market",
|
||||
"card_type": "action",
|
||||
"faction": "yellow",
|
||||
"name": "Close Ranks",
|
||||
"cost": 3,
|
||||
"init_amount": 1,
|
||||
"effects": [
|
||||
{
|
||||
"effect": "damage",
|
||||
"amount": 5
|
||||
},
|
||||
{
|
||||
"effect": "damage",
|
||||
"amount": 2,
|
||||
"times": "per_champion"
|
||||
},
|
||||
{
|
||||
"effect": "heal",
|
||||
"amount": 6,
|
||||
"effect_type": "faction_combo"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"role": "market",
|
||||
"card_type": "action",
|
||||
"faction": "yellow",
|
||||
"name": "Command",
|
||||
"cost": 5,
|
||||
"init_amount": 1,
|
||||
"effects": [
|
||||
{
|
||||
"effect": "draw",
|
||||
"amount": 1
|
||||
},
|
||||
{
|
||||
"effect": "damage",
|
||||
"amount": 3
|
||||
},
|
||||
{
|
||||
"effect": "gold",
|
||||
"amount": 2
|
||||
},
|
||||
{
|
||||
"effect": "heal",
|
||||
"amount": 4
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"role": "market",
|
||||
"card_type": "champion",
|
||||
"faction": "yellow",
|
||||
"name": "Darian , War Mage",
|
||||
"cost": 4,
|
||||
"defense": 5,
|
||||
"guard": false,
|
||||
"init_amount": 1,
|
||||
"effects": [
|
||||
{
|
||||
"effect": "damage",
|
||||
"amount": 3,
|
||||
"effect_type": "champion_action",
|
||||
"mutex": 1
|
||||
},
|
||||
{
|
||||
"effect": "heal",
|
||||
"amount": 4,
|
||||
"effect_type": "champion_action",
|
||||
"mutex": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"role": "market",
|
||||
"card_type": "action",
|
||||
"faction": "yellow",
|
||||
"name": "Domination",
|
||||
"cost": 7,
|
||||
"init_amount": 1,
|
||||
"effects": [
|
||||
{
|
||||
"effect": "heal",
|
||||
"amount": 6
|
||||
},
|
||||
{
|
||||
"effect": "damage",
|
||||
"amount": 6
|
||||
},
|
||||
{
|
||||
"effect": "draw",
|
||||
"amount": 1
|
||||
},
|
||||
{
|
||||
"effect": "prepare",
|
||||
"amount": 1,
|
||||
"effect_type": "faction_combo"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"role": "market",
|
||||
"card_type": "champion",
|
||||
"faction": "yellow",
|
||||
"name": "Cristov, the Just",
|
||||
"cost": 5,
|
||||
"defense": 5,
|
||||
"guard": true,
|
||||
"init_amount": 1,
|
||||
"effects": [
|
||||
{
|
||||
"effect": "damage",
|
||||
"amount": 2,
|
||||
"effect_type": "champion_action"
|
||||
},
|
||||
{
|
||||
"effect": "heal",
|
||||
"amount": 3,
|
||||
"effect_type": "champion_action"
|
||||
},
|
||||
{
|
||||
"effect": "draw",
|
||||
"amount": 1,
|
||||
"effect_type": "faction_combo"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"role": "market",
|
||||
"card_type": "champion",
|
||||
"faction": "yellow",
|
||||
"name": "Kraka, High Priest",
|
||||
"cost": 6,
|
||||
"defense": 6,
|
||||
"guard": false,
|
||||
"init_amount": 1,
|
||||
"effects": [
|
||||
{
|
||||
"effect": "heal",
|
||||
"amount": 2,
|
||||
"effect_type": "champion_action"
|
||||
},
|
||||
{
|
||||
"effect": "draw",
|
||||
"amount": 1,
|
||||
"effect_type": "champion_action"
|
||||
},
|
||||
{
|
||||
"effect": "heal",
|
||||
"amount": 2,
|
||||
"effect_type": "faction_combo",
|
||||
"times": "per_champion"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"role": "market",
|
||||
"card_type": "champion",
|
||||
"faction": "yellow",
|
||||
"name": "Man-at-Arms",
|
||||
"cost": 3,
|
||||
"defense": 4,
|
||||
"guard": true,
|
||||
"init_amount": 2,
|
||||
"effects": [
|
||||
{
|
||||
"effect": "damage",
|
||||
"amount": 2,
|
||||
"effect_type": "champion_action"
|
||||
},
|
||||
{
|
||||
"effect": "damage",
|
||||
"amount": 1,
|
||||
"times": "per_other_guard",
|
||||
"effect_type": "champion_action"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"role": "market",
|
||||
"card_type": "champion",
|
||||
"faction": "yellow",
|
||||
"name": "Master Weyan",
|
||||
"cost": 4,
|
||||
"defense": 4,
|
||||
"guard": true,
|
||||
"init_amount": 1,
|
||||
"effects": [
|
||||
{
|
||||
"effect": "damage",
|
||||
"amount": 3,
|
||||
"effect_type": "champion_action"
|
||||
},
|
||||
{
|
||||
"effect": "damage",
|
||||
"amount": 1,
|
||||
"times": "per_other_champion",
|
||||
"effect_type": "champion_action"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"role": "market",
|
||||
"card_type": "action",
|
||||
"faction": "yellow",
|
||||
"name": "Rally the Troops",
|
||||
"cost": 4,
|
||||
"init_amount": 1,
|
||||
"effects": [
|
||||
{
|
||||
"effect": "heal",
|
||||
"amount": 5
|
||||
},
|
||||
{
|
||||
"effect": "damage",
|
||||
"amount": 5
|
||||
},
|
||||
{
|
||||
"effect": "prepare",
|
||||
"amount": 1,
|
||||
"effect_type": "faction_combo"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"role": "market",
|
||||
"card_type": "action",
|
||||
"faction": "yellow",
|
||||
"name": "Recruit",
|
||||
"cost": 2,
|
||||
"init_amount": 3,
|
||||
"effects": [
|
||||
{
|
||||
"effect": "gold",
|
||||
"amount": 2
|
||||
},
|
||||
{
|
||||
"effect": "heal",
|
||||
"amount": 3
|
||||
},
|
||||
{
|
||||
"effect": "heal",
|
||||
"amount": 1,
|
||||
"times": "per_champion"
|
||||
},
|
||||
{
|
||||
"effect": "gold",
|
||||
"amount": 1,
|
||||
"effect_type": "faction_combo"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"role": "market",
|
||||
"card_type": "champion",
|
||||
"faction": "yellow",
|
||||
"name": "Tits Priest",
|
||||
"cost": 2,
|
||||
"defense": 3,
|
||||
"guard": false,
|
||||
"init_amount": 2,
|
||||
"effects": [
|
||||
{
|
||||
"effect": "gold",
|
||||
"amount": 1,
|
||||
"effect_type": "champion_action",
|
||||
"mutex": 1
|
||||
},
|
||||
{
|
||||
"effect": "heal",
|
||||
"amount": 1,
|
||||
"effect_type": "champion_action",
|
||||
"mutex": 1,
|
||||
"times": "per_champion"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 13,
|
||||
"role": "market",
|
||||
"card_type": "action",
|
||||
"faction": "yellow",
|
||||
"name": "Taxation",
|
||||
"cost": 1,
|
||||
"init_amount": 3,
|
||||
"effects": [
|
||||
{
|
||||
"effect": "gold",
|
||||
"amount": 2
|
||||
},
|
||||
{
|
||||
"effect": "heal",
|
||||
"amount": 6,
|
||||
"effect_type": "faction_combo"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 14,
|
||||
"role": "market",
|
||||
"card_type": "action",
|
||||
"faction": "yellow",
|
||||
"name": "Word of Power",
|
||||
"cost": 6,
|
||||
"init_amount": 1,
|
||||
"effects": [
|
||||
{
|
||||
"effect": "draw",
|
||||
"amount": 2
|
||||
},
|
||||
{
|
||||
"effect": "heal",
|
||||
"amount": 5,
|
||||
"effect_type": "faction_combo"
|
||||
},
|
||||
{
|
||||
"effect": "damage",
|
||||
"amount": 5,
|
||||
"effect_type": "suicide"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user