Show treasures
|
|
@ -11,3 +11,13 @@ Beer by Serhii Smirnov from the Noun Project
|
||||||
Caravel by Rahmat Hidayat from the Noun Project
|
Caravel by Rahmat Hidayat from the Noun Project
|
||||||
question mark by Icon Lauk from the Noun Project
|
question mark by Icon Lauk from the Noun Project
|
||||||
Hiking Trail by Weltenraser from the Noun Project
|
Hiking Trail by Weltenraser from the Noun Project
|
||||||
|
coin by Michele Zamparo from the Noun Project
|
||||||
|
Carving Tools by Coby Graphics from the Noun Project
|
||||||
|
Ink by MRK from the Noun Project
|
||||||
|
deed by Vectors Point from the Noun Project
|
||||||
|
Diamond by Dika Darma from the Noun Project
|
||||||
|
Crown by icon 54 from the Noun Project
|
||||||
|
life by Gregor Cresnar from the Noun Project
|
||||||
|
Art by Econceptive from the Noun Project
|
||||||
|
potion by Brianna Reed from the Noun Project
|
||||||
|
Ancient Egyptian religion by Dabid J. Pascual from the Noun Project
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
import dataclasses
|
import dataclasses
|
||||||
|
|
||||||
from map.quest_map import MapEncounter, QuestMap, EncounterType, QuestPath
|
from map.quest_map import MapEncounter, QuestMap, EncounterType, QuestPath, BattleEncounter
|
||||||
|
|
||||||
from typing import List, Dict, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
|
from map.treasure_hoard import TreasureType, Treasure
|
||||||
|
|
||||||
_ENCOUNTER_ICONS = {
|
_ENCOUNTER_ICONS = {
|
||||||
EncounterType.BATTLE_REGULAR: 'noun_Battle_3647629_cropped.png',
|
EncounterType.BATTLE_REGULAR: 'noun_Battle_3647629_cropped.png',
|
||||||
|
|
@ -12,7 +14,7 @@ _ENCOUNTER_ICONS = {
|
||||||
EncounterType.TOWN_DOCKS: 'noun_Caravel_2421659_cropped.png',
|
EncounterType.TOWN_DOCKS: 'noun_Caravel_2421659_cropped.png',
|
||||||
EncounterType.TOWN_MARKET: 'noun_Store_786819_cropped.png',
|
EncounterType.TOWN_MARKET: 'noun_Store_786819_cropped.png',
|
||||||
EncounterType.TOWN_LIBRARY: 'noun_Library_3820590_cropped.png',
|
EncounterType.TOWN_LIBRARY: 'noun_Library_3820590_cropped.png',
|
||||||
EncounterType.TOWN_WORKSHOP: 'noun_cogs_442166_cropped.png',
|
EncounterType.TOWN_WORKSHOP: 'noun_Carving Tools_693475_cropped.png',
|
||||||
EncounterType.TOWN_TOWN_HALL: 'noun_brussels town hall_3284349_cropped.png',
|
EncounterType.TOWN_TOWN_HALL: 'noun_brussels town hall_3284349_cropped.png',
|
||||||
EncounterType.TOWN_TEMPLE: 'noun_temple_2382601_cropped.png',
|
EncounterType.TOWN_TEMPLE: 'noun_temple_2382601_cropped.png',
|
||||||
EncounterType.TOWN_REST: 'noun_Tent_3814999_cropped.png',
|
EncounterType.TOWN_REST: 'noun_Tent_3814999_cropped.png',
|
||||||
|
|
@ -27,6 +29,20 @@ _PATH_ICONS = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_TREASURE_ICONS = {
|
||||||
|
TreasureType.GOLD: 'noun_coin_48892_cropped.png',
|
||||||
|
TreasureType.INK: 'noun_Ink_2509717_cropped.png',
|
||||||
|
TreasureType.COG: 'noun_cogs_442166_cropped.png',
|
||||||
|
TreasureType.DEED: 'noun_deed_3309438_cropped.png',
|
||||||
|
TreasureType.ART_OBJECT: 'noun_Art_3410337_cropped.png',
|
||||||
|
TreasureType.GEMS: 'noun_Diamond_3820185_cropped.png',
|
||||||
|
TreasureType.CONSUMABLE: 'noun_potion_34882_cropped.png',
|
||||||
|
TreasureType.NOBILITY_TITLE: 'noun_Crown_1936588_cropped.png',
|
||||||
|
TreasureType.LIFE: 'noun_life_3553107_cropped.png',
|
||||||
|
TreasureType.RELIC: 'noun_Ancient Egyptian religion_248077_cropped.png',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@dataclasses.dataclass(frozen=True)
|
@dataclasses.dataclass(frozen=True)
|
||||||
class RenderedElement:
|
class RenderedElement:
|
||||||
description: str
|
description: str
|
||||||
|
|
@ -35,6 +51,14 @@ class RenderedElement:
|
||||||
y: int
|
y: int
|
||||||
w: int
|
w: int
|
||||||
h: int
|
h: int
|
||||||
|
secondary: Optional['SecondaryRenderedElement'] = None
|
||||||
|
|
||||||
|
|
||||||
|
@dataclasses.dataclass(frozen=True)
|
||||||
|
class SecondaryRenderedElement(RenderedElement):
|
||||||
|
text: str = None
|
||||||
|
text_x: int = None
|
||||||
|
text_y: int = None
|
||||||
|
|
||||||
|
|
||||||
@dataclasses.dataclass(frozen=True)
|
@dataclasses.dataclass(frozen=True)
|
||||||
|
|
@ -73,34 +97,46 @@ def render_map(quest_map: QuestMap) -> RenderedMap:
|
||||||
return RenderedMap(rendered_encounters, rendered_paths)
|
return RenderedMap(rendered_encounters, rendered_paths)
|
||||||
|
|
||||||
|
|
||||||
|
_LEFT = 20
|
||||||
|
_TOP = 20
|
||||||
_ENCOUNTER_W = 40
|
_ENCOUNTER_W = 40
|
||||||
_ENCOUNTER_H = 40
|
_ENCOUNTER_H = 40
|
||||||
_ARROW_W = 40
|
_ARROW_W = 40
|
||||||
_ARROW_H = 20
|
_ARROW_H = 20
|
||||||
_PADDING_W = 10
|
_PADDING_W = 15
|
||||||
_PADDING_V = 5
|
_PADDING_V = 10
|
||||||
_ENCOUNTER_COLUMN_W = _ENCOUNTER_W + _PADDING_W
|
_ENCOUNTER_COLUMN_W = _ENCOUNTER_W + _PADDING_W
|
||||||
_PATH_COLUMN_W = _ARROW_W + _PADDING_W
|
_PATH_COLUMN_W = _ARROW_W + _PADDING_W
|
||||||
_COLUMN_W = _ENCOUNTER_COLUMN_W + _PATH_COLUMN_W
|
_COLUMN_W = _ENCOUNTER_COLUMN_W + _PATH_COLUMN_W
|
||||||
_ROW_H = _ENCOUNTER_H + _PADDING_V + _ARROW_H + _PADDING_V
|
_ROW_H = _ENCOUNTER_H + _PADDING_V + _ARROW_H + _PADDING_V
|
||||||
|
|
||||||
|
_SECONDARY_W = 24
|
||||||
|
_SECONDARY_H = 24
|
||||||
|
_SECONDARY_PADDING = 6
|
||||||
|
|
||||||
|
|
||||||
def _render_encounter(r: int, c: int, encounter: MapEncounter) -> Optional[RenderedEncounter]:
|
def _render_encounter(r: int, c: int, encounter: MapEncounter) -> Optional[RenderedEncounter]:
|
||||||
if encounter.type == EncounterType.INACCESSIBLE:
|
if encounter.type == EncounterType.INACCESSIBLE:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
icon = f'map/{_ENCOUNTER_ICONS[encounter.type]}'
|
icon = f'map/{_ENCOUNTER_ICONS[encounter.type]}'
|
||||||
x = _COLUMN_W * c
|
x = _LEFT + _COLUMN_W * c
|
||||||
y = _ROW_H * r
|
y = _TOP + _ROW_H * r
|
||||||
w = _ENCOUNTER_W
|
w = _ENCOUNTER_W
|
||||||
h = _ENCOUNTER_H
|
h = _ENCOUNTER_H
|
||||||
|
if isinstance(encounter, BattleEncounter):
|
||||||
|
x -= (_SECONDARY_PADDING + _SECONDARY_W) / 2
|
||||||
|
secondary = _render_battle_encounter_secondary_info(encounter, x, y, w, h)
|
||||||
|
else:
|
||||||
|
secondary = None
|
||||||
return RenderedEncounter(
|
return RenderedEncounter(
|
||||||
description=encounter.description,
|
description=encounter.description,
|
||||||
src=icon,
|
src=icon,
|
||||||
x=x,
|
x=x,
|
||||||
y=y,
|
y=y,
|
||||||
w=w,
|
w=w,
|
||||||
h=h
|
h=h,
|
||||||
|
secondary=secondary
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -109,8 +145,8 @@ def _render_path(r: int, c: int, path: QuestPath) -> Optional[RenderedPath]:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
icon = f'map/{_PATH_ICONS[path]}'
|
icon = f'map/{_PATH_ICONS[path]}'
|
||||||
x = _ENCOUNTER_COLUMN_W * ((c + 1) // 2) + _PATH_COLUMN_W * (c // 2)
|
x = _LEFT + _ENCOUNTER_COLUMN_W * ((c + 1) // 2) + _PATH_COLUMN_W * (c // 2)
|
||||||
y = (_ENCOUNTER_H + _PADDING_V) + _ROW_H * r
|
y = _TOP + (_ENCOUNTER_H + _PADDING_V) + _ROW_H * r
|
||||||
w = _ARROW_W
|
w = _ARROW_W
|
||||||
h = _ARROW_H
|
h = _ARROW_H
|
||||||
return RenderedPath(
|
return RenderedPath(
|
||||||
|
|
@ -119,5 +155,21 @@ def _render_path(r: int, c: int, path: QuestPath) -> Optional[RenderedPath]:
|
||||||
x=x,
|
x=x,
|
||||||
y=y,
|
y=y,
|
||||||
w=w,
|
w=w,
|
||||||
h=h
|
h=h,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _render_battle_encounter_secondary_info(encounter: BattleEncounter, x, y, w, h) -> Optional[RenderedElement]:
|
||||||
|
treasure: Treasure = encounter.treasure_hoard.revealed
|
||||||
|
return SecondaryRenderedElement(
|
||||||
|
description=encounter.treasure_hoard.description,
|
||||||
|
src = f'map/{_TREASURE_ICONS[treasure.treasure_type]}',
|
||||||
|
x=x + w + _SECONDARY_PADDING,
|
||||||
|
y=y,
|
||||||
|
w=_SECONDARY_W,
|
||||||
|
h=_SECONDARY_H,
|
||||||
|
secondary=None,
|
||||||
|
text=treasure.amount,
|
||||||
|
text_x=x + w + _SECONDARY_PADDING,
|
||||||
|
text_y=y + _SECONDARY_H
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 20 KiB |
BIN
questhelper/map/static/map/noun_Art_3410337.png
Normal file
|
After Width: | Height: | Size: 29 KiB |
BIN
questhelper/map/static/map/noun_Art_3410337_cropped.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
questhelper/map/static/map/noun_Carving Tools_693475.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
questhelper/map/static/map/noun_Carving Tools_693475_cropped.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
questhelper/map/static/map/noun_Crown_1936588.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
questhelper/map/static/map/noun_Crown_1936588_cropped.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
questhelper/map/static/map/noun_Diamond_3820185.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
questhelper/map/static/map/noun_Diamond_3820185_cropped.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
questhelper/map/static/map/noun_Ink_2509717.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
questhelper/map/static/map/noun_Ink_2509717_cropped.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
questhelper/map/static/map/noun_coin_48892.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
questhelper/map/static/map/noun_coin_48892_cropped.png
Normal file
|
After Width: | Height: | Size: 32 KiB |
BIN
questhelper/map/static/map/noun_deed_3309438.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
questhelper/map/static/map/noun_deed_3309438_cropped.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
questhelper/map/static/map/noun_life_3553107.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
questhelper/map/static/map/noun_life_3553107_cropped.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
questhelper/map/static/map/noun_potion_34882.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
questhelper/map/static/map/noun_potion_34882_cropped.png
Normal file
|
After Width: | Height: | Size: 27 KiB |
|
|
@ -11,6 +11,19 @@
|
||||||
style="position: absolute; left: {{e.x}}; top: {{e.y}};"
|
style="position: absolute; left: {{e.x}}; top: {{e.y}};"
|
||||||
width="{{e.w}}"
|
width="{{e.w}}"
|
||||||
height="{{e.h}}">
|
height="{{e.h}}">
|
||||||
|
{% if e.secondary %}
|
||||||
|
{% with s=e.secondary %}
|
||||||
|
<img src="{% static s.src %}"
|
||||||
|
alt="{{s.description}}"
|
||||||
|
title="{{s.description}}"
|
||||||
|
style="position: absolute; left: {{s.x}}; top: {{s.y}};"
|
||||||
|
width="{{s.w}}"
|
||||||
|
height="{{s.h}}">
|
||||||
|
<div style="position: absolute; left: {{s.text_x}}; top: {{s.text_y}};">
|
||||||
|
{{s.text}}
|
||||||
|
</div>
|
||||||
|
{% endwith %}
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% for e in map.paths %}
|
{% for e in map.paths %}
|
||||||
<img src="{% static e.src %}"
|
<img src="{% static e.src %}"
|
||||||
|
|
|
||||||