50 lines
1.6 KiB
Python
50 lines
1.6 KiB
Python
from map.quest_map import MapEncounter, QuestMap, EncounterType
|
|
|
|
from typing import List, Dict, Optional
|
|
|
|
_ICONS = {
|
|
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) -> 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(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,
|
|
}
|