{
 "id": "midnight-letter",
 "title": "The Midnight Letter",
 "kind": "branch-and-bottleneck",
 "note": "Written for this site as a structural demonstration (12 passages, two state variables). Not based on any published work.",
 "start": "dock",
 "vars": {"lantern": false, "friend": false},
 "var_labels": {"lantern": "Lantern", "friend": "Fisherman's boy"},
 "nodes": {
  "dock": {"n": 1, "label": "Dock Street",
   "text": "A sealed letter must reach the clock tower across the river by midnight. The bridge is out.",
   "choices": [
    {"label": "Cut through the market", "to": "market"},
    {"label": "Take the river path", "to": "river"}]},
  "market": {"n": 2, "label": "Market",
   "text": "The stalls are closing. One lantern still hangs on a hook.",
   "choices": [
    {"label": "Buy the lantern", "to": "stall", "set": {"lantern": true}},
    {"label": "Keep your coins and hurry on", "to": "landing"}]},
  "stall": {"n": 3, "label": "Lantern stall",
   "text": "The stallholder lights the wick for you. The glass is warm in your hand.",
   "choices": [
    {"label": "Go down to the water", "to": "landing"}]},
  "river": {"n": 4, "label": "River path",
   "text": "On the river path, a fisherman is fighting a torn net.",
   "choices": [
    {"label": "Help him mend it", "to": "reeds", "set": {"friend": true}},
    {"label": "Hurry past", "to": "landing"}]},
  "reeds": {"n": 5, "label": "Reed path",
   "text": "He thanks you and shows you a path through the reeds. His boy runs ahead to show the way.",
   "choices": [
    {"label": "Follow the boy", "to": "landing"}]},
  "landing": {"n": 6, "label": "Ferry landing",
   "text": "Every way down ends at the ferry landing.",
   "variants": [
    {"if": {"lantern": true}, "text": "Your lantern shows the bell post and a rowing boat tied below it."},
    {"if": {"friend": true}, "text": "The fisherman's boy is already here, holding a rowing boat by its rope."},
    {"text": "It is too dark to see much: a bell post, and a shape that might be a boat."}],
   "choices": [
    {"label": "Ring for the ferry", "to": "ferry"},
    {"label": "Take the rowing boat", "to": "rowboat"}]},
  "ferry": {"n": 7, "label": "Ferry",
   "text": "The ferry crawls out into the fog. A passenger offers you a seat inside.",
   "choices": [
    {"label": "Stay on deck", "to": "farbank"},
    {"label": "Sit inside", "to": "farbank"}]},
  "rowboat": {"n": 8, "label": "Rowing boat",
   "text": "The current is strong. The far bank slides past.",
   "choices": [
    {"label": "Row hard for the steps", "to": "farbank"},
    {"label": "Let the current carry you", "to": "mill"}]},
  "mill": {"n": 9, "label": "Old mill", "end": true,
   "endings": [
    {"id": "E5", "title": "Too far downstream", "fail": true,
     "text": "You come ashore at the old mill, far downstream. Across the water, the tower clock strikes twelve."}]},
  "farbank": {"n": 10, "label": "Far bank",
   "text": "The far bank.",
   "variants": [
    {"if": {"friend": true}, "text": "The boy points to the steep lane. \"Shortest way,\" he says."},
    {"if": {"lantern": true}, "text": "Your lantern shows two ways up: a steep lane and the river stairs."},
    {"text": "Two ways lead up in the dark: a lane and some stairs."}],
   "choices": [
    {"label": "Climb the steep lane", "to": "tower"},
    {"label": "Take the river stairs", "to": "stairs"}]},
  "tower": {"n": 11, "label": "Clock tower", "end": true,
   "endings": [
    {"if": {"friend": true}, "id": "E1", "title": "On time, with help",
     "text": "The boy has run ahead and woken the porter. The gate is open when you arrive."},
    {"if": {"lantern": true}, "id": "E2", "title": "On time",
     "text": "By lantern light you find the right door and hand over the letter as the clock strikes."},
    {"id": "E3", "title": "At the last stroke",
     "text": "The gate is locked. You slide the letter under it as midnight strikes."}]},
  "stairs": {"n": 12, "label": "River stairs", "end": true,
   "endings": [
    {"id": "E4", "title": "Wrong tower", "fail": true,
     "text": "The stairs climb to the old tower, closed for years. Midnight strikes from the other hill."}]}
 }
}
