-
Notifications
You must be signed in to change notification settings - Fork 0
/
arsenal.cpp
52 lines (39 loc) · 881 Bytes
/
arsenal.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
#include "arsenal.h"
void arsenal::free() {
for (auto _arg : _arsenal)
delete[] _arg;
delete[] curr;
}
arsenal::arsenal() {
base* _base = new base();
this->addWeapon(_base);
this->curr = nullptr;
}
void arsenal::setWeapon(int index) {
this->curr = _arsenal[index]->clone();
this->_arsenal[index]->use();
}
int arsenal::size() const {
return this->_arsenal.Size();
}
int arsenal::attack() const {
return curr->getDamage();
}
void arsenal::showArsenal() const {
int index = 0;
std::cout << std::endl;
for (auto _arg : _arsenal) {
std::cout << index++ << ": ";
_arg->represent();
std::cout << std::endl;
}
}
void arsenal::addWeapon(weapon* toAdd) {
_arsenal.push_back(toAdd->clone());
}
bool arsenal::isUsed(int index) const {
return _arsenal[index]->isUsed();
}
arsenal::~arsenal() {
free();
}