-
Notifications
You must be signed in to change notification settings - Fork 10
/
defs.cpp
88 lines (73 loc) · 1.57 KB
/
defs.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
#include "stdafx.h"
#include <algorithm>
#include <sstream>
#include "defs.h"
#include "ZorkException.h"
#include "object.h"
#include "room.h"
#include "dung.h"
#include "parser.h"
int no_tell = 0;
int eg_score = 0;
PhraseP make_phrase(const WordP &p, const ObjectP &op)
{
return std::make_shared<phrase>(p, op);
}
void prin1(int val)
{
tty << val;
}
bool apply_random(const rapplic& fcn)
{
return fcn(Rarg());
}
ExitFuncVal apply_random(ex_rapplic fcn)
{
return fcn();
}
bool apply_random(hackfn fcn, const HackP &demon)
{
return fcn(demon);
}
bool describable(const ObjectP &obj)
{
return !trnn(obj, Bits::ndescbit);
}
bool see_inside(const ObjectP &op)
{
return trnn(op, Bits::ovison) && (trnn(op, Bits::transbit) || trnn(op, Bits::openbit));
}
bool apply_object(const ObjectP &op)
{
bool rv;
auto &fn = op->oaction();
if (rv = (fn != nullptr))
rv = fn(Rarg());
return rv;
}
bool trnn_bits(const ObjectP& op, const Flags<Bits, numbits>& bits_to_check)
{
return (op->oflags() & bits_to_check).any();
}
bool strnn(const SyntaxP &syn, SyntaxBits b)
{
return syn->sflags.test(b);
}
bool gtrnn(const RoomP &p, Bits b)
{
return std::find(p->rglobal().begin(), p->rglobal().end(), b) != p->rglobal().end();
}
void trc(const ObjectP &op, Bits b)
{
op->oflags()[b].flip();
}
void rtrc(const RoomP &p, RoomBit b)
{
p->rbits()[b].flip();
}
bool flaming(const ObjectP &obj)
{
// True if all of the light-giving bits are set.
auto& f = obj->oflags();
return f[Bits::flamebit] && f[Bits::onbit] && f[Bits::lightbit];
}