-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitems.cpp
More file actions
73 lines (54 loc) · 1.12 KB
/
items.cpp
File metadata and controls
73 lines (54 loc) · 1.12 KB
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
#include "items.h"
#include <cstring>
Item::Item(const char* nam, const int val, const int req) {
name = new char[strlen(nam)+1];
strcpy(name,nam);
price = val;
levelReq = req;
}
char *Item::getName() const {
return name;
}
int Item::getPrice() const {
return price;
}
int Item::getLevelReq() const {
return levelReq;
}
Item::~Item() {
delete[] name;
}
Weapon::Weapon(const char* nam,const int val, const int req,const int dmg, HandType typ) : Item(nam,val,req) {
damage = dmg;
type = typ;
}
int Weapon::use() {
return damage;
}
Weapon::~Weapon() {
}
Armor::Armor(const char* nam,const int val, const int req,const int def) : Item(nam,val,req) {
defense = def;
}
int Armor::use() {
return defense;
}
Armor::~Armor() {
}
Potion::Potion(const char* nam,const int val, const int req, PotionType tp, const int st) : Item(nam,val,req) {
stat = st;
type = tp;
available = true;
}
PotionType Potion::getType() const {
return type;
}
bool Potion::isUsable() {
return available;
}
int Potion::use() {
available = false;
return stat;
}
Potion::~Potion() {
}