Generate treasure hoards
This commit is contained in:
parent
541991d404
commit
97782ab212
7 changed files with 132 additions and 9 deletions
65
questhelper/map/treasure_hoard_generator.py
Normal file
65
questhelper/map/treasure_hoard_generator.py
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
import random
|
||||
from typing import List, Tuple
|
||||
|
||||
from map.quest_map import EncounterType
|
||||
from map.treasure_hoard import TreasureHoard, Treasure, TreasureType as TT
|
||||
|
||||
|
||||
class HoardTable:
|
||||
def __init__(self, input: List[Tuple[int, int, TT]]):
|
||||
self.input = input
|
||||
|
||||
def roll(self) -> Treasure:
|
||||
dice_total = random.randint(1, 6) + random.randint(1, 6)
|
||||
for top_of_band, amount, treasure_type in self.input:
|
||||
if dice_total <= top_of_band:
|
||||
return Treasure(amount, treasure_type)
|
||||
|
||||
|
||||
_TABLES = {
|
||||
1: {
|
||||
EncounterType.BATTLE_REGULAR: HoardTable([
|
||||
(2, 200, TT.GOLD),
|
||||
(4, 2, TT.COG),
|
||||
(5, 1, TT.CONSUMABLE),
|
||||
(6, 1, TT.DEED),
|
||||
(8, 50, TT.GOLD),
|
||||
(9, 1, TT.GEMS),
|
||||
(11, 1, TT.ART_OBJECT),
|
||||
(12, 1, TT.LIFE),
|
||||
]),
|
||||
EncounterType.BATTLE_ELITE: HoardTable([
|
||||
(2, 300, TT.GOLD),
|
||||
(4, 4, TT.COG),
|
||||
(5, 2, TT.CONSUMABLE),
|
||||
(6, 2, TT.DEED),
|
||||
(8, 100, TT.GOLD),
|
||||
(9, 2, TT.GEMS),
|
||||
(10, 2, TT.ART_OBJECT),
|
||||
(11, 1, TT.NOBILITY_TITLE),
|
||||
(12, 1, TT.LIFE),
|
||||
]),
|
||||
EncounterType.BATTLE_BOSS: HoardTable([
|
||||
(2, 400, TT.GOLD),
|
||||
(4, 6, TT.COG),
|
||||
(5, 3, TT.CONSUMABLE),
|
||||
(6, 3, TT.DEED),
|
||||
(8, 150, TT.GOLD),
|
||||
(9, 3, TT.GEMS),
|
||||
(11, 1, TT.NOBILITY_TITLE),
|
||||
(12, 1, TT.RELIC),
|
||||
]),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def generate_hoard(battle_type: EncounterType, level: int):
|
||||
return TreasureHoard(_roll_treasure(battle_type, level))
|
||||
|
||||
|
||||
def _roll_treasure(battle_type: EncounterType, level: int):
|
||||
# TODO: Handle more quest levels
|
||||
assert level == 1
|
||||
|
||||
table: HoardTable = _TABLES[level][battle_type]
|
||||
return table.roll()
|
||||
Loading…
Add table
Add a link
Reference in a new issue