37 lines
1.9 KiB
Python
37 lines
1.9 KiB
Python
from typing import List
|
|
|
|
stats_radius = 22
|
|
|
|
|
|
def draw_effects_resources_for_row(dwg, effects: List, y: int, x_width: int):
|
|
row_1_nb_effects = len(effects)
|
|
|
|
row_1_x_offset = -20
|
|
row_1_x_step = 60
|
|
if row_1_nb_effects == 1:
|
|
row_1_x_offset = 0
|
|
elif row_1_nb_effects == 2:
|
|
row_1_x_offset = -20
|
|
elif row_1_nb_effects == 3:
|
|
row_1_x_offset = -40
|
|
row_1_nb_effects_applied = 0
|
|
|
|
for effect in effects:
|
|
if effect.get('effect') == '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, y + stats_radius), r=stats_radius, fill='red'))
|
|
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
|
|
|
|
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, y + stats_radius), r=stats_radius, fill='yellow'))
|
|
dwg.add(dwg.text(str(effect.get('amount')), insert=(x_effect_pos, 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') == 'heal':
|
|
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, 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
|