-
Notifications
You must be signed in to change notification settings - Fork 10
/
util.h
45 lines (38 loc) · 1.51 KB
/
util.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
#pragma once
#include <assert.h>
#ifdef _MSC_VER
#include <crtdbg.h>
#endif
#if !defined(_ASSERT)
#define _ASSERT assert
#endif
#include "room.h"
#include "rooms.h"
extern bool always_lit;
template <typename T>
const typename T::value_type &pick_one(const T &items)
{
size_t idx = rand() % items.size();
return items[idx];
}
// Returns a new list with the specified object removed.
ObjList splice_out(const ObjectP &op, const ObjList &al);
ObjList &splice_out_in_place(const ObjectP& op, ObjList& al);
bool remove_object(const ObjectP &obj, const AdvP &winner = *::winner);
bool insert_object(const ObjectP &obj, const RoomP &room);
void insert_into(const ObjectP &cnt, const ObjectP &obj);
void remove_from(const ObjectP &cnt, const ObjectP &obj);
void take_object(const ObjectP &obj, const AdvP &winner = *::winner);
void drop_object(const ObjectP &obj, const AdvP &winner = *::winner);
bool drop_if(const ObjectP &obj, const AdvP &winner = *::winner);
const ObjectP &snarf_object(const ObjectP &who, const ObjectP &what);
const HackP &get_demon(const char *id);
bool in_room(const ObjectP &obj, const RoomP &here = ::here);
bool hackable(const ObjectP &obj, const RoomP &rm);
bool lfcn(const ObjList &l);
bool lit(const RoomP &rm);
bool prob(int goodluck, int badluck = -1);
bool perform(rapplic fcn, const VerbP &vb, const ObjectP &obj1 = ObjectP(), const ObjectP &obj2 = ObjectP());
ObjList rob_adv(const AdvP &win, ObjList newlist);
ObjList rob_room(const RoomP &rm, ObjList newlist, int prob);
bool yes_no(bool no_is_bad = false);