Render encounters

This commit is contained in:
henriquenakashima 2021-03-28 15:09:08 -04:00
parent 075e373ab2
commit f6b0f860f7
8 changed files with 148 additions and 16 deletions

View file

@ -1,13 +1,50 @@
from map.quest_map import MapEncounter, QuestMap, EncounterType
from typing import List, Dict, Optional
_ICONS = {
EncounterType.BATTLE_REGULAR: 'noun_Battle_3647629.png'
EncounterType.BATTLE_REGULAR: 'noun_Battle_3647629.png',
EncounterType.BATTLE_ELITE: 'noun_Shield_3806325.png',
EncounterType.BATTLE_BOSS: 'noun_dragon_3820621.png',
EncounterType.TOWN_TAVERN: 'noun_Beer_3054928.png',
EncounterType.TOWN_DOCKS: 'noun_Caravel_2421659.png',
EncounterType.TOWN_MARKET: 'noun_Store_786819.png',
EncounterType.TOWN_LIBRARY: 'noun_Library_3820590.png',
EncounterType.TOWN_WORKSHOP: 'noun_cogs_442166.png',
EncounterType.TOWN_TOWN_HALL: 'noun_brussels town hall_3284349.png',
EncounterType.TOWN_TEMPLE: 'noun_temple_2382601.png',
EncounterType.TOWN_REST: 'noun_Tent_3814999.png',
EncounterType.TOWN_ROAD: 'noun_Hiking Trail_2686687.png',
}
def render_map(quest_map: QuestMap):
return [__render_encounter(MapEncounter(EncounterType.BATTLE_REGULAR))] * 3
def render_map(quest_map: QuestMap) -> List[Dict]:
rendered_encounters = []
row: List[MapEncounter]
for r, row in enumerate(quest_map.encounters):
for c, encounter in enumerate(row):
rendered_encounter = _render_encounter(r, c, encounter)
if rendered_encounter is not None:
rendered_encounters.append(rendered_encounter)
return rendered_encounters
def __render_encounter(encounter: MapEncounter):
return f'map/{_ICONS[encounter.type]}'
def _render_encounter(r: int, c: int, encounter: MapEncounter) -> Optional[Dict]:
if encounter.type == EncounterType.INACCESSIBLE:
return None
icon = f'map/{_ICONS[encounter.type]}'
x = 200 * c
y = 100 * r
w = 90
h = 90
return {
'description': encounter.description,
'src': icon,
'x': x,
'y': y,
'w': w,
'h': h,
}