-
Notifications
You must be signed in to change notification settings - Fork 10
/
act2.cpp
1292 lines (1228 loc) · 37.7 KB
/
act2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "stdafx.h"
#include "act1.h"
#include "act2.h"
#include "cevent.h"
#include "objfns.h"
#include "defs.h"
#include "funcs.h"
#include "rooms.h"
#include "zstring.h"
#include "util.h"
#include "dung.h"
#include "parser.h"
#include "adv.h"
#include "makstr.h"
#include "memq.h"
using namespace std::string_view_literals;
int beach_dig = 0;
namespace
{
RoomP munged_room;
}
int light_shaft = []() { inc_score_max(10); return 10; }();
ObjectP btie;
ObjectP binf;
CEventP burnup_int;
bool digger::operator()() const
{
ObjectP prsio = prsi();
if (prsio == sfind_obj("SHOVE"))
{
object_action();
}
else if (trnn(prsio, Bits::toolbit))
{
tell("Digging with the ", 1, prsio->odesc2(), " is slow and tedious.");
}
else
{
tell("Digging with a ", 1, prsio->odesc2(), " is silly.");
}
return true;
}
bool ledge_mung::operator()() const
{
RoomP rm = sfind_room("LEDG4");
const AdvP &winner = *::winner;
if (here == rm)
{
if (winner->avehicle())
{
if (btie)
{
rm = sfind_room("VLBOT");
bloc = rm;
remove_object(sfind_obj("BALLO"));
insert_object(sfind_obj("DBALL"), rm);
btie.reset();
binf.reset();
clock_disable(bint);
clock_disable(brnin);
jigs_up("The ledge collapses, probably as a result of the explosion. A large\n"
"chunk of it, which is attached to the hook, drags you down to the\n"
"ground. Fatally.");
}
else
{
tell("The ledge collapses, leaving you with no place to land.");
}
}
else
{
jigs_up("The force of the explosion has caused the ledge to collapse\n"
"belatedly.");
}
}
else
{
tell("The ledge collapses, giving you a narrow escape.");
}
mung_room(rm, "The ledge has collapsed and cannot be landed on.");
return true;
}
bool safe_mung::operator()() const
{
RoomP rm = munged_room;
if (here == rm)
{
jigs_up(rtrnn(rm, RoomBit::rhousebit) ?
"The house shakes, and the ceiling of the room you're in collapses,\n"
"turning you into a pancake." :
"The room trembles and 50,000 pounds of rock fall on you, turning you\n"
"into a pancake.");
}
else
{
tell("You may recall that recent explosion. Well, probably as a result of\n"
"that, you hear an ominous rumbling, as if one of the rooms in the\n"
"dungeon had collapsed.", long_tell1);
rm == sfind_room("SAFE") && clock_int(ledin, 8);
}
mung_room(rm, "The way is blocked by debris from an explosion.");
return true;
}
bool shaker::operator()() const
{
ObjectP prso = ::prso();
bool rv = true;
if (object_action())
{
}
else if (trnn(prso, Bits::villain))
{
tell("This seems to have no effect.");
}
else if (!trnn(prso, Bits::takebit))
{
tell("You can't take it; thus, you can't shake it!");
}
else if (!trnn(prso, Bits::openbit) && !empty(prso->ocontents()))
{
tell("It sounds like there is something inside the ", 1, prso->odesc2(), ".");
}
else if (trnn(prso, Bits::openbit) && !empty(prso->ocontents()))
{
for (const ObjectP &x : prso->ocontents())
{
x->ocan(nullptr);
insert_object(x, here);
}
prso->ocontents().clear();
tell("All of the objects spill onto the floor.");
}
else
rv = false;
return rv;
}
bool swimmer::operator()() const
{
return tell(rtrnn(here, RoomBit::rfillbit) ? "Swimming is not allowed in this dungeon." : pick_one(swimyuks));
}
bool volgnome::operator()() const
{
if (member("LEDG", here->rid()))
{
tell(gnome_desc, long_tell1);
insert_object(sfind_obj("GNOME"), here);
}
else
{
clock_int(vlgin, 1);
}
return true;
}
bool geronimo::operator()() const
{
return (*winner)->avehicle() == sfind_obj("BARRE") ? jigs_up(over_falls_str) : tell("Wasn't he an Indian?");
}
bool put_balloon(const ObjectP &ball, std::string_view there, std::string_view str)
{
if (member("LEDG", here->rid()) || here == find_room("VLBOT"))
{
tell("You watch as the balloon slowly ", 1, str);
}
remove_object(ball);
insert_object(ball, bloc = find_room(there));
return true;
}
bool rise_and_shine(const ObjectP &ball)
{
const AdvP &winner = *::winner;
bool in = winner->avehicle() == ball;
RoomP bl = bloc;
clock_int(bint, 3);
const char *m;
if (m = member("VAIR", bl->rid()))
{
if (rest(m, 4) == "4"sv)
{
clock_disable(burnup_int);
clock_disable(bint);
remove_object(ball);
const auto& vlbot = sfind_room("VLBOT");
insert_object(sfind_obj("DBALL"), vlbot);
if (in)
{
jigs_up("Your balloon has hit the rim of the volcano, ripping the cloth and\n"
"causing you a 500 foot drop. Did you get your flight insurance?");
}
else if (here == vlbot)
{
tell("You watch the balloon explode after hitting the rim; its tattered\n"
"remains land on the ground by your feet.");
}
else
{
tell("You hear a boom and notice that the balloon is falling to the ground.");
}
bloc = vlbot;
}
else
{
std::string s = " ";
substruc(bl->rid(), 0, 4, s);
s[4] = m[4] + 1;
if (in)
{
goto_(bloc = find_room(s));
tell("The balloon ascends.");
room_info()();
}
else
{
put_balloon(ball, s, "ascends.");
}
}
}
else if (m = member("LEDG", bl->rid()))
{
char s[6] = { 0 };
substruc("VAIR", 0, 4, s);
s[4] = m[4];
if (in)
{
goto_(bloc = find_room(s));
tell("The balloon leaves the ledge.");
room_info()();
}
else
{
clock_int(vlgin, 10);
put_balloon(ball, s, "floats away. It seems to be ascending\ndue to its light load.");
}
}
else if (in)
{
goto_(bloc = sfind_room("VAIR1"));
tell("The balloon slowly rises from the ground.");
room_info()();
}
else
{
put_balloon(ball, "VAIR1", "lifts off.");
}
return true;
}
bool decline_and_fall(const ObjectP &ball)
{
const AdvP &winner = *::winner;
bool in = winner->avehicle() == ball;
RoomP bl = bloc;
clock_int(bint, 3);
const char *m;
if (m = member("VAIR", bl->rid()))
{
if (rest(m, 4) == std::string("1"))
{
if (in)
{
goto_(bloc = sfind_room("VLBOT"));
if (binf)
{
tell("The balloon has landed.");
clock_int(bint, 0);
room_info()();
}
else
{
remove_object(ball);
insert_object(sfind_obj("DBALL"), bloc);
winner->avehicle(ObjectP());
clock_disable(clock_int(bint, 0));
tell("You have landed, but the balloon did not survive.");
}
}
else
{
put_balloon(ball, "VLBOT", "lands.");
}
}
else
{
std::string s = " ";
substruc(bl->rid(), 0, 4, s);
s[4] = m[4] - 1;
if (in)
{
goto_(bloc = sfind_room(s));
tell("The balloon descends.");
room_info()();
}
else
{
put_balloon(ball, s, "descends.");
}
}
}
return true;
}
bool balloon_burn()
{
ObjectP prso = ::prso();
const ObjectP &ball = sfind_obj("BALLO");
tell("The ", 1, prso->odesc2(), " burns inside the receptacle.");
burnup_int = clock_int(brnin, prso->osize() * 20);
tro(prso, Bits::flamebit, Bits::lightbit, Bits::onbit );
trz(prso, Bits::takebit, Bits::readbit );
if (binf)
{
}
else
{
tell("The cloth bag inflates as it fills with hot air.");
if (!flags[FlagId::blab])
{
auto &blabe = sfind_obj("BLABE");
ball->ocontents().push_front(blabe);
blabe->ocan(ball);
}
flags[FlagId::blab] = true;
binf = prso;
clock_int(bint, 3);
}
return true;
}
bool blast::operator()() const
{
return (here != sfind_room("SAFE")) ? tell("I don't really know how to do that.") : true;
}
bool breathe::operator()() const
{
return perform(inflater(), find_verb("INFLA"), prso(), sfind_obj("LUNGS"));
}
bool burnup::operator()() const
{
const ObjectP &r = sfind_obj("RECEP");
_ASSERT(r->ocontents().size() == 1);
const ObjectP &obj = r->ocontents().front();
if (here == bloc)
{
tell("You notice that the ", 1, obj->odesc2(), " has burned out, and that\n"
"the cloth bag starts to deflate.");
}
splice_out_in_place(obj, r->ocontents());
binf.reset();
return true;
}
void fweep(int, int)
{
// This function uses the "IMAGE 7" command apparently to ring
// the terminal bell. Since that will be annoying, to say the
// least, it just doesn't do anything.
}
namespace obj_funcs
{
bool dboat_function::operator()() const
{
const ObjectP &dboat = sfind_obj("DBOAT");
bool rv = true;
if (verbq("INFLA"))
{
tell("This boat will not inflate since some moron put a hole in it.");
}
else if (verbq("PLUG"))
{
if (prsi() == sfind_obj("PUTTY"))
{
tell("Well done. The boat is repaired.");
if (!dboat->oroom())
{
drop_object(dboat);
take_object(sfind_obj("IBOAT"));
}
else
{
remove_object(sfind_obj("DBOAT"));
insert_object(sfind_obj("IBOAT"), here);
}
}
else
{
with_tell(prsi());
}
}
else
rv = false;
return rv;
}
bool gunk_function::operator()() const
{
const ObjectP& g = sfind_obj("GUNK");
const ObjectP &m = g->ocan();
if (m)
{
splice_out_in_place(g, m->ocontents());
g->ocan(nullptr);
return tell("The slag turns out to be rather insubstantial, and crumbles into dust\n"
"at your touch. It must not have been very valuable.");
}
return false;
}
bool fuse_function::operator()() const
{
const ObjectP &fuse = sfind_obj("FUSE");
const ObjectP &brick = sfind_obj("BRICK");
RoomP brick_room;
bool rv = true;
if (verbq("BURN"))
{
tell("The wire starts to burn.");
clock_enable(clock_int(fusin, 2));
}
else if (verbq("C-INT"))
{
if (fuse->ocan() == brick)
{
if (auto &oc = brick->ocan())
{
brick_room = oc->oroom();
}
else
{
brick_room = brick->oroom();
}
brick_room || (brick_room = here);
if (brick_room == here)
{
mung_room(brick_room, "The way is blocked by debris from an explosion.");
jigs_up(brick_boom);
}
else if (brick_room == sfind_room("SAFE"))
{
clock_int(safin, 5);
munged_room = brick->oroom();
tell("There is an explosion nearby.");
if (memq(brick, sfind_obj("SSLOT")->ocontents()))
{
trz(sfind_obj("SSLOT"), Bits::ovison);
tro(sfind_obj("SAFE"), Bits::openbit);
flags[FlagId::safe_flag] = true;
}
}
else
{
tell("There is an explosion nearby.");
clock_int(safin, 5);
munged_room = brick->oroom();
for (const ObjectP &x : brick_room->robjs())
{
if (trnn(x, Bits::takebit))
{
trz(x, Bits::ovison);
}
}
if (brick_room == sfind_room("LROOM"))
{
for (const ObjectP &x : sfind_obj("TCASE")->ocontents())
{
x->ocan(nullptr);
}
sfind_obj("TCASE")->ocontents().clear();
}
}
remove_object(brick);
}
else if (!fuse->oroom() || (here == fuse->oroom()))
{
tell("The wire rapidly burns into nothingness.");
}
remove_object(fuse);
}
else
rv = false;
return rv;
}
bool safe_function::operator()() const
{
const char* p = nullptr;
if (verbq("TAKE"))
{
p = "The box is imbedded in the wall.";
}
else if (verbq("OPEN"))
{
p = flags[FlagId::safe_flag] ? "The box has no door!" : "The box is rusted and will not open.";
}
else if (verbq("CLOSE"))
{
p = flags[FlagId::safe_flag] ? "The box has no door!" : "The box is not open, chomper!";
}
return p ? tell(p) : false;
}
bool gnome_function::operator()() const
{
auto &gnome = sfind_obj("GNOME");
if (verbq( "GIVE", "THROW" ))
{
ObjectP prso = ::prso();
if (prso->otval() != 0)
{
tell("Thank you very much for the " + prso->odesc2() + ". I don't believe \n"
"I've ever seen one as beautiful. 'Follow me', he says, and a door\n"
"appears on the west end of the ledge. Through the door, you can see\n"
"a narrow chimney sloping steeply downward. The gnome moves quickly,\n"
"and he disappears from sight.");
remove_object(prso);
remove_object(gnome);
flags[FlagId::gnome_door] = true;
}
else if (bomb(prso))
{
auto& brick = sfind_obj("BRICK");
brick->oroom() || insert_object(brick, here);
remove_object(gnome);
clock_disable(gnoin);
clock_disable(vlgin);
tell("'That certainly wasn't what I had in mind', he says, and disappears.");
}
else
{
tell("'That wasn't quite what I had in mind', he says, crunching the\n" + prso->odesc2() +
" in his rock-hard hands.", 1);
remove_object(prso);
}
}
else if (verbq("C-INT"))
{
if (here == gnome->oroom())
{
tell("The gnome glances at his watch. 'Oops. I'm late for an\n"
"appointment!' He disappears, leaving you alone on the ledge.", long_tell1);
}
remove_object(gnome);
}
else
{
tell("The gnome appears increasingly nervous.");
flags[FlagId::gnome_flag] || clock_int(gnoin, 5);
flags[FlagId::gnome_flag] = true;
}
return true;
}
bool balloon::operator()(Rarg arg) const
{
auto &ball = sfind_obj("BALLO");
auto &cont = sfind_obj("RECEP");
ObjectP binf = ::binf;
if (arg == ApplyRandomArg::read_out)
{
if (verbq("LOOK"))
{
if (binf)
{
tell("The cloth bag is inflated and there is a ", 1, binf->odesc2(), " burning in the receptacle.");
}
else
{
// The word "the" is doubled in the MDL source code.
tell("The cloth bag is draped over the basket.");
}
if (btie)
{
tell("The balloon is tied to the hook.");
}
}
return false;
}
else if (arg == ApplyRandomArg::read_in)
{
if (verbq("WALK"))
{
auto m = memq(as_dir(prsvec[1]), here->rexits());
if (m)
{
if (btie)
{
tell("You are tied to the ledge.");
return true;
}
else
{
ExitType rex = std::get<1>(**m);
RoomP r;
_ASSERT(!std::get_if<RoomP>(&rex));
std::string *sp;
(sp = std::get_if<std::string>(&rex)) &&
(r = sfind_room(*sp)) &&
(bloc = r);
clock_int(bint, 3);
return false;
}
}
else
{
tell("I'm afraid you can't control the balloon in this way.");
return true;
}
}
else if (verbq("TAKE"))
{
ObjectP prso = ::prso();
if (binf == prso)
{
tell("You don't really want to hold a burning ", 1, prso->odesc2(), ".");
return true;
}
return false;
}
else if (verbq("PUT") && prsi() == cont && !empty(cont->ocontents()))
{
tell("The receptacle is already occupied.");
return true;
}
else
return false;
}
if (verbq("C-INT"))
{
if (trnn(cont, Bits::openbit) && binf || member("LEDG", here->rid()))
{
rise_and_shine(ball);
}
else
{
decline_and_fall(ball);
}
return true;
}
return false;
}
bool wire_function::operator()() const
{
bool rv = true;
ObjectP prso = ::prso();
if (verbq( "TAKE", "FIND", "EXAMI" ))
{
bcontents()();
}
else if (verbq("TIE"))
{
if (prso == sfind_obj("BROPE") &&
(prsi() == sfind_obj("HOOK1") || prsi() == sfind_obj("HOOK2")))
{
btie = prsi();
prsi()->odesc1("The basket is anchored to a small hook by the braided wire.");
clock_disable(bint);
tell("The balloon is fastened to the hook.");
}
else
rv = false;
}
else if (verbq("UNTIE") && prso == sfind_obj("BROPE"))
{
if (btie)
{
clock_enable(bint = clock_int(::bint, 3));
btie->odesc1(hook_desc);
btie.reset();
tell("The wire falls off of the hook.");
}
else
{
tell("The wire is not tied to anything.");
}
}
else
rv = false;
return rv;
}
bool bcontents::operator()() const
{
bool rv = true;
ObjectP prso;
if (verbq("TAKE"))
{
prso = ::prso();
tell("The ", 0, prso->odesc2(), " is an integral part of the basket and cannot\nbe removed.");
tell(prso == sfind_obj("BROPE") ? " The wire might possibly be tied, though." : "");
}
else if (verbq( "FIND", "EXAMI" ))
{
prso = ::prso();
tell("The ", 1, prso->odesc2(), " is part of the basket. It may be manipulated\n"
"within the basket but cannot be removed.");
}
else
rv = false;
return rv;
}
bool barrel::operator()(Rarg arg) const
{
bool rv = false;
if (arg == ApplyRandomArg::read_in)
{
std::string_view msg;
if (verbq("WALK"))
{
msg = "You cannot move the barrel.";
}
else if (verbq("LOOK"))
{
msg = "You are inside a barrel. Congratulations. Etched into the side of the\n"
"barrel is the word 'Geronimo!'. From your position, you cannot see\n"
"the falls.";
}
else if (verbq("TAKE"))
{
msg = pick_one(yuks);
}
else if (verbq("BURN"))
{
msg = "The barrel is damp and cannot be burned.";
}
if (!msg.empty())
rv = tell(msg);
}
return rv;
}
bool grue_function::operator()() const
{
if (verbq("EXAMI"))
{
return tell(grue_desc1, long_tell1);
}
else if (verbq("FIND"))
{
return tell(grue_desc2, long_tell1);
}
return false;
}
bool mswitch_function::operator()() const
{
bool rv = false;
if (verbq("TURN"))
{
rv = true;
ObjectP prsio = prsi();
auto& screw = sfind_obj("SCREW");
if (prsio == screw)
{
auto &mach = sfind_obj("MACHI");
if (trnn(mach, Bits::openbit))
{
tell("The machine doesn't seem to want to do anything.");
}
else
{
tell("The machine comes to life (figuratively) with a dazzling display of\n"
"colored lights and bizarre noises. After a few moments, the\n"
"excitement abates.", long_tell1);
auto &c = sfind_obj("COAL");
if (c->ocan() == mach)
{
remove_object(c);
auto& d = sfind_obj("DIAMO");
mach->ocontents().push_front(d);
d->ocan(mach);
}
else if (!empty(mach->ocontents()))
{
// Looks like this is a bug in the MDL code. The code
// just inserts the gunk into the machine, but does 2 things wrong:
// 1. It never sets the ocan for gunk to the machine.
// 2. It does not remove the inserted objects from the machine.
// Remove all objects from the machine. They are destroyed.
// Make a copy of the list, since remove_object changes
// mach->ocontents.
ObjList temp_list = mach->ocontents();
for (auto &o : temp_list)
{
remove_object(o);
}
mach->ocontents().push_front(sfind_obj("GUNK"));
// Set the container of the gunk to the machine.
sfind_obj("GUNK")->ocan(mach);
}
}
}
else
{
tell("It seems that a ", 1, prsio->odesc2(), " won't do.");
}
}
return rv;
}
bool machine_function::operator()() const
{
bool rv = false;
if (here == sfind_room("MACHI"))
{
const ObjectP &mach = sfind_obj("MACHI");
if (verbq("OPEN"))
{
rv = true;
if (trnn(mach, Bits::openbit))
{
tell(pick_one(dummy));
}
else
{
tro(mach, Bits::openbit);
tell("The lid opens."sv);
}
}
else if (verbq("CLOSE"))
{
rv = true;
if (trnn(mach, Bits::openbit))
{
trz(mach, Bits::openbit);
tell("The lid closes."sv);
}
else
tell(pick_one(dummy));
}
}
return rv;
}
bool guano_function::operator()() const
{
bool rv = false;
if (verbq("DIG"))
{
rv = true;
static size_t guano_dig = 0;
tell(++guano_dig > cdigs.size() ? "This is getting you nowhere." : cdigs[guano_dig - 1]);
}
return rv;
}
bool sand_function::operator()() const
{
int cnt;
bool rv;
if (rv = verbq("DIG"))
{
beach_dig = cnt = beach_dig + 1;
const ObjectP& s = sfind_obj("STATU");
if (cnt > 4)
{
beach_dig = 0;
if (memq(s, here->robjs()))
{
trz(s, Bits::ovison);
}
jigs_up("The hole collapses, smothering you.");
}
else if (cnt == 4)
{
if (!trnn(s, Bits::ovison))
{
tell("You can see a small statue here in the sand.");
tro(s, Bits::ovison);
}
}
else if (cnt < 0) // ????
{
}
else
{
tell(bdigs[size_t(cnt) - 1]);
}
}
return rv;
}
bool ground_function::operator()() const
{
if (here == sfind_room("BEACH"sv))
{
return sand_function()();
}
else if (verbq("DIG"))
{
return tell("The ground is too hard for digging here.");
}
return false;
}
bool rboat_function::operator()(Rarg arg) const
{
bool rv = true;
const ObjectP &rboat = sfind_obj("RBOAT");
const ObjectP &iboat = sfind_obj("IBOAT");
const AdvP &winner = *::winner;
if (arg) // Must be a holdover from something -- never used in MDL.
{
return false;
}
if (verbq("BOARD"))
{
if (memq(sfind_obj("STICK"), winner->aobjs()))
{
tell("There is a hissing sound and the boat deflates.");
remove_object(rboat);
insert_object(sfind_obj("DBOAT"), here);
}
else
{
rv = false;
}
}
else if (verbq("INFLA"))
{
tell("Inflating it further would probably burst it.");
}
else if (verbq("DEFLA"))
{
if (winner->avehicle() == rboat)
{
tell("You can't deflate the boat while you're in it.");
}
else if (!memq(rboat, here->robjs()))
{
tell("The boat must be on the ground to be deflated.");
}
else
{
tell("The boat deflates.");
flags[FlagId::deflate] = true;
remove_object(rboat);
insert_object(iboat, here);
}
}
else
rv = false;
return rv;
}
bool iboat_function::operator()() const
{
const ObjectP &iboat = sfind_obj("IBOAT");
const ObjectP &rboat = sfind_obj("RBOAT");
bool rv;
if (rv = verbq("INFLA"))
{
ObjectP prsi;
if (!memq(iboat, here->robjs()))
{
tell("The boat must be on the ground to be inflated.");
}
else if ((prsi = ::prsi()) == sfind_obj("PUMP"))
{
tell("The boat inflates and appears seaworthy.");
flags[FlagId::deflate] = false;
remove_object(iboat);
insert_object(rboat, here);
}
else if (prsi == sfind_obj("LUNGS"))
{
tell("You don't have enough lung power to inflate it.");
}
else
{
tell("With a ", 1, prsi->odesc2(), "? Surely you jest!");
}
}
return rv;
}