TableTower/core/sample_board.gd

111 lines
8 KiB
GDScript3
Raw Normal View History

class_name SampleBoard
extends RefCounted
## The example board: road encounters, loot chains, a d100 ranged travel table
## and a d100 table of 100 unique trinkets.
const TRINKETS := [
"A brass key that's warm to the touch", "A glass eye that follows movement", "A tin whistle only dogs can hear", "A pressed flower that never wilts",
"A tiny portrait of a stranger", "A compass that points to the nearest well", "A wooden die with seven sides", "A silver spoon bent into a ring",
"A sealed letter addressed to you", "A bell with no clapper that still rings", "A jar of buttons from a hundred coats", "A dragon scale the size of a coin",
"A candle that burns cold", "A deck of cards missing every queen", "A bird skull painted gold", "A map of a city that doesn't exist",
"A thimble of sand that never spills", "A ribbon embroidered with your name", "A clockwork beetle that wants winding", "A pebble that is always wet",
"A fishhook carved from bone", "A coin from a kingdom that fell", "A lock of silver hair tied with string", "A broken hourglass, sand still falling",
"A soup recipe written in blood", "A doll with one button eye", "A chess piece shaped like a crow", "A vial of fog",
"A tooth with a tiny keyhole", "A feather that falls upward", "An empty locket that hums", "A spool of thread that never runs out",
"A ring too small for any finger", "A wax seal of a three-eyed owl", "A shell that whispers in a strange tongue", "A rusted crown sized for a cat",
"A knot no blade can cut", "A page torn from a spellbook", "A marble with a storm inside", "A tiny saddle for a mouse",
"A mirror shard that shows yesterday", "A reed flute that plays by itself", "A holed stone that shows stars at noon", "A child's drawing of you",
"A spice tin of dried fireflies", "A wooden sword notched for every win", "A pair of dice that always roll the same", "An acorn that grows back each night",
"A tarnished medal for bravery", "A bottle with a ship of bones inside", "A glove that's always warm", "A bookmark from a library that burned",
"A walnut that rattles", "A copper ring stamped with a moon", "A lantern wick that relights itself", "A painted egg that is far too heavy",
"A bag of salt from a distant sea", "A wanted poster with no face", "A spinning top that never falls", "A snuff box full of teeth",
"A crystal that glows near goblins", "A riddle carved into a spoon handle", "A scarf that smells of summer rain", "A key with no teeth",
"A thumb-sized statue of a sleeping god", "A bone flute with one hole", "An inkwell that refills with black water", "A quill that writes only in red",
"A pocket watch running backwards", "A wedding ring with both names scratched out", "An eggshell painted with a map", "A pouch of mismatched dice",
"A tinderbox that sparks blue", "A prayer bead from an unknown faith", "A playing card with your face on it", "A cracked monocle",
"A tiny cage with the door open", "A pressed four-leaf clover", "A seashell found far inland", "A gold tooth",
"A badge from the city watch", "A charm bracelet with one charm missing", "A bundle of letters tied with twine", "A chip of a giant's fingernail",
"A rope that ties itself", "A stone that floats", "A song trapped in a bottle", "A carved wooden fish",
"A toy soldier missing an arm", "A coin that always lands on its edge", "A candle stub that smells of home", "A brooch shaped like a spider",
"A sliver of moonlight in a vial", "An arrowhead made of glass", "A dried rose from a grave", "A bone die marked with runes",
"A tiny shield with an unknown crest", "A horseshoe for a six-legged horse", "A note: “Don't trust the innkeeper”", "An egg that is warm and ticking",
]
static func create() -> TowerBoard:
var trinket_rows: Array = []
for s in TRINKETS:
trinket_rows.append([s])
# [id, name, position, entries: [text, pipes?, range?, {details?, weight?}?], options?]
# options: dice, collapsed, details, tags, card_mode
var spec: Array = [
["wilderness", "Wilderness Travel", Vector2(40, 180), [
["Travelers on the road", ["road"], [1, 30], {"details": "Most days the road is just the road. Roll on the Road Encounter table to see who is on it."}],
["Beasts on the hunt", ["monsters"], [31, 50]],
["A peddler's cart", ["wares"], [51, 65]],
["Something glints in the grass", ["loot"], [66, 80]],
["A stranger at the campfire", ["names"], [81, 95]],
["An odd find", ["trinkets"], [96, 100]],
], {"dice": "1d100", "details": "Roll once per [b]travel day[/b]. Each result sends you to a table for the details of what the party meets.", "tags": ["travel"]}],
["road", "Road Encounter", Vector2(390, 40), [
["Bandits ambush the party", ["loot"]], ["A merchant caravan", ["wares"]],
["Something big in the trees", ["monsters"]], ["A quiet stretch of road"],
["A sudden storm rolls in"], ["A lost traveler", ["names"]],
]],
["trinkets", "Curious Trinkets", Vector2(390, 420), trinket_rows, {"collapsed": true}],
["monsters", "Monsters", Vector2(740, 20), [
["Owlbear", ["loot"], null, {"details": "[b]Owlbear[/b]: AC 13, 59 HP. Multiattack: beak and claws. Grabs and crushes anything that comes close to its nest."}],
["Giant spider"],
["Troll", ["loot"], null, {"details": "[b]Troll[/b]: AC 15, 84 HP. Regenerates 10 HP each turn unless hit by [i]fire[/i] or [i]acid[/i]."}],
["Wyvern"],
], {"tags": ["combat"]}],
["wares", "Merchant Wares", Vector2(740, 300), [["Bolts of silk"], ["Rare spices"], ["Lamp oil"], ["A crate of strange eggs"]]],
["loot", "Loot", Vector2(1090, 60), [
["A pouch of gold", [], null, {"weight": 3}], ["A weapon", ["weapons"]], ["A healing potion"],
["A torn map"], ["A gemstone"], ["Nothing but lint"],
], {"tags": ["treasure"]}],
["names", "Traveler Names", Vector2(1090, 400), [["Aldric"], ["Brenna"], ["Corvin"], ["Dagny"], ["Elowen"], ["Fenn"]]],
["weapons", "Weapons", Vector2(1440, 60), [["Dagger"], ["Sword", ["quality"]], ["Hand axe"], ["Shortbow"]]],
["quality", "Sword Quality", Vector2(1790, 130), [["Rusty"], ["Notched"], ["Fine"], ["Elven-forged"]]],
["party_roles", "Party Roles", Vector2(1440, 330), [
["Scout"], ["Map keeper"], ["Quartermaster"], ["Lookout"], ["Cook"], ["Diplomat"],
], {"card_mode": true, "details": "Hand out one role per player. Each role is dealt once until everyone has had one, then the deck is reshuffled."}],
["weather", "Weather", Vector2(1790, 380), [
["Storm", [], [2, 3]], ["Rain", [], [4, 5]], ["Overcast", [], [6, 8]],
["Clear skies", [], [9, 10]], ["Heat wave", [], [11, 12]],
], {"dice": "2d6", "details": "Roll [b]2d6[/b]. Middling weather is the most common."}],
# Shows inline [[references]], a chain variable and a persistent {@town}.
["quest_hooks", "Quest Hooks", Vector2(40, 560), [
["[[Traveler Names -> patron]] begs you to recover [[Loot]] from the ruins near {@town|Towns}. {patron} pays well."],
["The mayor of {@town|Towns} posts a bounty: [i]bring back [[Monsters]] alive[/i]."],
["[[Traveler Names]] swears the [[Curious Trinkets]] they found is cursed."],
], {"details": "Opening hooks for a session. [b]{@town}[/b] is the party's current town; it's rolled once, then reused until you clear it."}],
["towns", "Towns", Vector2(740, 560), [["Millbrook"], ["Saltmere"], ["Grey Harrow"], ["Kettle Ford"]]],
]
var board := TowerBoard.new()
for s in spec:
var t := RollTable.new(s[0], s[1])
t.position = s[2]
var opts: Dictionary = s[4] if s.size() > 4 else {}
t.dice = str(opts.get("dice", RollTable.DEFAULT_DICE))
t.collapsed = bool(opts.get("collapsed", false))
t.details = str(opts.get("details", ""))
for tag in opts.get("tags", []):
t.tags.append(tag)
t.card_mode = bool(opts.get("card_mode", false))
for row in s[3]:
var e := TableEntry.new(TowerBoard.new_id("e"), row[0])
if row.size() > 1:
for p in row[1]:
e.add_pipe(p)
if row.size() > 2 and row[2] != null:
e.has_range = true
e.range_lo = row[2][0]
e.range_hi = row[2][1]
if row.size() > 3:
e.details = str(row[3].get("details", ""))
e.weight = int(row[3].get("weight", 1))
t.entries.append(e)
board.tables.append(t)
return board