#include "RangedWeapon.hpp" #include "Actor.hpp" #include "Bullet.hpp" RangedWeapon::RangedWeapon(Weapon::Class c, const std::string &name) : Weapon(Item::Type::RANGEDWEAPON, c, name) { } bool RangedWeapon::use(Actor &user, Actor &actor) { //TODO implement attack probability if (_charged) { actor.damage(user.stat(Actor::Stat::ATTACK) + _damage - actor.stat(Actor::Stat::DEFENCE) ); _charged = false; } return true; } bool RangedWeapon::reload(Actor &actor) { Bullet *bullet = nullptr; //TODO add bullet type std::list inventory = actor.inventory(); for (Item *item : inventory) { if (item->type == Item::Type::BULLET) { //TODO get the bullet bullet = dynamic_cast(item); break; } } if (bullet == nullptr) { return false; } if (bullet->decreaseAmount(1)) { _charged = true; return true; } return false; }