-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathact3.cpp
2534 lines (2389 loc) · 67.7 KB
/
act3.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 "precomp.h"
#include <numeric>
#include <algorithm>
#include "act1.h"
#include "act2.h"
#include "act3.h"
#include "util.h"
#include "objfns.h"
#include "funcs.h"
#include "parser.h"
#include "makstr.h"
#include "zstring.h"
#include "cevent.h"
#include "adv.h"
#include "memq.h"
using namespace std::string_literals;
using namespace std::string_view_literals;
namespace
{
const char *through_desc = "You feel somewhat disoriented as you pass through...";
}
ObjectP matobj;
ObjectP timber_tie;
bool go_and_look(RoomP rm)
{
bool seen = rtrnn(rm, RoomBit::rseenbit);
goto_(rm);
perform(room_desc(), find_verb("LOOK"));
seen || rtrz(rm, RoomBit::rseenbit);
return true;
}
bool climb_down::operator()() const
{
return climb_up()(direction::Down);
}
void cp_corner(int locn, int col, int row)
{
auto s = (col != 0 && row != 0) ? "??" :
((col = cpuvec[size_t(locn) - 1]) == 0) ? " " :
(col == 1) ? "MM" :
"SS";
tell(s, no_crlf);
}
void cp_ortho(int contents)
{
auto ss = contents == 0 ? " " :
contents == 1 ? "MM" :
"SS";
tell(ss, no_crlf);
}
bool cpwhere()
{
int here = cphere;
auto &uvec = cpuvec;
int n = uvec[size_t(here) - 8 - 1];
int s = uvec[size_t(here) + 8 - 1];
int e = uvec[size_t(here) + 1 - 1];
int w = uvec[size_t(here) - 1 - 1];
tell(" |", no_crlf);
cp_corner(here - 9, n, w);
tell(" ", no_crlf);
cp_ortho(n);
tell(" ", no_crlf);
cp_corner(here - 7, n, e);
tell("|");
tell("West |", no_crlf);
cp_ortho(w);
tell(" .. ", no_crlf);
cp_ortho(e);
tell("| East\n |", no_crlf);
cp_corner(here + 7, s, w);
tell(" ", no_crlf);
cp_ortho(s);
tell(" ", no_crlf);
cp_corner(here + 9, s, e);
tell("|");
switch (here)
{
case 10:
tell("In the ceiling above you is a large circular opening.");
break;
case 37:
tell("The center of the floor here is noticeably depressed.");
break;
case 52:
tell("The west wall here has a large ", 1, flags[FlagId::cpout] ? "opening" : "steel door", " at its center. On one\n"
"side of the door is a small slit.");
break;
}
if (e == -2)
tell("There is a ladder here, firmly attached to the east wall.");
if (w == -3)
tell("There is a ladder here, firmly attached to the west wall.");
return true;
}
bool frobozz::operator()() const
{
return tell("The FROBOZZ Corporation created, owns, and operates this dungeon.");
}
bool maker::operator()() const
{
bool rv = false;
if (prso() == sfind_obj("WISH"))
{
ObjectP coins = sfind_obj("BAGCO");
if (here == sfind_room("BWELL") &&
(memq(coins, here->robjs()) || memq(coins = sfind_obj("COIN"), here->robjs())))
{
tell("A whispering voice replies: 'Water makes the bucket go.'\n"
"Unfortunately, wishing makes the coins go....");
remove_object(coins);
}
else
tell("No one is listening.");
rv = true;
}
return rv;
}
void numtell(int num, std::string_view str)
{
if (num == 0)
{
princ("no");
}
else
{
princ(num);
}
tell(" ", 0, str);
num == 1 || tell("s", 0);
tell(".");
}
bool oops::operator()() const
{
return tell("You haven't made any spelling mistakes....lately.");
}
void pcheck()
{
auto &lid = plid();
auto &mat = sfind_obj("MAT");
const ObjList &objs = palobjs;
if (is_empty(prsvec[1]))
return;
flags[FlagId::plook] = false;
if (verbq("TAKE") && memq(prso(), objs))
{
trnn(lid, Bits::openbit);
if (flags[FlagId::ptouch])
{
tell("The lid falls to cover the keyhole.");
trz(lid, Bits::openbit);
}
else
{
flags[FlagId::ptouch] = true;
}
}
for (const ObjectP &obj : objs)
{
if (memq(obj, sfind_obj("PKH1")->ocontents()) || memq(obj, sfind_obj("PKH2")->ocontents()))
{
tro(obj, Bits::ndescbit);
}
else
{
trz(obj, Bits::ndescbit);
}
}
if (!mat->oroom() || mat->ocan())
{
flags[FlagId::mud] = false;
}
if (flags[FlagId::mud])
{
remove_object(mat);
insert_object(mat, here);
tro(mat, Bits::ndescbit);
}
else
{
trz(mat, Bits::ndescbit);
}
}
bool pdoor(std::string_view str, const ObjectP &lid, const ObjectP &keyhole)
{
if (flags[FlagId::plook])
return flags[FlagId::plook] = false;
tell("On the ", 1, str, pal_door);
if (!trnn(lid, Bits::openbit))
{
tell("covered by a thin metal lid ", 0);
}
tell("lies within the lock.");
if (!empty(keyhole->ocontents()))
{
tell("A ", 1, keyhole->ocontents().front()->odesc2(), " is in place within the keyhole.");
}
if (flags[FlagId::mud])
{
tell("The edge of a welcome mat is visible under the door.");
if (matobj)
{
tell("Lying on the mat is a ", 1, matobj->odesc2(), ".");
}
}
return true;
}
ObjectP pkh(ObjectP keyhole, bool this_)
{
ObjectP obj;
if ((keyhole == (obj = sfind_obj("PKH1")) && !this_) ||
(keyhole != obj && this_))
{
return sfind_obj("PKH2");
}
return obj;
}
bool play::operator()() const
{
bool rv = true;
ObjectP prso = ::prso();
if (prso == sfind_obj("STRAD"))
{
if (prsi() && trnn(prsi(), Bits::weaponbit))
{
tell("Very good. The violin is now worthless.");
prso->otval(0);
}
else
{
tell("An amazingly offensive noise issues from the violin.");
}
}
else if (trnn(prso, Bits::villain))
{
jigs_up("You are so engrossed in the role of the " + prso->odesc2() + " that\n"
"you kill yourself, just as he would have done!", 1);
}
else
rv = false;
return rv;
}
const ObjectP &plid(const ObjectP &obj1, const ObjectP &obj2)
{
return memq(obj1, here->robjs()) ? obj1 : obj2;
}
void plookat(const RoomP &rm)
{
RoomP here = ::here;
// go_and_look changes ::here
go_and_look(rm);
goto_(here);
}
bool put_under::operator()() const
{
if (object_action())
{
}
else if (memq("DOOR", prsi()->onames()))
{
tell("There's not enough room under this door.");
}
else
tell("You can't do that.");
return true;
}
bool rope_away(const ObjectP &rope, const RoomP &rm)
{
tro(rope, Bits::climbbit, Bits::ndescbit );
if (!rope->oroom())
{
drop_object(rope);
insert_object(rope, rm);
}
return true;
}
bool scol_obj(const ObjectP &obj, int cint, const RoomP &rm)
{
clock_int(sclin, cint);
remove_object(obj);
insert_object(obj, rm);
if (rm == sfind_room("BKBOX"))
{
tell("The ", 1, obj->odesc2(), " passes through the wall and vanishes.");
}
else
{
tell("The curtain dims slightly as the ", 1, obj->odesc2(), " passes through.");
scol_room.reset();
}
return true;
}
bool scol_through(int cint, const RoomP &rm)
{
clock_int(sclin, cint);
goto_(rm);
tell(through_desc);
room_info()();
return true;
}
bool sender::operator()() const
{
if (object_action())
{
}
else if (ObjectP prso = ::prso(); trnn(prso, Bits::villain))
{
tell("Why would you send for the ", 1, prso->odesc2(), "?");
}
else
tell("That doesn't make sends.");
return true;
}
bool slider(const ObjectP &obj)
{
if (trnn(obj, Bits::takebit))
{
if (obj == sfind_obj("VALUA") || obj == sfind_obj("EVERY"))
{
obj_funcs::valuables_c()();
}
else
{
tell("The ", 1, obj->odesc2(), " falls through the slide and is gone.");
remove_object(obj);
obj == sfind_obj("WATER") || insert_object(obj, sfind_room("CELLA"));
}
}
else
{
tell(pick_one(yuks));
}
return true;
}
bool smeller::operator()() const
{
return tell("It smells like a ", 1, ((ObjectP)prso())->odesc2(), ".");
}
bool through::operator()(ObjectP obj) const
{
RoomP here = ::here;
const RoomP &box = sfind_room("BKBOX");
RoomP scrm = scol_room;
ParseVec prsvec = ::prsvec;
ObjectP prsoo = prso();
ScolWalls m;
if (!obj && object_action())
{
}
else if (!obj &&
trnn(prsoo, Bits::vehbit) &&
perform(board(), find_verb("BOARD"), prsoo))
{
}
else if (((obj || prsoo == sfind_obj("SCOL")) && scrm) ||
here == box && prsoo == sfind_obj("WNORT") && scrm)
{
scol_active = scrm;
prsvec[1] = std::monostate();
if (obj)
{
scol_obj(obj, 0, scrm);
}
else
{
scol_through(6, scrm);
}
}
else if (here == scol_active && prsoo == find_obj((m = get_wall(here)).obj))
{
scol_room = find_room(m.rm2);
prsvec[1] = find_dir(prsoo->oadjs()[0]);
if (obj)
{
scol_obj(obj, 0, box);
}
else
{
scol_through(0, box);
}
}
else if (!obj && !trnn(prsoo, Bits::takebit))
{
if (prsoo == sfind_obj("SCOL"))
{
tell("You can't go more than part way through the curtain.");
}
else if (object_action())
{
}
else
{
tell("You hit your head against the ", 1, prsoo->odesc2(), " as you attempt this feat.");
}
}
else if (obj)
{
tell("You can't do that!");
}
else if (!prsoo->oroom())
{
tell("That would be quite a contortion.");
}
else
{
tell(pick_one(yuks));
}
return true;
}
bool untie_from::operator()() const
{
ObjectP prso = ::prso();
ObjectP prsi = ::prsi();
if ((prso == sfind_obj("ROPE") && ((flags[FlagId::dome_flag] && prsi == sfind_obj("RAILI")) || prsi == timber_tie)) ||
(prso == sfind_obj("BROPE") && btie))
{
return perform(untie(), find_verb("UNTIE"), prso);
}
else
{
return tell("It's not attached to that!");
}
}
bool wind::operator()() const
{
if (!object_action())
{
tell("You cannot wind up a ", 1, ((ObjectP)prso())->odesc2(), ".");
}
return true;
}
bool win::operator()() const
{
return tell("Naturally!");
}
bool wisher::operator()() const
{
return perform(maker(), find_verb("MAKE"), sfind_obj("WISH"));
}
bool yell::operator()() const
{
return tell("Aaaarrrrrrrrgggggggggggggghhhhhhhhhhhhhh!");
}
bool chomp::operator()() const
{
return tell("I don't know how to do that. I win in all cases!");
}
bool climb_up::operator()(direction dir, bool noobj) const
{
bool flg = noobj || (trnn(prso(), Bits::climbbit));
ParseVec pv = prsvec;
if (object_action())
{
}
else if (flg && memq(dir, here->rexits()))
{
pv[1] = dir;
pv[0] = find_verb("WALK");
walk()();
}
else if (flg)
{
tell("You can't go that way.");
}
else if (memq("WALL", ((ObjectP)prso())->onames()))
{
tell("Climbing the walls is of no avail.");
}
else
tell("Bizarre!");
return true;
}
bool climb_foo::operator()() const
{
return climb_up()(direction::Up, true);
}
bool count::operator()() const
{
const AdvP &winner = *::winner;
const ObjList &objs = winner->aobjs();
int cnt;
ObjectP prso = ::prso();
struct ObjTell
{
std::string_view oname;
std::string_view tellval;
};
static const ObjTell ots[] =
{
{ "BLESS", "Well, for one, you are playing Zork..." },
{ "LEAVE", "There are 69,105 leaves here." },
{ "BILLS", "Don't you trust me? There are 200 bills." },
{ "CANDL", "Let's see, how many objects in a pair? Don't tell me, I'll get it." },
};
bool rv = false;
for (auto& ot : ots)
{
if (prso == sfind_obj(ot.oname))
{
rv = tell(ot.tellval);
break;
}
}
if (rv)
{
// Already handled.
}
else
{
tell("You have ", 0);
if (prso == sfind_obj("MATCH"))
{
int cnt = prso->omatch() - 1;
princ(cnt);
tell(" match", 1, cnt != 1 ? "es." : ".");
}
else if (prso == sfind_obj("VALUA"))
{
// Count valuables.
numtell(cnt = std::accumulate(objs.begin(), objs.end(), 0, [](int val, const ObjectP &obj)
{
return val + (obj->otval() != 0 ? 1 : 0);
}), "valuable");
if (here == sfind_room("LROOM"))
{
tell("Your adventure has netted ", 0);
numtell(length(sfind_obj("TCASE")->ocontents()), "treasure");
}
}
else if (prso == sfind_obj("POSSE"))
{
numtell(cnt = length(objs), "possession");
}
else
{
tell("lost your mind.");
}
}
return true;
}
bool enter::operator()() const
{
ParseVec pv = prsvec;
put(pv, 1, direction::Enter);
put(pv, 0, find_verb("WALK"));
return walk()();
}
ScolWalls get_wall(const RoomP &rm)
{
for (auto &w : scol_walls)
{
if (find_room(w.rm1) == rm)
return w;
}
return ScolWalls();
}
bool pass_the_bucket(const RoomP &r, const ObjectP &b)
{
const AdvP &winner = *::winner;
ParseVecVal oldprsvec1 = prsvec[1];
prsvec[1] = std::monostate();
remove_object(b);
insert_object(b, r);
if (winner->avehicle() == b)
{
goto_(r);
room_info()();
}
prsvec[1] = oldprsvec1;
return true;
}
bool iceboom()
{
mung_room(here, icemung);
jigs_up(iceblast);
return true;
}
bool held(const ObjectP &obj)
{
const ObjectP &can = obj->ocan();
const AdvP &winner = *::winner;
return memq(obj, winner->aobjs()) || can && held(can);
}
bool knock::operator()() const
{
if (object_action())
{
}
else if (ObjectP obj = prso(); memq("DOOR", obj->onames()))
{
tell("I don't think that anybody's home.");
}
else
{
tell("Why knock on a ", 1, obj->odesc2(), "?");
}
return true;
}
bool bad_egg(const ObjectP &begg)
{
const ObjectP &egg = sfind_obj("EGG");
auto& bcana = sfind_obj("BCANA");
if (sfind_obj("GCANA")->ocan() == egg)
{
tell(bcana->odesco());
bcana->otval(1);
}
else
{
remove_object(bcana);
}
begg->otval(2);
if (egg->oroom())
insert_object(begg, here);
else if (const ObjectP &can = egg->ocan())
insert_into(can, begg);
else
take_object(begg);
remove_object(egg);
return true;
}
bool scol_clock::operator()() const
{
scol_active = sfind_room("FCHMP");
if (here == sfind_room("BKVAU"))
jigs_up(alarm_voice);
else if (here == sfind_room("BKTWI"))
{
if (!flags[FlagId::zgnome])
{
clock_int(zgnin, 5);
flags[FlagId::zgnome] = true;
}
}
return true;
}
bool zgnome_init::operator()() const
{
bool rv = false;
if (verbq("C-INT"))
{
if (here == sfind_room("BKTWI"))
{
clock_int(zglin, 12);
tell(zgnome_desc, long_tell1);
insert_object(sfind_obj("ZGNOM"), here);
rv = true;
}
}
return rv;
}
int cpnext(int rm, const ObjectP &obj)
{
auto m = memq(obj, cpwalls);
return rm + std::get<1>(**m);
}
bool cpgoto(int fx)
{
rtrz(here, RoomBit::rseenbit);
cpobjs[size_t(cphere) - 1] = here->robjs();
cphere = fx;
here->robjs() = cpobjs[size_t(fx) - 1];
perform(room_desc(), find_verb("LOOK"));
return true;
}
std::string username()
{
const char* un;
return (un = getenv("USERNAME")) ? un :
(un = getenv("USER")) ? un :
"Occupant";
}
namespace obj_funcs
{
bool canary_object::operator()() const
{
bool rv = false;
if (verbq("WIND"))
{
rv = true;
ObjectP prso = ::prso();
if (prso == sfind_obj("GCANA"))
{
const RoomP &tree = sfind_room("TREE");
if (!flags[FlagId::sing_song] && (member("FORE", here->rid()) || here == tree))
{
tell(opera);
flags[FlagId::sing_song] = true;
insert_object(sfind_obj("BAUBL"), here == tree ? sfind_room("FORE3") : here);
}
else
{
tell("The canary chirps blithely, if somewhat tinnily, for a short time.");
}
}
else
{
tell("There is an unpleasant grinding noise from inside the canary.");
}
}
return rv;
}
bool zgnome_function::operator()() const
{
ObjectP gnome = sfind_obj("ZGNOM");
ObjectP brick;
if (verbq( "GIVE", "THROW" ))
{
ObjectP prso = ::prso();
if (prso->otval() != 0)
{
tell("The gnome carefully places the ", long_tell1, prso->odesc2(), " in the\n"
"deposit box. 'Let me show you the way out,' he says, making it clear\n"
"he will be pleased to see the last of you. Then, you are momentarily\n"
"disoriented, and when you recover you are back at the Bank Entrance.");
remove_object(gnome);
remove_object(prso);
clock_disable(zglin);
goto_(sfind_room("BKENT"));
}
else if (bomb(prso))
{
remove_object(gnome);
(brick = sfind_obj("BRICK"))->oroom() || insert_object(brick, here);
clock_disable(zglin);
clock_disable(zgnin);
tell(zgnome_pop_1);
}
else
{
tell(zgnome_pop);
remove_object(prso);
}
}
else if (verbq("C-INT"))
{
if (here == sfind_room("BKTWI"))
{
tell(zgnome_bye, long_tell1);
}
remove_object(gnome);
}
else if (verbq( "KILL", "ATTAC", "POKE" ))
{
tell("The gnome says 'Well, I never...' and disappears with a snap of his\n"
"fingers, leaving you alone.");
remove_object(gnome);
clock_disable(zglin);
}
else
{
tell("The gnome appears increasingly impatient.");
}
return true;
}
bool wclif_object::operator()() const
{
if (verbq( "CLUP", "CLDN", "CLUDG" ))
{
return tell("The cliff is too steep for climbing.");
}
return false;
}
bool well_function::operator()() const
{
bool rv = true;
ObjectP prso = ::prso();
if (trnn(prso, Bits::takebit) && verbq( "THROW", "DROP", "PUT" ))
{
tell("The ", 1, prso->odesc2(), " is now sitting at the bottom of the well.");
remove_object(prso);
insert_object(prso, sfind_room("BWELL"));
}
else
rv = false;
return rv;
}
bool cretin::operator()() const
{
const AdvP &me = player();
ObjectP prsoo;
if (verbq("GIVE") && !trnn(prsoo = prso(), Bits::no_check_bit))
{
remove_object(prsoo);
me->aobjs().push_back(prsoo);
return tell("Done.");
}
else if (verbq( "KILL", "MUNG" ))
{
return jigs_up("If you insist.... Poof, you're dead!");
}
else if (verbq("TAKE"))
{
return tell("How romantic!");
}
return false;
}
bool eatme_function::operator()() const
{
bool rv = true;
RoomP here = ::here;
ObjectP c;
ObjectP prso = ::prso();
if (verbq("EAT") && prso == (c = sfind_obj("ECAKE")) && here == sfind_room("ALICE"))
{
tell("Suddenly, the room appears to have become very large.");
remove_object(c);
auto &r = sfind_room("ALISM");
trz(sfind_obj("ROBOT"), Bits::ovison);
r->robjs() = here->robjs();
for (auto &x : here->robjs())
{
x->osize(x->osize() * 64);
x->oroom(r);
}
goto_(r);
}
else
rv = false;
return rv;
}
bool cake_function::operator()() const
{
auto &rice = sfind_obj("RDICE");
auto &oice = sfind_obj("ORICE");
auto &bice = sfind_obj("BLICE");
ObjectP prso = ::prso();
bool rv = true;
if (verbq("READ"))
{
if (ObjectP prsi = ::prsi(); !empty(prsi))
{
if (prsi == sfind_obj("BOTTL"))
{
tell("The letters appear larger, but still are too small to be read.");
}
else if (prsi == sfind_obj("FLASK"))
{
tell("The icing, now visible, says '", 1,
prso == rice ? "Evaporate" : (prso == oice ? "Explode" : "Enlarge"), "'.");
}
else tell("You can't see through that!");
}
else
{
tell("The only writing legible is a capital E. The rest is too small to\n"
"be clearly visible.");
}
}
else if (verbq("EAT") && member("ALI", here->rid()))
{
if (prso == oice)
{
remove_object(prso);
iceboom();
}
else if (prso == bice)
{
remove_object(prso);
tell("The room around you seems to be getting smaller.");
if (here == sfind_room("ALISM"))
{
auto &r = sfind_room("ALICE");
tro(sfind_obj("ROBOT"), Bits::ovison);
r->robjs() = here->robjs();
trz(sfind_obj("POSTS"), Bits::ovison);
for (auto &x : here->robjs())
{
x->oroom(r);
x->osize(x->osize() / 64);
}
goto_(r);
}
else
{
jigs_up(crushed);
}
}
}
else if (verbq("THROW") && prso == oice && member("ALI", here->rid()))
{
remove_object(prso);
iceboom();
}
else if (ObjectP prsi = ::prsi(); verbq("THROW") && prso == rice && prsi == sfind_obj("POOL"))
{
remove_object(prsi);
tell("The pool of water evaporates, revealing a tin of rare spices.");
tro(sfind_obj("SAFFR"), Bits::ovison);
}
else
rv = false;
return rv;
}
bool slide_rope::operator()() const
{
bool rv = true;
if (verbq("TAKE"))
{
tell("What do you think is suspending you in midair?");
}
else if (verbq("DROP"))
{
tell("You tumble down the chute to the cellar.");
go_and_look(sfind_room("CELLA"));
}
else if (verbq( "CLDN", "CLUP", "CLUDG" ))
{
rv = false;
}
else
tell("It's not easy to play with the rope in your position.");
return rv;
}
bool brochure::operator()() const
{
bool rv = true;
auto &stamp = sfind_obj("DSTMP");
ObjectP prso = ::prso();
if (prso == stamp)
{
if (verbq("TAKE"))
{
trz(sfind_obj("BROCH"), Bits::contbit);
}
rv = false;
}
else if (verbq( "EXAMI", "LKAT", "READ" ) && prso == sfind_obj("BROCH"))