-
Notifications
You must be signed in to change notification settings - Fork 11
/
rooms.h
189 lines (170 loc) · 5.22 KB
/
rooms.h
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
#pragma once
#include <string>
#include <optional>
#include <random>
#include <fstream>
#include "defs.h"
#include "funcs.h"
#include "room.h"
// This exception is thrown when the user has quit or restart.
// This attempts to mimic the behavior of the QUIT MDL function,
// which is just an immediate exit of the running application.
// (Probably exit() would do the same thing, but I hate exit(). :-) )
class ExitException : public std::exception {
public:
ExitException(bool restart_flag) : restart(restart_flag) {}
bool restart_flag() const { return restart; };
private:
bool restart;
};
// Current location
extern RoomP here;
extern rapplic dead_player;
extern direction fromdir;
extern const AdvP *winner;
extern int raw_score;
extern int moves;
extern std::list<HackP> demons;
extern std::unique_ptr<std::ofstream> script_channel;
const CEventP &clock_int(const CEventP &cev, std::optional<int> num = std::optional<int>(), bool flag = false);
bool clock_disable(const CEventP &cev);
bool clock_enable(const CEventP &cev);
struct ParseCont
{
ParseCont() : s1b(" "), s2b(" "), i1(0)
{
s1 = SIterator(s1b, s1b.end());
s2 = SIterator(s2b);
}
SIterator s1;
SIterator s2;
int i1;
private:
std::string s1b;
std::string s2b;
};
typedef std::shared_ptr<ParseCont> ParseContP;
const int lexsize = 30;
typedef std::array<ParseContP, lexsize> ParseContV;
extern Iterator<ParseContV> parse_cont;
std::string unspeakable_code();
const char *remarkably_disgusting_code();
void start(std::string_view &rm, std::string_view st = std::string());
void save_it(bool start = true);
void contin(bool foo = false);
bool goto_(const RoomP &rm, const AdvP &win = *winner);
bool room_info(std::optional<int> full);
inline bool room_info() { return room_info(std::optional<int>()); }
bool object_action();
bool long_desc_obj(const ObjectP &obj, int full = 1, bool fullq = false, bool first = false);
bool command();
bool find();
bool find_frob(const ObjList &objl, const std::string &str1, const std::string &str2, const std::string &str3);
bool kill_cints();
bool invent(const AdvP &win);
inline bool invent() { return invent(*winner); }
void print_contents(const ObjList &olst);
void print_cont(const ObjectP &obj, const ObjectP &av, const ObjectP &win, SIterator indent, bool cse = true);
bool quit();
void rdcom(Iterator<ParseContV> ivec = Iterator<ParseContV>());
// recout's quit parameter can be a boolean or a string. If it's a string,
// print that instead of Quit or Died.
typedef std::variant<bool, std::string> RecOutQuit;
void record(int score, int moves, int deaths, RecOutQuit quit, const RoomP &loc);
inline void record(int score, int movs, int deaths, const char *quit, RoomP loc)
{
record(score, movs, deaths, std::string(quit), loc);
}
void recout(int score, int moves, int deaths, const RecOutQuit &quit, const RoomP &loc);
bool room_obj();
bool room_name();
bool room_room();
void score_room(const RoomP &rm);
void mung_room(RoomP rm, std::string_view str);
inline bool room_desc() { return room_info(3); }
bool jigs_up(std::string_view desc, bool player = false);
void score_upd(int num);
void score_bless();
bool nogo(const std::string &str, direction dir);
int weight(const ObjList &objl);
void score_obj(const ObjectP &obj);
int score(bool ask);
inline bool score() { score(false); return true; }
const RoomP &get_door_room(const RoomP &rm, const DoorExitPtr &leavings);
bool takefn2(bool take_);
inline bool takefn() { return takefn2(true); }
bool backer();
bool board();
bool brief();
bool bugger(bool feech);
inline bool bugger() { return bugger(false); }
bool clock_demon(const HackP &hack);
bool closer();
bool do_restore();
bool do_save();
bool do_script();
bool do_unscript();
bool do_unscript(bool verbose);
bool doc();
bool dropper();
bool end_game_herald();
bool feech();
bool finish(const RecOutQuit &ask);
inline bool finish(const char *ask) { return finish(std::string(ask)); }
inline bool finish(bool ask) { return finish(RecOutQuit(ask)); }
inline bool finish() { return finish(true); }
bool frob_lots(Iterator<ObjVector> uv);
bool help();
bool info();
bool lamp_off();
bool lamp_on();
bool move();
bool no_obj_hack();
bool opener();
bool play_time(bool loser);
inline bool play_time() {
return play_time(true);
}
bool putter(bool objact);
inline bool putter() {
return putter(true);
}
inline bool putter_noarg() { return putter(true); }
bool restart();
bool superbrief();
bool unboard();
bool valchk(const std::any &flg, const ObjectP &obj, Iterator<ObjVector> allbut);
bool verbose();
bool version();
bool wait(int turns);
inline bool wait() { return wait(3); }
bool walk();
namespace obj_funcs
{
bool valuables_c(std::any everything, const Iterator<ObjVector> &allbut);
}
inline bool rtrnn(const RoomP &p, Bits bits)
{
return p->rbits().test(bits);
}
// Returns true if any bit in the room bits is set.
template <typename... Args>
bool rtrnn(const RoomP &p, Bits first, Args... bits)
{
if (rtrnn(p, first))
return true;
return rtrnn(p, bits...);
}
template <typename T>
bool rtrz(const RoomP &p, T bit)
{
p->rbits().reset(bit);
return true;
}
template <typename T, typename... Args>
bool rtrz(const RoomP &p, T first, Args... bits)
{
rtrz(p, first);
rtrz(p, bits...);
return true;
}