current hitpoints added
This commit is contained in:
18
generate.py
18
generate.py
@@ -13,6 +13,7 @@ DNDB_CHARS = [
|
||||
"portraitName": "vevel",
|
||||
"characterUrl": "/profile/megavenik/characters/69760590",
|
||||
"avatarUrl": "https://www.dndbeyond.com/avatars/thumbnails/31479/654/150/154/1581111423-69760590.jpeg",
|
||||
"hitpointsCoords": (603, 168),
|
||||
},
|
||||
{
|
||||
"characterId": 69976266,
|
||||
@@ -21,6 +22,7 @@ DNDB_CHARS = [
|
||||
"portraitName": "milosh",
|
||||
"characterUrl": "/profile/EdgarBrin/characters/69976266",
|
||||
"avatarUrl": "https://www.dndbeyond.com/avatars/thumbnails/31479/725/150/155/1581111423-69976266.jpeg",
|
||||
"hitpointsCoords": (588, 168),
|
||||
},
|
||||
{
|
||||
"characterId": 69976392,
|
||||
@@ -29,6 +31,7 @@ DNDB_CHARS = [
|
||||
"portraitName": "militsa",
|
||||
"characterUrl": "/profile/tritiumTino/characters/69976392",
|
||||
"avatarUrl": "https://www.dndbeyond.com/avatars/thumbnails/31479/709/150/154/1581111423-69976392.jpeg",
|
||||
"hitpointsCoords": (566, 168),
|
||||
},
|
||||
{
|
||||
"characterId": 90463225,
|
||||
@@ -37,6 +40,7 @@ DNDB_CHARS = [
|
||||
"portraitName": "nivenna",
|
||||
"characterUrl": "/profile/Maslinium/characters/90463225",
|
||||
"avatarUrl": "https://www.dndbeyond.com/avatars/thumbnails/31479/748/160/150/1581111423-90463225.jpeg",
|
||||
"hitpointsCoords": (566, 168),
|
||||
},
|
||||
{
|
||||
"characterId": 99072742,
|
||||
@@ -45,6 +49,7 @@ DNDB_CHARS = [
|
||||
"portraitName": "darpa",
|
||||
"characterUrl": "/profile/Forfattare/characters/99072742",
|
||||
"avatarUrl": "https://www.dndbeyond.com/avatars/thumbnails/34003/953/150/153/1581111423-99072742.jpeg",
|
||||
"hitpointsCoords": (624, 168),
|
||||
},
|
||||
{
|
||||
"characterId": 99483409,
|
||||
@@ -53,6 +58,7 @@ DNDB_CHARS = [
|
||||
"portraitName": "deyan",
|
||||
"characterUrl": "/profile/SantaKosh/characters/99483409",
|
||||
"avatarUrl": "https://www.dndbeyond.com/avatars/thumbnails/34005/197/157/150/1581111423-99483409.jpeg",
|
||||
"hitpointsCoords": (670, 168),
|
||||
}
|
||||
]
|
||||
|
||||
@@ -354,6 +360,7 @@ def generate_main(char: dict):
|
||||
ch = CharacterService()
|
||||
print(f"Chars name: {char['characterName']}")
|
||||
max_hp = ch.get_max_hp(data)
|
||||
current_hp = max_hp - int(data['removedHitPoints'])
|
||||
print(f"CHARS HEALTH: {max_hp-int(data['removedHitPoints'])}/{max_hp}")
|
||||
|
||||
# Load the background image
|
||||
@@ -361,9 +368,11 @@ def generate_main(char: dict):
|
||||
|
||||
# Load the image to be placed on top
|
||||
foreground = Image.open(f"parts/{char['portraitName']}-main.png")
|
||||
hitpoints = Image.open(f"parts/{char['portraitName']}-hitpoints.png")
|
||||
|
||||
# Paste the foreground image onto the background
|
||||
background.paste(foreground, (0, 0), foreground)
|
||||
background.paste(hitpoints, (0, 0), hitpoints)
|
||||
|
||||
# Create a drawing context
|
||||
draw = ImageDraw.Draw(background)
|
||||
@@ -384,6 +393,15 @@ def generate_main(char: dict):
|
||||
|
||||
draw.text(calculate_coordinates(label_width, label_height, STATS_DICT[stat]["coords"]), stats_label, font=stats_font, fill=(255, 255, 255))
|
||||
|
||||
# hitpoints tag
|
||||
hitpoints_font = ImageFont.truetype("fonts/NotoSerif-Regular.ttf", 30)
|
||||
|
||||
hitpoints_label = f"{current_hp}"
|
||||
|
||||
label_width, label_height = get_correct_text_sizes(draw, hitpoints_label, hitpoints_font)
|
||||
|
||||
draw.text(calculate_coordinates(label_width, label_height, char['hitpointsCoords']), hitpoints_label, font=hitpoints_font, fill=(255, 255, 255))
|
||||
|
||||
name_font = ImageFont.truetype("fonts/alaruss.ttf", 96)
|
||||
name_label = char['characterName'].upper()
|
||||
|
||||
|
||||
BIN
parts/darpa-hitpoints.png
Normal file
BIN
parts/darpa-hitpoints.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
BIN
parts/deyan-hitpoints.png
Normal file
BIN
parts/deyan-hitpoints.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
BIN
parts/militsa-hitpoints.png
Normal file
BIN
parts/militsa-hitpoints.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
BIN
parts/milosh-hitpoints.png
Normal file
BIN
parts/milosh-hitpoints.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
BIN
parts/nivenna-hitpoints.png
Normal file
BIN
parts/nivenna-hitpoints.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
BIN
parts/vevel-hitpoints.png
Normal file
BIN
parts/vevel-hitpoints.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
Reference in New Issue
Block a user