-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitem.cpp
56 lines (44 loc) · 1.05 KB
/
item.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
#include "item.h"
#include "entity.h"
// return the item's name
std::string Item::GetName() {
return name_;
}
// return its weight
float Item::GetWeight() {
return weight_;
}
// return its value
float Item::GetValue() {
return value_;
}
// return a new clone of this Item
Item* Item::Clone() {
return new Item(name_, weight_, value_);
}
// methods for EquippableItem
// get the user of this equippable item
Entity* EquippableItem::GetUser() {
return user_;
}
// get the slot that this item is relevant to
int EquippableItem::GetSlot() {
return slot_;
}
// get the stat bonuses provided by this item
std::array<int, 4> EquippableItem::GetBonuses() {
return bonuses_;
}
// set the current user of this item
void EquippableItem::SetUser(Entity* user) {
user_ = user;
}
// HealingItem methods
// heal this item's user
void HealingItem::Consume(Entity* user) {
user->Heal(power_);
}
// return a new clone of this HealingItem
HealingItem* HealingItem::Clone() {
return new HealingItem(GetName(), GetWeight(), GetValue(), power_);
}