use crate::game::*; pub fn talk(t: Talk, node: &str, g: &Game) -> Dialog { match t { Talk::Npc(n) => npc(n, node, g), Talk::Obj(o) => obj(o, g), Talk::Ev(e) => ev(e, node, g), Talk::Camp => camp(g), } } fn hi(g: &Game, n: Npc, a: &'static str, b: &'static str, c: &'static str) -> &'static str { match g.heart(n) { 0 => a, 1 | 2 => b, _ => c, } } fn eat(g: &mut Game) { if g.pay(1) { g.hunger = (g.hunger + 45.0).min(100.0); g.request = Some(Req::Wait { minutes: 30.0 }); } } fn bed(g: &mut Game) { if g.pay(2) { g.request = Some(Req::Sleep { until: 7.0 * 60.0, camp: false }); } } fn sleep_home(g: &mut Game) { g.request = Some(Req::Sleep { until: 7.0 * 60.0, camp: false }); } fn buy_ration(g: &mut Game) { g.buy(Item::Ration, 1); } fn buy_wood(g: &mut Game) { g.buy(Item::Firewood, 1); } fn buy_tobacco(g: &mut Game) { g.buy(Item::Tobacco, 1); } fn buy_whistle(g: &mut Game) { g.buy(Item::TinWhistle, 1); } fn buy_ribbon(g: &mut Game) { g.buy(Item::Ribbon, 2); } fn buy_book(g: &mut Game) { g.buy(Item::PoetryBook, 6); } fn give_bread(g: &mut Game) { g.take(Item::Ration); } fn npc(n: Npc, node: &str, g: &Game) -> Dialog { match n { Npc::Hale => hale(node, g), Npc::Pike => pike(node, g), Npc::Bess => bess(node, g), Npc::Edwin => edwin(node, g), Npc::OldTom => tom(node, g), Npc::Annie => sam(node, g), Npc::Foreman => foreman(node, g), Npc::Quill => quill(node, g), Npc::Weaver => weaver(node), Npc::Peddler => market(g), Npc::Miner => miner(node, g), Npc::Jack => jack(node, g), Npc::Pawn => pawn(node, g), } } fn hale(node: &str, g: &Game) -> Dialog { let n = Npc::Hale; match node { "parcel" => { if g.flag("job_parcel") || g.flag("delivered_parcel") { Dialog::new(n.name(), "The Millbrook parcel is in your hands. Mind it.").bye("Leave") } else { Dialog::new(n.name(), "A parcel for the Millbrook mill foreman. Five shillings on delivery.") .act("Take the parcel", None, |g| { g.give(Item::Parcel); g.set("job_parcel"); }) .bye("Not today") } } "letter" => { if g.flag("job_letter") { Dialog::new(n.name(), "Straight to the pawnbroker in Coalbridge, and back before dark.").bye("Leave") } else if g.flag("delivered_letter") { Dialog::new(n.name(), "The pawnbroker paid fair, I'll say that for him.").bye("Leave") } else { Dialog::new(n.name(), "A sealed letter for the Coalbridge pawnbroker. Eight shillings on delivery.") .act("Take the letter", None, |g| { g.give(Item::Letter); g.set("job_letter"); }) .bye("Not today") } } "roads" => Dialog::new( n.name(), "Surveyors have pegged a line over the moor all summer. Railway, they say. The coaching trade is finished.", ) .go("Back", "start") .bye("Leave"), _ => hale_start(g), } } fn hale_start(g: &Game) -> Dialog { let n = Npc::Hale; if g.flag("delivered_parcel") && !g.flag("hale_thanked") { return Dialog::new(n.name(), "The foreman's receipt came back. You did well by the parcel.").act( "Thank you, sir", Some("letter"), |g| { g.bond(Npc::Hale, 1); g.set("hale_thanked"); }, ); } let text = hi( g, n, "Morning. The post comes in on the early coach, if the rain lets it.", "Ah, it's you. Mind the loose step.", "Good to see you, friend. Sit a minute, the kettle's on.", ); let mut d = Dialog::new(n.name(), text); if !g.flag("job_parcel") && !g.flag("delivered_parcel") { d = d.go("Any work going?", "parcel"); } if (g.flag("job_parcel") || g.flag("delivered_parcel")) && !g.flag("job_letter") && !g.flag("delivered_letter") { d = d.go("Any more work?", "letter"); } d.go("Talk about the roads", "roads").bye("Leave") } fn pike(node: &str, g: &Game) -> Dialog { let n = Npc::Pike; match node { "shop" => { let mut d = Dialog::new(n.name(), "Prices are up since the mills. Never sleep cold on the moor road. Take wood."); if g.money >= 1 { d = d.act("Ration (1s)", Some("shop"), buy_ration); d = d.act("Firewood (1s)", Some("shop"), buy_wood); } if !g.has(Item::Bedroll) && g.money >= 3 { d = d.act("Bedroll (3s)", Some("shop"), |g| { g.buy(Item::Bedroll, 3); }); } if !g.has(Item::Lantern) && g.money >= 2 { d = d.act("Lantern (2s)", Some("shop"), |g| { g.buy(Item::Lantern, 2); }); } d.bye("Leave") } _ => Dialog::new( n.name(), hi( g, n, "Good day. Mind the sugar tins on the sill.", "Morning. Need anything for the road?", "Back again? Let me sort you out proper.", ), ) .go("Show me your goods", "shop") .bye("Leave"), } } fn bess(node: &str, g: &Game) -> Dialog { let n = Npc::Bess; match node { "gossip" => Dialog::new( n.name(), "The ironworks took on two hundred men in spring. Half of them left wives on the moor road. Mind yourself out there.", ) .bye("Leave"), "wants" => Dialog::new( n.name(), "A silk ribbon for chapel on Sunday. They sell them in Millbrook, the peddler there has a tray.", ) .bye("Leave"), "ribbon_thanks" => Dialog::new(n.name(), "Oh, look at that. I'll wear it to chapel on Sunday.").bye("Leave"), _ => { let mut d = Dialog::new( n.name(), hi( g, n, "Hot meal and a fire, if you've the coin.", "Mind the step. Soup's on.", "Sit by the fire, love. You look done in.", ), ); if g.money >= 1 { d = d.act("Hot meal (1s)", None, eat); } if g.has(Item::Ribbon) && !g.flag("gave_ribbon") { d = d.act("Give her the silk ribbon", Some("ribbon_thanks"), |g| { g.take(Item::Ribbon); g.bond(Npc::Bess, 2); g.set("gave_ribbon"); }); } if !g.has(Item::Ribbon) && !g.flag("gave_ribbon") { d = d.go("Do you need anything?", "wants"); } d.go("Any news?", "gossip").bye("Leave") } } } fn edwin(node: &str, g: &Game) -> Dialog { let n = Npc::Edwin; match node { "wants" => Dialog::new(n.name(), "I'd give a week's wages for Songs of the Moor. Nobody in Ashford stocks it.") .bye("Leave"), "thanks" => Dialog::new(n.name(), "Songs of the Moor. Thank you. I'll read it by the stove tonight.").bye("Leave"), "verse" => Dialog::new( n.name(), "The chimneys bloom with smoke by day, the larks have long since fled; but the beck still runs its quiet way beneath the moor's grey bed.", ) .bye("Leave"), _ => { let mut d = Dialog::new( n.name(), hi( g, n, "Sit down, the slate's still warm. Don't mind the boys.", "Ah. Did you bring the post?", "You're a welcome sight. Sit by the stove.", ), ); if g.has(Item::PoetryBook) && !g.flag("gave_book") { d = d.act("Give him Songs of the Moor", Some("thanks"), |g| { g.take(Item::PoetryBook); g.bond(Npc::Edwin, 2); g.set("gave_book"); }); } if g.flag("gave_book") { d = d.go("Recite something", "verse"); } else { d = d.go("What do you want?", "wants"); } d.bye("Leave") } } } fn tom(node: &str, g: &Game) -> Dialog { let n = Npc::OldTom; match node { "jack" => Dialog::new( n.name(), "My Jack went to the Coalbridge ironworks a year gone. Not a line since. Would you look in on him?", ) .act("I'll look for him", Some("jack_yes"), |g| g.set("quest_jack")), "jack_yes" => Dialog::new(n.name(), "Thank you. Tell him his father's chest is bad, but his bed's still made.") .bye("Leave"), "letter_read" => Dialog::new( n.name(), "He can't read, so you read it aloud. 'Dear Father, the works are hard and the wage is steady. I think of the moor every night. Your son, Jack.' He says nothing for a long while, then nods. 'Aye. That's him.'", ) .bye("Leave"), "tobacco" => Dialog::new(n.name(), "He packs the pipe with shaking hands. 'That's a kindness, lad.'").bye("Leave"), _ => { let mut d = Dialog::new( n.name(), hi( g, n, "*Coughs into his sleeve.* Mind the dust, lad.", "Morning. The chest is bad today.", "Sit down, lad. Good to see a friendly face.", ), ); if !g.flag("quest_jack") && !g.flag("jack_done") { d = d.go("Anything I can do?", "jack"); } if g.flag("quest_jack") && g.has(Item::JacksLetter) && !g.flag("jack_done") { d = d.act("Give him the letter", Some("letter_read"), |g| { g.take(Item::JacksLetter); g.bond(Npc::OldTom, 3); g.set("jack_done"); }); } if g.has(Item::Tobacco) { d = d.act("Give him pipe tobacco", Some("tobacco"), |g| { g.take(Item::Tobacco); g.bond(Npc::OldTom, 1); }); } d.bye("Leave") } } } fn sam(node: &str, g: &Game) -> Dialog { let n = Npc::Annie; match node { "wants" => Dialog::new(n.name(), "A tin whistle. The peddler in Millbrook has them for a shilling.").bye("Leave"), "whistle_play" => Dialog::new( n.name(), "He blows three wobbly notes, then a whole tune. The kitchen goes quiet to listen.", ) .bye("Leave"), _ => { let mut d = Dialog::new( n.name(), hi( g, n, "He stares at your boots and says nothing.", "He grins and hides behind the table leg.", "He shows you his scraped knee, proudly.", ), ); if g.has(Item::TinWhistle) { d = d.act("Give him the tin whistle", Some("whistle_play"), |g| { g.take(Item::TinWhistle); g.bond(Npc::Annie, 2); g.set("gave_whistle"); }); } else if g.flag("gave_whistle") { d = d.go("Ask for a tune", "whistle_play"); } else { d = d.go("What do you want?", "wants"); } d.bye("Leave") } } } fn foreman(node: &str, g: &Game) -> Dialog { let n = Npc::Foreman; match node { "bales" => Dialog::new( n.name(), "Two bales from the pile to the mill door. Three shillings. They weigh more than they look.", ) .act("Take the job", None, |g| g.set("job_bales")) .bye("Not today"), "parcel_done" => Dialog::new(n.name(), "Good. Tell Hale the mill is still standing.").bye("Leave"), "bales_paid" => Dialog::new(n.name(), "Three shillings. Don't spend it all at the Arms.").bye("Leave"), "children" => Dialog::new( n.name(), "Eight and nine year olds on the lower frames, under the belts. Their fingers are quick. That's all the mill wants of them.", ) .bye("Leave"), _ => { let mut text = String::from("The frames don't stop. Fourteen hours, six days."); if g.flag("job_bales") && g.counter("bales") < 2 { text += &format!(" {} bales still to carry.", 2 - g.counter("bales")); } let mut d = Dialog::new(n.name(), text); if g.has(Item::Parcel) && g.flag("job_parcel") { d = d.act("Deliver the Millbrook parcel", Some("parcel_done"), |g| { g.take(Item::Parcel); g.earn(5); g.set("delivered_parcel"); g.unset("job_parcel"); }); } if g.flag("job_bales") && g.counter("bales") >= 2 { d = d.act("Collect your pay", Some("bales_paid"), |g| { g.earn(3); g.unset("job_bales"); g.set("bales_done"); }); } else if !g.flag("job_bales") && !g.flag("bales_done") { d = d.go("Any extra work?", "bales"); } d.go("What about the children?", "children").bye("Leave") } } } fn quill(node: &str, g: &Game) -> Dialog { let n = Npc::Quill; match node { "news" => Dialog::new( n.name(), "Penny papers and Chartist pamphlets, under the counter. The Chartists want the vote and a fair wage. The magistrate wants them quiet. I sell both and read neither.", ) .bye("Leave"), _ => { let mut d = Dialog::new( n.name(), hi( g, n, "Come in out of the damp. Mind the stacks.", "Ah, a customer. Anything in particular?", "The usual, is it? Shall I put it aside?", ), ); if !g.has(Item::PoetryBook) && !g.flag("gave_book") && g.money >= 6 { d = d.act("Songs of the Moor (6s)", None, buy_book); } d.go("Any news?", "news").bye("Leave") } } } fn weaver(node: &str) -> Dialog { let n = Npc::Weaver; match node { "loom" => Dialog::new( n.name(), "The power looms came in. Cloth at a penny the yard, that I'd never weave for less than sixpence. The mill took my trade and gave me a shed to stand in.", ) .go("And now?", "last"), "last" => Dialog::new(n.name(), "Mind the shuttle on the sill. It's all I kept of my trade.").bye("Leave"), _ => Dialog::new(n.name(), "I had four looms and a bench of my own, once.") .go("What happened?", "loom") .bye("Leave"), } } fn market(g: &Game) -> Dialog { let mut d = Dialog::new(Npc::Peddler.name(), "Whistles, ribbons, bread. Prices are up since the mill opened."); if !g.has(Item::TinWhistle) && g.money >= 1 { d = d.act("Tin Whistle (1s)", Some("start"), buy_whistle); } if !g.has(Item::Ribbon) && g.money >= 2 { d = d.act("Silk Ribbon (2s)", Some("start"), buy_ribbon); } if g.money >= 1 { d = d.act("Ration (1s)", Some("start"), buy_ration); d = d.act("Firewood (1s)", Some("start"), buy_wood); } d.bye("Leave") } fn miner(node: &str, g: &Game) -> Dialog { let n = Npc::Miner; match node { "pit" => Dialog::new( n.name(), "Two hundred feet down. Water to the knees, and gas that takes the lamp if you're careless. My father went down at nine. I went at eight.", ) .bye("Leave"), "notice" => Dialog::new( n.name(), "The notice says the company will not answer for accidents below ground. He nods, as if he'd known it.", ) .bye("Thank you"), _ => { let mut d = Dialog::new(n.name(), "Coal dust in the lines of his face, an unlit lamp at his belt.") .go("Tell me about the pit", "pit"); if !g.flag("read_notice") { d = d.act("Read him the posted notice (earn 1s)", Some("notice"), |g| { g.earn(1); g.set("read_notice"); g.request = Some(Req::Wait { minutes: 15.0 }); }); } d.bye("Leave") } } } fn jack(node: &str, g: &Game) -> Dialog { let n = Npc::Jack; match node { "ashamed" => Dialog::new( n.name(), "I can't write. Never learned, and I was too proud to say so. A year gone and not a word.", ) .bye("Leave"), "letter" => Dialog::new( n.name(), "He turns his cap in his hands. 'Put it down for me. Tell him I'm well.' You write it on the back of a receipt.", ) .act("Write it for him", Some("letter_done"), |g| { g.request = Some(Req::Wait { minutes: 60.0 }); g.give(Item::JacksLetter); g.set("jack_letter"); }), "letter_done" => Dialog::new( n.name(), "He folds it twice and hands it over. 'Tell him I'm sorry. Don't tell him how I look.'", ) .bye("Leave"), _ => { let text = if g.flag("jack_letter") { "He nods, and says no more." } else { "A wary man in a soot-grey coat. 'What's it to you?'" }; let mut d = Dialog::new(n.name(), text); if !g.flag("jack_letter") { d = d.go("Why haven't you written?", "ashamed").go("I can write a letter for you", "letter"); } d.bye("Leave") } } } fn pawn(node: &str, g: &Game) -> Dialog { let n = Npc::Pawn; match node { "letter_done" => Dialog::new(n.name(), "He reads it through once and counts eight shillings onto the counter.") .bye("Leave"), "rings" => Dialog::new( n.name(), "Wedding rings every Monday, back every Saturday when the wages come. Some come back twice. I don't ask.", ) .bye("Leave"), _ => { let mut d = Dialog::new( n.name(), "Glass case, scales, a drawer of watches. The wedding rings sit at the front.", ); if g.has(Item::Letter) && g.flag("job_letter") { d = d.act("Deliver the sealed letter", Some("letter_done"), |g| { g.take(Item::Letter); g.earn(8); g.set("delivered_letter"); g.unset("job_letter"); }); } if g.money >= 1 { d = d.act("Pipe Tobacco (1s)", Some("start"), buy_tobacco); d = d.act("Ration (1s)", Some("start"), buy_ration); } d.go("Anything I should know?", "rings").bye("Leave") } } } fn obj(o: Obj, g: &Game) -> Dialog { match o { Obj::HomeBed => Dialog::new("", "Your cottage. The fire is banked low and the bed is still warm from the night.") .act("Sleep until morning", None, sleep_home) .bye("Leave"), Obj::BalePile => { if g.flag("job_bales") && !g.flag("carrying") && g.counter("bales") < 2 { Dialog::new("", "A bale of raw cotton, heavy and sour with oil.") .act("Heave a bale", None, |g| g.set("carrying")) .bye("Leave") } else { Dialog::new("", "A bale of raw cotton, heavy and sour with oil. The pile is taller than the men who stack it.") .bye("Leave") } } Obj::BaleDrop => { if g.flag("carrying") { let text = match g.counter("bales") { 0 => "The mill door, and the roar of the looms like weather. Your first bale goes down among the others.", _ => "The last bale. Your arms have stopped telling you how heavy they are.", }; Dialog::new("", text) .act("Drop the bale", None, |g| { g.unset("carrying"); g.add("bales", 1); g.request = Some(Req::Wait { minutes: 20.0 }); }) .bye("Leave") } else { Dialog::new("", "The mill door. The roar of the looms comes out like weather.").bye("Leave") } } Obj::Signpost => Dialog::new( "", "Ashford four miles. Millbrook two, the mill chimney in view. Coalbridge over the moor, where the smoke comes from.", ) .bye("Leave"), Obj::MillInn => inn("The Weavers' Arms", g), Obj::CoalInn => inn("The Miners' Rest", g), } } fn inn(name: &'static str, g: &Game) -> Dialog { let mut d = Dialog::new(name, "Smoke, beer and wet wool. A bed upstairs for two shillings."); if g.money >= 2 { d = d.act("Bed (2s)", None, bed); } if g.money >= 1 { d = d.act("Hot meal (1s)", None, eat); } d.bye("Leave") } fn ev(e: Ev, node: &str, g: &Game) -> Dialog { match e { Ev::BrokenCart => cart(node), Ev::Highwayman => highwayman(node, g), Ev::Storm => storm(), Ev::Peddler => tinker(node, g), Ev::Lost => lost(node, g), Ev::Wolves => wolves(g), } } fn cart(node: &str) -> Dialog { match node { "done" => Dialog::new("Carter", "He presses a ration into your hand. For the road.").bye("Leave"), _ => Dialog::new("Carter", "A carter kneels by a cart with a split wheel. His horse stands patient in the rain.") .act("Help him (1 hour)", Some("done"), |g| { g.request = Some(Req::Wait { minutes: 60.0 }); g.earn(1); g.give(Item::Ration); }) .bye("Can't stop"), } } fn highwayman(node: &str, g: &Game) -> Dialog { match node { "robbed" => Dialog::new("", "He takes the coins without a word and is gone into the dark.").bye("Leave"), "ran" => Dialog::new("", "You run. Your legs burn and the lamp swings, but nobody follows.").bye("Leave"), "bread" => Dialog::new( "Highwayman", "He lowers the pistol. 'Laid off from the looms in March. I'm not a thief, not really.'", ) .bye("Leave"), _ => { let mut d = Dialog::new("Highwayman", "A man steps out from the wall, a pistol held low. 'Your purse or your life.'") .act("Hand over your purse", Some("robbed"), |g| { let n = g.money.min(3); g.money -= n; g.toasts.push(format!("- {n}s")); g.sfx.push(Sfx::Coin); }) .act("Run for it", Some("ran"), |g| { g.energy = (g.energy - 25.0).max(0.0); g.warmth = (g.warmth - 10.0).max(0.0); }); if g.has(Item::Ration) { d = d.act("Offer him bread", Some("bread"), give_bread); } d } } } fn storm() -> Dialog { Dialog::new("", "Clouds come down over the moor, grey and fast. The first drops hit hard.") .act("Press on", None, |g| { g.raining = true; }) .act("Shelter under the trees (1 hour)", None, |g| { g.request = Some(Req::Wait { minutes: 60.0 }); }) } fn tinker(node: &str, g: &Game) -> Dialog { match node { "rail" => Dialog::new( "Tinker", "They'll lay rails over the moor by spring. He says it like a man reading a death notice.", ) .bye("Leave"), _ => { let mut d = Dialog::new("Tinker", "A tinker with a handcart and a tin tray. Bread, wood, and news."); if g.money >= 1 { d = d.act("Ration (1s)", Some("start"), buy_ration); d = d.act("Firewood (1s)", Some("start"), buy_wood); } d.go("Ask about the railway", "rail").bye("Walk on") } } } fn lost(node: &str, g: &Game) -> Dialog { match node { "done" => Dialog::new("Boy", "He eats it in three bites and runs off down the beck path.").bye("Leave"), "point" => Dialog::new( "Boy", "Follow the beck down, with the mill chimney on your left. You'll hear the looms before you see them.", ) .bye("Leave"), _ => { let mut d = Dialog::new( "Boy", "A boy in a coat too big for him, lost. 'Mill's on the wrong side of the beck, mister. Me mam said the road was straight.'", ); if g.has(Item::Ration) { d = d.act("Give him bread and point the way", Some("done"), give_bread); } d.go("Point the way", "point").bye("Walk on") } } } fn camp(g: &Game) -> Dialog { let mut text = String::from("A dry hollow off the road, out of the wind."); text += if g.has(Item::Firewood) { " Wood for a fire." } else { " No wood. It will be cold." }; text += if g.has(Item::Bedroll) { " A bedroll." } else { " Bare ground." }; Dialog::new("", text) .act("Make camp and sleep", None, |g| { g.request = Some(Req::Sleep { until: 7.0 * 60.0, camp: true }); }) .act("Rest an hour", None, |g| { g.request = Some(Req::Wait { minutes: 60.0 }); }) .bye("Not here") } fn wolves(g: &Game) -> Dialog { let mut d = Dialog::new("", "Yellow eyes in the dark. The pack circles, closer each turn."); if g.has(Item::Lantern) && !g.flag("lantern") { d = d.act("Light the lantern", None, |g| g.set("lantern")); } if g.has(Item::Ration) { d = d.act("Throw them a ration", None, |g| { g.take(Item::Ration); g.set("wolves_leave"); }); } d.act("Run for it", None, |g| { g.energy = (g.energy - 25.0).max(0.0); if g.money > 0 { g.money -= 1; } g.set("wolves_leave"); }) }