Town deck
This commit is contained in:
parent
51123c10bc
commit
a7387da9fc
1 changed files with 24 additions and 10 deletions
|
|
@ -2,20 +2,33 @@ import random
|
|||
from typing import List
|
||||
|
||||
import map.quest_map
|
||||
from map.quest_map import QuestMap, MapEncounter, EncounterType, QuestPath as QP
|
||||
from map.quest_map import QuestMap, MapEncounter, EncounterType as ET, QuestPath as QP
|
||||
|
||||
|
||||
TOWN_DECK = (
|
||||
[ET.TOWN_MARKET] * 2
|
||||
+ [ET.TOWN_TAVERN] * 3
|
||||
+ [ET.TOWN_DOCKS] * 2
|
||||
+ [ET.TOWN_LIBRARY] * 5
|
||||
+ [ET.TOWN_WORKSHOP] * 2
|
||||
+ [ET.TOWN_TOWN_HALL] * 2
|
||||
+ [ET.TOWN_TEMPLE] * 2
|
||||
+ [ET.TOWN_REST] * 2
|
||||
+ [ET.TOWN_ROAD] * 7)
|
||||
DIAGONALS_DECK = [QP.NO_PATH] * 8 + [QP.FORWARD_LEFT] * 5 + [QP.FORWARD_RIGHT] * 5
|
||||
|
||||
|
||||
def generate_encounter_inaccessible() -> MapEncounter:
|
||||
return MapEncounter(EncounterType.INACCESSIBLE)
|
||||
return MapEncounter(ET.INACCESSIBLE)
|
||||
|
||||
|
||||
def generate_encounter_battle(battle_type: EncounterType):
|
||||
def generate_encounter_battle(battle_type: ET):
|
||||
assert battle_type in map.quest_map.ENCOUNTER_TYPES_BATTLE
|
||||
return MapEncounter(battle_type)
|
||||
|
||||
|
||||
def generate_encounter_town():
|
||||
town_type = random.choice(map.quest_map.ENCOUNTER_TYPES_TOWN)
|
||||
def generate_encounter_town(town_type: ET):
|
||||
assert town_type in map.quest_map.ENCOUNTER_TYPES_TOWN
|
||||
return MapEncounter(town_type)
|
||||
|
||||
|
||||
|
|
@ -26,27 +39,28 @@ def generate_map() -> QuestMap:
|
|||
|
||||
# TODO: Use sample as if drawing from a deck
|
||||
encounters_rows = []
|
||||
town_deck_it = iter(random.sample(TOWN_DECK, len(TOWN_DECK)))
|
||||
for r in range(11):
|
||||
row: List[MapEncounter] = []
|
||||
if r == 10:
|
||||
row.append(generate_encounter_inaccessible())
|
||||
row.append(generate_encounter_battle(EncounterType.BATTLE_BOSS))
|
||||
row.append(generate_encounter_battle(ET.BATTLE_BOSS))
|
||||
row.append(generate_encounter_inaccessible())
|
||||
elif r in (1, 4, 7):
|
||||
elite_column = random.randrange(4) # 75% chance of elite
|
||||
for c in range(3):
|
||||
battle_type = EncounterType.BATTLE_ELITE if c == elite_column else EncounterType.BATTLE_REGULAR
|
||||
battle_type = ET.BATTLE_ELITE if c == elite_column else ET.BATTLE_REGULAR
|
||||
row.append(generate_encounter_battle(battle_type))
|
||||
else:
|
||||
for c in range(3):
|
||||
row.append(generate_encounter_town())
|
||||
town_type = next(town_deck_it)
|
||||
row.append(generate_encounter_town(town_type))
|
||||
encounters_rows.append(row)
|
||||
|
||||
quest_map.encounters = encounters_rows
|
||||
|
||||
# Generate paths
|
||||
diagonals_deck = [QP.NO_PATH] * 8 + [QP.FORWARD_LEFT] * 5 + [QP.FORWARD_RIGHT] * 5
|
||||
random_paths_it = iter(random.sample(diagonals_deck, len(diagonals_deck)))
|
||||
random_paths_it = iter(random.sample(DIAGONALS_DECK, len(DIAGONALS_DECK)))
|
||||
path_rows = []
|
||||
for r in range(11 - 1):
|
||||
row: List[QP]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue