blob: 21feae4d575e3f078182de28a2673a13d0a1ff73 (
plain)
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
|
#include "RangedWeapon.hpp"
#include "Actor.hpp"
#include "Bullet.hpp"
RangedWeapon::RangedWeapon(const std::string &name)
: Weapon(Item::Type::RANGEDWEAPON, name)
{
}
bool RangedWeapon::use(Actor &user, Actor &actor)
{
//TODO implement attack probability
if (_charged) {
actor.damage(user.attack() + _damage - actor.defence());
_charged = false;
}
}
bool RangedWeapon::reload(Actor &actor)
{
//TODO add bullet type
std::list<Item*> inventory = actor.inventory();
for (Item* item : inventory) {
if (item->type == Item::Type::BULLET) {
//TODO get the bullet
//Bullet* bullet = dynamic_cast <Bullet*> (item);
break;
}
}
/*
if (bullet->decreaseAmount(1)) {
_charged = true;
return true;
} else {
return false;
}
*/
}
|