forge
Explore
Log in

Don't you dare go Hollow

courier

Clone
★ 0

0 watching0 forksRustAGPL-3.05.3 MiB6d9eeb9Tahinli21 days ago3 commits

content.rs738 lines, 26.4 KiBHistoryRawDownload
1use crate::game::*;
2
3pub fn talk(t: Talk, node: &str, g: &Game) -> Dialog {
4 match t {
5 Talk::Npc(n) => npc(n, node, g),
6 Talk::Obj(o) => obj(o, g),
7 Talk::Ev(e) => ev(e, node, g),
8 Talk::Camp => camp(g),
9 }
10}
11
12fn hi(g: &Game, n: Npc, a: &'static str, b: &'static str, c: &'static str) -> &'static str {
13 match g.heart(n) {
14 0 => a,
15 1 | 2 => b,
16 _ => c,
17 }
18}
19
20fn eat(g: &mut Game) {
21 if g.pay(1) {
22 g.hunger = (g.hunger + 45.0).min(100.0);
23 g.request = Some(Req::Wait { minutes: 30.0 });
24 }
25}
26
27fn bed(g: &mut Game) {
28 if g.pay(2) {
29 g.request = Some(Req::Sleep { until: 7.0 * 60.0, camp: false });
30 }
31}
32
33fn sleep_home(g: &mut Game) {
34 g.request = Some(Req::Sleep { until: 7.0 * 60.0, camp: false });
35}
36
37fn buy_ration(g: &mut Game) {
38 g.buy(Item::Ration, 1);
39}
40
41fn buy_wood(g: &mut Game) {
42 g.buy(Item::Firewood, 1);
43}
44
45fn buy_tobacco(g: &mut Game) {
46 g.buy(Item::Tobacco, 1);
47}
48
49fn buy_whistle(g: &mut Game) {
50 g.buy(Item::TinWhistle, 1);
51}
52
53fn buy_ribbon(g: &mut Game) {
54 g.buy(Item::Ribbon, 2);
55}
56
57fn buy_book(g: &mut Game) {
58 g.buy(Item::PoetryBook, 6);
59}
60
61fn give_bread(g: &mut Game) {
62 g.take(Item::Ration);
63}
64
65fn npc(n: Npc, node: &str, g: &Game) -> Dialog {
66 match n {
67 Npc::Hale => hale(node, g),
68 Npc::Pike => pike(node, g),
69 Npc::Bess => bess(node, g),
70 Npc::Edwin => edwin(node, g),
71 Npc::OldTom => tom(node, g),
72 Npc::Annie => sam(node, g),
73 Npc::Foreman => foreman(node, g),
74 Npc::Quill => quill(node, g),
75 Npc::Weaver => weaver(node),
76 Npc::Peddler => market(g),
77 Npc::Miner => miner(node, g),
78 Npc::Jack => jack(node, g),
79 Npc::Pawn => pawn(node, g),
80 }
81}
82
83fn hale(node: &str, g: &Game) -> Dialog {
84 let n = Npc::Hale;
85 match node {
86 "parcel" => {
87 if g.flag("job_parcel") || g.flag("delivered_parcel") {
88 Dialog::new(n.name(), "The Millbrook parcel is in your hands. Mind it.").bye("Leave")
89 } else {
90 Dialog::new(n.name(), "A parcel for the Millbrook mill foreman. Five shillings on delivery.")
91 .act("Take the parcel", None, |g| {
92 g.give(Item::Parcel);
93 g.set("job_parcel");
94 })
95 .bye("Not today")
96 }
97 }
98 "letter" => {
99 if g.flag("job_letter") {
100 Dialog::new(n.name(), "Straight to the pawnbroker in Coalbridge, and back before dark.").bye("Leave")
101 } else if g.flag("delivered_letter") {
102 Dialog::new(n.name(), "The pawnbroker paid fair, I'll say that for him.").bye("Leave")
103 } else {
104 Dialog::new(n.name(), "A sealed letter for the Coalbridge pawnbroker. Eight shillings on delivery.")
105 .act("Take the letter", None, |g| {
106 g.give(Item::Letter);
107 g.set("job_letter");
108 })
109 .bye("Not today")
110 }
111 }
112 "roads" => Dialog::new(
113 n.name(),
114 "Surveyors have pegged a line over the moor all summer. Railway, they say. The coaching trade is finished.",
115 )
116 .go("Back", "start")
117 .bye("Leave"),
118 _ => hale_start(g),
119 }
120}
121
122fn hale_start(g: &Game) -> Dialog {
123 let n = Npc::Hale;
124 if g.flag("delivered_parcel") && !g.flag("hale_thanked") {
125 return Dialog::new(n.name(), "The foreman's receipt came back. You did well by the parcel.").act(
126 "Thank you, sir",
127 Some("letter"),
128 |g| {
129 g.bond(Npc::Hale, 1);
130 g.set("hale_thanked");
131 },
132 );
133 }
134 let text = hi(
135 g,
136 n,
137 "Morning. The post comes in on the early coach, if the rain lets it.",
138 "Ah, it's you. Mind the loose step.",
139 "Good to see you, friend. Sit a minute, the kettle's on.",
140 );
141 let mut d = Dialog::new(n.name(), text);
142 if !g.flag("job_parcel") && !g.flag("delivered_parcel") {
143 d = d.go("Any work going?", "parcel");
144 }
145 if (g.flag("job_parcel") || g.flag("delivered_parcel")) && !g.flag("job_letter") && !g.flag("delivered_letter") {
146 d = d.go("Any more work?", "letter");
147 }
148 d.go("Talk about the roads", "roads").bye("Leave")
149}
150
151fn pike(node: &str, g: &Game) -> Dialog {
152 let n = Npc::Pike;
153 match node {
154 "shop" => {
155 let mut d = Dialog::new(n.name(), "Prices are up since the mills. Never sleep cold on the moor road. Take wood.");
156 if g.money >= 1 {
157 d = d.act("Ration (1s)", Some("shop"), buy_ration);
158 d = d.act("Firewood (1s)", Some("shop"), buy_wood);
159 }
160 if !g.has(Item::Bedroll) && g.money >= 3 {
161 d = d.act("Bedroll (3s)", Some("shop"), |g| {
162 g.buy(Item::Bedroll, 3);
163 });
164 }
165 if !g.has(Item::Lantern) && g.money >= 2 {
166 d = d.act("Lantern (2s)", Some("shop"), |g| {
167 g.buy(Item::Lantern, 2);
168 });
169 }
170 d.bye("Leave")
171 }
172 _ => Dialog::new(
173 n.name(),
174 hi(
175 g,
176 n,
177 "Good day. Mind the sugar tins on the sill.",
178 "Morning. Need anything for the road?",
179 "Back again? Let me sort you out proper.",
180 ),
181 )
182 .go("Show me your goods", "shop")
183 .bye("Leave"),
184 }
185}
186
187fn bess(node: &str, g: &Game) -> Dialog {
188 let n = Npc::Bess;
189 match node {
190 "gossip" => Dialog::new(
191 n.name(),
192 "The ironworks took on two hundred men in spring. Half of them left wives on the moor road. Mind yourself out there.",
193 )
194 .bye("Leave"),
195 "wants" => Dialog::new(
196 n.name(),
197 "A silk ribbon for chapel on Sunday. They sell them in Millbrook, the peddler there has a tray.",
198 )
199 .bye("Leave"),
200 "ribbon_thanks" => Dialog::new(n.name(), "Oh, look at that. I'll wear it to chapel on Sunday.").bye("Leave"),
201 _ => {
202 let mut d = Dialog::new(
203 n.name(),
204 hi(
205 g,
206 n,
207 "Hot meal and a fire, if you've the coin.",
208 "Mind the step. Soup's on.",
209 "Sit by the fire, love. You look done in.",
210 ),
211 );
212 if g.money >= 1 {
213 d = d.act("Hot meal (1s)", None, eat);
214 }
215 if g.has(Item::Ribbon) && !g.flag("gave_ribbon") {
216 d = d.act("Give her the silk ribbon", Some("ribbon_thanks"), |g| {
217 g.take(Item::Ribbon);
218 g.bond(Npc::Bess, 2);
219 g.set("gave_ribbon");
220 });
221 }
222 if !g.has(Item::Ribbon) && !g.flag("gave_ribbon") {
223 d = d.go("Do you need anything?", "wants");
224 }
225 d.go("Any news?", "gossip").bye("Leave")
226 }
227 }
228}
229
230fn edwin(node: &str, g: &Game) -> Dialog {
231 let n = Npc::Edwin;
232 match node {
233 "wants" => Dialog::new(n.name(), "I'd give a week's wages for Songs of the Moor. Nobody in Ashford stocks it.")
234 .bye("Leave"),
235 "thanks" => Dialog::new(n.name(), "Songs of the Moor. Thank you. I'll read it by the stove tonight.").bye("Leave"),
236 "verse" => Dialog::new(
237 n.name(),
238 "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.",
239 )
240 .bye("Leave"),
241 _ => {
242 let mut d = Dialog::new(
243 n.name(),
244 hi(
245 g,
246 n,
247 "Sit down, the slate's still warm. Don't mind the boys.",
248 "Ah. Did you bring the post?",
249 "You're a welcome sight. Sit by the stove.",
250 ),
251 );
252 if g.has(Item::PoetryBook) && !g.flag("gave_book") {
253 d = d.act("Give him Songs of the Moor", Some("thanks"), |g| {
254 g.take(Item::PoetryBook);
255 g.bond(Npc::Edwin, 2);
256 g.set("gave_book");
257 });
258 }
259 if g.flag("gave_book") {
260 d = d.go("Recite something", "verse");
261 } else {
262 d = d.go("What do you want?", "wants");
263 }
264 d.bye("Leave")
265 }
266 }
267}
268
269fn tom(node: &str, g: &Game) -> Dialog {
270 let n = Npc::OldTom;
271 match node {
272 "jack" => Dialog::new(
273 n.name(),
274 "My Jack went to the Coalbridge ironworks a year gone. Not a line since. Would you look in on him?",
275 )
276 .act("I'll look for him", Some("jack_yes"), |g| g.set("quest_jack")),
277 "jack_yes" => Dialog::new(n.name(), "Thank you. Tell him his father's chest is bad, but his bed's still made.")
278 .bye("Leave"),
279 "letter_read" => Dialog::new(
280 n.name(),
281 "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.'",
282 )
283 .bye("Leave"),
284 "tobacco" => Dialog::new(n.name(), "He packs the pipe with shaking hands. 'That's a kindness, lad.'").bye("Leave"),
285 _ => {
286 let mut d = Dialog::new(
287 n.name(),
288 hi(
289 g,
290 n,
291 "*Coughs into his sleeve.* Mind the dust, lad.",
292 "Morning. The chest is bad today.",
293 "Sit down, lad. Good to see a friendly face.",
294 ),
295 );
296 if !g.flag("quest_jack") && !g.flag("jack_done") {
297 d = d.go("Anything I can do?", "jack");
298 }
299 if g.flag("quest_jack") && g.has(Item::JacksLetter) && !g.flag("jack_done") {
300 d = d.act("Give him the letter", Some("letter_read"), |g| {
301 g.take(Item::JacksLetter);
302 g.bond(Npc::OldTom, 3);
303 g.set("jack_done");
304 });
305 }
306 if g.has(Item::Tobacco) {
307 d = d.act("Give him pipe tobacco", Some("tobacco"), |g| {
308 g.take(Item::Tobacco);
309 g.bond(Npc::OldTom, 1);
310 });
311 }
312 d.bye("Leave")
313 }
314 }
315}
316
317fn sam(node: &str, g: &Game) -> Dialog {
318 let n = Npc::Annie;
319 match node {
320 "wants" => Dialog::new(n.name(), "A tin whistle. The peddler in Millbrook has them for a shilling.").bye("Leave"),
321 "whistle_play" => Dialog::new(
322 n.name(),
323 "He blows three wobbly notes, then a whole tune. The kitchen goes quiet to listen.",
324 )
325 .bye("Leave"),
326 _ => {
327 let mut d = Dialog::new(
328 n.name(),
329 hi(
330 g,
331 n,
332 "He stares at your boots and says nothing.",
333 "He grins and hides behind the table leg.",
334 "He shows you his scraped knee, proudly.",
335 ),
336 );
337 if g.has(Item::TinWhistle) {
338 d = d.act("Give him the tin whistle", Some("whistle_play"), |g| {
339 g.take(Item::TinWhistle);
340 g.bond(Npc::Annie, 2);
341 g.set("gave_whistle");
342 });
343 } else if g.flag("gave_whistle") {
344 d = d.go("Ask for a tune", "whistle_play");
345 } else {
346 d = d.go("What do you want?", "wants");
347 }
348 d.bye("Leave")
349 }
350 }
351}
352
353fn foreman(node: &str, g: &Game) -> Dialog {
354 let n = Npc::Foreman;
355 match node {
356 "bales" => Dialog::new(
357 n.name(),
358 "Two bales from the pile to the mill door. Three shillings. They weigh more than they look.",
359 )
360 .act("Take the job", None, |g| g.set("job_bales"))
361 .bye("Not today"),
362 "parcel_done" => Dialog::new(n.name(), "Good. Tell Hale the mill is still standing.").bye("Leave"),
363 "bales_paid" => Dialog::new(n.name(), "Three shillings. Don't spend it all at the Arms.").bye("Leave"),
364 "children" => Dialog::new(
365 n.name(),
366 "Eight and nine year olds on the lower frames, under the belts. Their fingers are quick. That's all the mill wants of them.",
367 )
368 .bye("Leave"),
369 _ => {
370 let mut text = String::from("The frames don't stop. Fourteen hours, six days.");
371 if g.flag("job_bales") && g.counter("bales") < 2 {
372 text += &format!(" {} bales still to carry.", 2 - g.counter("bales"));
373 }
374 let mut d = Dialog::new(n.name(), text);
375 if g.has(Item::Parcel) && g.flag("job_parcel") {
376 d = d.act("Deliver the Millbrook parcel", Some("parcel_done"), |g| {
377 g.take(Item::Parcel);
378 g.earn(5);
379 g.set("delivered_parcel");
380 g.unset("job_parcel");
381 });
382 }
383 if g.flag("job_bales") && g.counter("bales") >= 2 {
384 d = d.act("Collect your pay", Some("bales_paid"), |g| {
385 g.earn(3);
386 g.unset("job_bales");
387 g.set("bales_done");
388 });
389 } else if !g.flag("job_bales") && !g.flag("bales_done") {
390 d = d.go("Any extra work?", "bales");
391 }
392 d.go("What about the children?", "children").bye("Leave")
393 }
394 }
395}
396
397fn quill(node: &str, g: &Game) -> Dialog {
398 let n = Npc::Quill;
399 match node {
400 "news" => Dialog::new(
401 n.name(),
402 "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.",
403 )
404 .bye("Leave"),
405 _ => {
406 let mut d = Dialog::new(
407 n.name(),
408 hi(
409 g,
410 n,
411 "Come in out of the damp. Mind the stacks.",
412 "Ah, a customer. Anything in particular?",
413 "The usual, is it? Shall I put it aside?",
414 ),
415 );
416 if !g.has(Item::PoetryBook) && !g.flag("gave_book") && g.money >= 6 {
417 d = d.act("Songs of the Moor (6s)", None, buy_book);
418 }
419 d.go("Any news?", "news").bye("Leave")
420 }
421 }
422}
423
424fn weaver(node: &str) -> Dialog {
425 let n = Npc::Weaver;
426 match node {
427 "loom" => Dialog::new(
428 n.name(),
429 "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.",
430 )
431 .go("And now?", "last"),
432 "last" => Dialog::new(n.name(), "Mind the shuttle on the sill. It's all I kept of my trade.").bye("Leave"),
433 _ => Dialog::new(n.name(), "I had four looms and a bench of my own, once.")
434 .go("What happened?", "loom")
435 .bye("Leave"),
436 }
437}
438
439fn market(g: &Game) -> Dialog {
440 let mut d = Dialog::new(Npc::Peddler.name(), "Whistles, ribbons, bread. Prices are up since the mill opened.");
441 if !g.has(Item::TinWhistle) && g.money >= 1 {
442 d = d.act("Tin Whistle (1s)", Some("start"), buy_whistle);
443 }
444 if !g.has(Item::Ribbon) && g.money >= 2 {
445 d = d.act("Silk Ribbon (2s)", Some("start"), buy_ribbon);
446 }
447 if g.money >= 1 {
448 d = d.act("Ration (1s)", Some("start"), buy_ration);
449 d = d.act("Firewood (1s)", Some("start"), buy_wood);
450 }
451 d.bye("Leave")
452}
453
454fn miner(node: &str, g: &Game) -> Dialog {
455 let n = Npc::Miner;
456 match node {
457 "pit" => Dialog::new(
458 n.name(),
459 "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.",
460 )
461 .bye("Leave"),
462 "notice" => Dialog::new(
463 n.name(),
464 "The notice says the company will not answer for accidents below ground. He nods, as if he'd known it.",
465 )
466 .bye("Thank you"),
467 _ => {
468 let mut d = Dialog::new(n.name(), "Coal dust in the lines of his face, an unlit lamp at his belt.")
469 .go("Tell me about the pit", "pit");
470 if !g.flag("read_notice") {
471 d = d.act("Read him the posted notice (earn 1s)", Some("notice"), |g| {
472 g.earn(1);
473 g.set("read_notice");
474 g.request = Some(Req::Wait { minutes: 15.0 });
475 });
476 }
477 d.bye("Leave")
478 }
479 }
480}
481
482fn jack(node: &str, g: &Game) -> Dialog {
483 let n = Npc::Jack;
484 match node {
485 "ashamed" => Dialog::new(
486 n.name(),
487 "I can't write. Never learned, and I was too proud to say so. A year gone and not a word.",
488 )
489 .bye("Leave"),
490 "letter" => Dialog::new(
491 n.name(),
492 "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.",
493 )
494 .act("Write it for him", Some("letter_done"), |g| {
495 g.request = Some(Req::Wait { minutes: 60.0 });
496 g.give(Item::JacksLetter);
497 g.set("jack_letter");
498 }),
499 "letter_done" => Dialog::new(
500 n.name(),
501 "He folds it twice and hands it over. 'Tell him I'm sorry. Don't tell him how I look.'",
502 )
503 .bye("Leave"),
504 _ => {
505 let text = if g.flag("jack_letter") {
506 "He nods, and says no more."
507 } else {
508 "A wary man in a soot-grey coat. 'What's it to you?'"
509 };
510 let mut d = Dialog::new(n.name(), text);
511 if !g.flag("jack_letter") {
512 d = d.go("Why haven't you written?", "ashamed").go("I can write a letter for you", "letter");
513 }
514 d.bye("Leave")
515 }
516 }
517}
518
519fn pawn(node: &str, g: &Game) -> Dialog {
520 let n = Npc::Pawn;
521 match node {
522 "letter_done" => Dialog::new(n.name(), "He reads it through once and counts eight shillings onto the counter.")
523 .bye("Leave"),
524 "rings" => Dialog::new(
525 n.name(),
526 "Wedding rings every Monday, back every Saturday when the wages come. Some come back twice. I don't ask.",
527 )
528 .bye("Leave"),
529 _ => {
530 let mut d = Dialog::new(
531 n.name(),
532 "Glass case, scales, a drawer of watches. The wedding rings sit at the front.",
533 );
534 if g.has(Item::Letter) && g.flag("job_letter") {
535 d = d.act("Deliver the sealed letter", Some("letter_done"), |g| {
536 g.take(Item::Letter);
537 g.earn(8);
538 g.set("delivered_letter");
539 g.unset("job_letter");
540 });
541 }
542 if g.money >= 1 {
543 d = d.act("Pipe Tobacco (1s)", Some("start"), buy_tobacco);
544 d = d.act("Ration (1s)", Some("start"), buy_ration);
545 }
546 d.go("Anything I should know?", "rings").bye("Leave")
547 }
548 }
549}
550
551fn obj(o: Obj, g: &Game) -> Dialog {
552 match o {
553 Obj::HomeBed => Dialog::new("", "Your cottage. The fire is banked low and the bed is still warm from the night.")
554 .act("Sleep until morning", None, sleep_home)
555 .bye("Leave"),
556 Obj::BalePile => {
557 if g.flag("job_bales") && !g.flag("carrying") && g.counter("bales") < 2 {
558 Dialog::new("", "A bale of raw cotton, heavy and sour with oil.")
559 .act("Heave a bale", None, |g| g.set("carrying"))
560 .bye("Leave")
561 } else {
562 Dialog::new("", "A bale of raw cotton, heavy and sour with oil. The pile is taller than the men who stack it.")
563 .bye("Leave")
564 }
565 }
566 Obj::BaleDrop => {
567 if g.flag("carrying") {
568 let text = match g.counter("bales") {
569 0 => "The mill door, and the roar of the looms like weather. Your first bale goes down among the others.",
570 _ => "The last bale. Your arms have stopped telling you how heavy they are.",
571 };
572 Dialog::new("", text)
573 .act("Drop the bale", None, |g| {
574 g.unset("carrying");
575 g.add("bales", 1);
576 g.request = Some(Req::Wait { minutes: 20.0 });
577 })
578 .bye("Leave")
579 } else {
580 Dialog::new("", "The mill door. The roar of the looms comes out like weather.").bye("Leave")
581 }
582 }
583 Obj::Signpost => Dialog::new(
584 "",
585 "Ashford four miles. Millbrook two, the mill chimney in view. Coalbridge over the moor, where the smoke comes from.",
586 )
587 .bye("Leave"),
588 Obj::MillInn => inn("The Weavers' Arms", g),
589 Obj::CoalInn => inn("The Miners' Rest", g),
590 }
591}
592
593fn inn(name: &'static str, g: &Game) -> Dialog {
594 let mut d = Dialog::new(name, "Smoke, beer and wet wool. A bed upstairs for two shillings.");
595 if g.money >= 2 {
596 d = d.act("Bed (2s)", None, bed);
597 }
598 if g.money >= 1 {
599 d = d.act("Hot meal (1s)", None, eat);
600 }
601 d.bye("Leave")
602}
603
604fn ev(e: Ev, node: &str, g: &Game) -> Dialog {
605 match e {
606 Ev::BrokenCart => cart(node),
607 Ev::Highwayman => highwayman(node, g),
608 Ev::Storm => storm(),
609 Ev::Peddler => tinker(node, g),
610 Ev::Lost => lost(node, g),
611 Ev::Wolves => wolves(g),
612 }
613}
614
615fn cart(node: &str) -> Dialog {
616 match node {
617 "done" => Dialog::new("Carter", "He presses a ration into your hand. For the road.").bye("Leave"),
618 _ => Dialog::new("Carter", "A carter kneels by a cart with a split wheel. His horse stands patient in the rain.")
619 .act("Help him (1 hour)", Some("done"), |g| {
620 g.request = Some(Req::Wait { minutes: 60.0 });
621 g.earn(1);
622 g.give(Item::Ration);
623 })
624 .bye("Can't stop"),
625 }
626}
627
628fn highwayman(node: &str, g: &Game) -> Dialog {
629 match node {
630 "robbed" => Dialog::new("", "He takes the coins without a word and is gone into the dark.").bye("Leave"),
631 "ran" => Dialog::new("", "You run. Your legs burn and the lamp swings, but nobody follows.").bye("Leave"),
632 "bread" => Dialog::new(
633 "Highwayman",
634 "He lowers the pistol. 'Laid off from the looms in March. I'm not a thief, not really.'",
635 )
636 .bye("Leave"),
637 _ => {
638 let mut d = Dialog::new("Highwayman", "A man steps out from the wall, a pistol held low. 'Your purse or your life.'")
639 .act("Hand over your purse", Some("robbed"), |g| {
640 let n = g.money.min(3);
641 g.money -= n;
642 g.toasts.push(format!("- {n}s"));
643 g.sfx.push(Sfx::Coin);
644 })
645 .act("Run for it", Some("ran"), |g| {
646 g.energy = (g.energy - 25.0).max(0.0);
647 g.warmth = (g.warmth - 10.0).max(0.0);
648 });
649 if g.has(Item::Ration) {
650 d = d.act("Offer him bread", Some("bread"), give_bread);
651 }
652 d
653 }
654 }
655}
656
657fn storm() -> Dialog {
658 Dialog::new("", "Clouds come down over the moor, grey and fast. The first drops hit hard.")
659 .act("Press on", None, |g| {
660 g.raining = true;
661 })
662 .act("Shelter under the trees (1 hour)", None, |g| {
663 g.request = Some(Req::Wait { minutes: 60.0 });
664 })
665}
666
667fn tinker(node: &str, g: &Game) -> Dialog {
668 match node {
669 "rail" => Dialog::new(
670 "Tinker",
671 "They'll lay rails over the moor by spring. He says it like a man reading a death notice.",
672 )
673 .bye("Leave"),
674 _ => {
675 let mut d = Dialog::new("Tinker", "A tinker with a handcart and a tin tray. Bread, wood, and news.");
676 if g.money >= 1 {
677 d = d.act("Ration (1s)", Some("start"), buy_ration);
678 d = d.act("Firewood (1s)", Some("start"), buy_wood);
679 }
680 d.go("Ask about the railway", "rail").bye("Walk on")
681 }
682 }
683}
684
685fn lost(node: &str, g: &Game) -> Dialog {
686 match node {
687 "done" => Dialog::new("Boy", "He eats it in three bites and runs off down the beck path.").bye("Leave"),
688 "point" => Dialog::new(
689 "Boy",
690 "Follow the beck down, with the mill chimney on your left. You'll hear the looms before you see them.",
691 )
692 .bye("Leave"),
693 _ => {
694 let mut d = Dialog::new(
695 "Boy",
696 "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.'",
697 );
698 if g.has(Item::Ration) {
699 d = d.act("Give him bread and point the way", Some("done"), give_bread);
700 }
701 d.go("Point the way", "point").bye("Walk on")
702 }
703 }
704}
705
706fn camp(g: &Game) -> Dialog {
707 let mut text = String::from("A dry hollow off the road, out of the wind.");
708 text += if g.has(Item::Firewood) { " Wood for a fire." } else { " No wood. It will be cold." };
709 text += if g.has(Item::Bedroll) { " A bedroll." } else { " Bare ground." };
710 Dialog::new("", text)
711 .act("Make camp and sleep", None, |g| {
712 g.request = Some(Req::Sleep { until: 7.0 * 60.0, camp: true });
713 })
714 .act("Rest an hour", None, |g| {
715 g.request = Some(Req::Wait { minutes: 60.0 });
716 })
717 .bye("Not here")
718}
719
720fn wolves(g: &Game) -> Dialog {
721 let mut d = Dialog::new("", "Yellow eyes in the dark. The pack circles, closer each turn.");
722 if g.has(Item::Lantern) && !g.flag("lantern") {
723 d = d.act("Light the lantern", None, |g| g.set("lantern"));
724 }
725 if g.has(Item::Ration) {
726 d = d.act("Throw them a ration", None, |g| {
727 g.take(Item::Ration);
728 g.set("wolves_leave");
729 });
730 }
731 d.act("Run for it", None, |g| {
732 g.energy = (g.energy - 25.0).max(0.0);
733 if g.money > 0 {
734 g.money -= 1;
735 }
736 g.set("wolves_leave");
737 })
738}