forked from miki151/keeperrl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
item.h
155 lines (121 loc) · 4.23 KB
/
item.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
/* Copyright (C) 2013-2014 Michal Brzozowski ([email protected])
This file is part of KeeperRL.
KeeperRL is free software; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
KeeperRL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program.
If not, see http://www.gnu.org/licenses/ . */
#ifndef _ITEM_H
#define _ITEM_H
#include "util.h"
#include "enums.h"
#include "unique_entity.h"
#include "renderable.h"
#include "effect_type.h"
#include "position.h"
class Level;
class Attack;
class Fire;
class ItemAttributes;
RICH_ENUM(TrapType,
BOULDER,
POISON_GAS,
ALARM,
WEB,
SURPRISE,
TERROR
);
RICH_ENUM(ItemClass,
WEAPON,
RANGED_WEAPON,
AMMO,
ARMOR,
SCROLL,
POTION,
BOOK,
AMULET,
RING,
TOOL,
OTHER,
GOLD,
FOOD,
CORPSE
);
class Item : public Renderable, public UniqueEntity<Item> {
public:
Item(const ItemAttributes&);
virtual ~Item();
static string getTrapName(TrapType);
virtual void apply(Creature*);
bool isDiscarded();
string getName(bool plural = false, bool blind = false) const;
string getTheName(bool plural = false, bool blind = false) const;
string getAName(bool plural = false, bool blind = false) const;
string getNameAndModifiers(bool plural = false, bool blind = false) const;
string getArtifactName() const;
string getShortName(bool blind = false, bool noSuffix = false) const;
string getPluralTheName(int count) const;
string getPluralTheNameAndVerb(int count, const string& verbSingle, const string& verbPlural) const;
virtual optional<EffectType> getEffectType() const;
optional<EffectType> getAttackEffect() const;
ItemClass getClass() const;
int getPrice() const;
void setShopkeeper(const Creature* shopkeeper);
const Creature* getShopkeeper() const;
optional<TrapType> getTrapType() const;
optional<CollectiveResourceId> getResourceId() const;
bool canEquip() const;
EquipmentSlot getEquipmentSlot() const;
void addModifier(ModifierType, int value);
int getModifier(ModifierType) const;
int getAttr(AttrType) const;
void tick(double time, Position);
string getApplyMsgThirdPerson(bool blind) const;
string getApplyMsgFirstPerson(bool blind) const;
string getNoSeeApplyMsg() const;
void onEquip(Creature*);
void onUnequip(Creature*);
virtual void onEquipSpecial(Creature*) {}
virtual void onUnequipSpecial(Creature*) {}
virtual void setOnFire(double amount, Position);
double getFireSize() const;
void onHitSquareMessage(Position, int numItems);
void onHitCreature(Creature* c, const Attack& attack, int numItems);
double getApplyTime() const;
double getWeight() const;
string getDescription() const;
AttackType getAttackType() const;
bool isWieldedTwoHanded() const;
int getMinStrength() const;
static ItemPredicate effectPredicate(EffectType);
static ItemPredicate classPredicate(ItemClass);
static ItemPredicate classPredicate(vector<ItemClass>);
static ItemPredicate namePredicate(const string& name);
static vector<pair<string, vector<Item*>>> stackItems(vector<Item*>,
function<string(const Item*)> addSuffix = [](const Item*) { return ""; });
struct CorpseInfo {
UniqueEntity<Creature>::Id victim;
bool canBeRevived;
bool hasHead;
bool isSkeleton;
template <class Archive>
void serialize(Archive& ar, const unsigned int version);
};
virtual optional<CorpseInfo> getCorpseInfo() const { return none; }
SERIALIZATION_DECL(Item);
protected:
virtual void specialTick(double time, Position) {}
void setName(const string& name);
bool SERIAL(discarded) = false;
private:
string getModifiers(bool shorten = false) const;
string getVisibleName(bool plural) const;
string getBlindName(bool plural) const;
HeapAllocated<ItemAttributes> SERIAL(attributes);
const Creature* SERIAL(shopkeeper) = nullptr;
HeapAllocated<Fire> SERIAL(fire);
};
#endif