-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweapon.cpp
101 lines (83 loc) · 2.19 KB
/
weapon.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
89
90
91
92
93
94
95
96
97
98
99
100
101
#include "weapon.h"
weapon::weapon() : item ("Fist", "Bare hands", 0) {
settype(weapontype::Fist);
setdamage(1.0);
setlevel(1);
setrange(0);
setweight(0);
setdurability(-0);
}
weapon::weapon(std::string name, std::string desc, int value,
weapontype wep, float damage, int level,
int range, int weight, int durability)
: item(name, desc, value), type_{ wep }, damage_{ damage }, level_{ level }, range_{ range }, weight_{ weight }, durability_{ durability } {
}
/*
std::string weapon::getname() const {
return name_;
} */
weapontype weapon::gettype() const {
return type_;
}
float weapon::getdamage() const {
return damage_ * (1 * ((level_ - 1) / 10));
}
int weapon::getlevel() const {
return level_;
}
int weapon::getweight() const {
return weight_;
}
int weapon::getrange() const {
return range_;
}
int weapon::getdurability() const {
return durability_;
}
//////////////////////////////////////////////////////////////////////////
/*
void weapon::setname(std::string name) {
name_ = name;
}*/
void weapon::settype(weapontype type) {
type_ = type;
}
void weapon::setdamage(float damage) {
damage_ = damage;
}
void weapon::setlevel(int level) {
level_ = level;
}
void weapon::setweight(int weight) {
weight_ = weight;
}
void weapon::setrange(int range) {
range_ = range;
}
void weapon::setdurability(int durability) {
durability_ = durability;
}
std::string weapon::tostring(){
std::string type;
switch (type_) {
case weapontype::Longsword: type = "Longsword";
break;
case weapontype::Bastardsword: type = "Bastardsword";
break;
case weapontype::Spear: type = "Spear";
break;
case weapontype::Mace: type = "Mace";
break;
case weapontype::Bow: type = "Bow";
break;
case weapontype::Staff: type = "Staff";
break;
case weapontype::Fist: type = "Fist";
break;
default: type = "Unknown";
break;
}
std::string out = "Name: " + this->getname() + "\n Description: " + this->getdescription() + "\n Value: " + std::to_string(this->getvalue()) +
"\n Type: " + type + "\n Damage: " + std::to_string(damage_) + "\n Range: " + std::to_string(range_) + "\n Weight: " + std::to_string(weight_);
return out;
}