aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/cpp/RangedWeapon.cpp
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2018-02-25 21:11:43 +0100
committerNao Pross <naopross@thearcway.org>2018-02-25 21:11:43 +0100
commit20b958c69451dd8251a8899cf7264d5c92ed7c60 (patch)
tree440ec68a189efdf42a21a9d621b6de2c04305fb5 /src/main/cpp/RangedWeapon.cpp
parentUpdate CMakeLists and Makefile (diff)
downloadSubconscious-old-20b958c69451dd8251a8899cf7264d5c92ed7c60.tar.gz
Subconscious-old-20b958c69451dd8251a8899cf7264d5c92ed7c60.zip
Better management of stats and skill of actors and items
Diffstat (limited to 'src/main/cpp/RangedWeapon.cpp')
-rw-r--r--src/main/cpp/RangedWeapon.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/main/cpp/RangedWeapon.cpp b/src/main/cpp/RangedWeapon.cpp
index 6f24666..13d4c70 100644
--- a/src/main/cpp/RangedWeapon.cpp
+++ b/src/main/cpp/RangedWeapon.cpp
@@ -2,8 +2,8 @@
#include "Actor.hpp"
#include "Bullet.hpp"
-RangedWeapon::RangedWeapon(const std::string &name)
-: Weapon(Item::Type::RANGEDWEAPON, name)
+RangedWeapon::RangedWeapon(Weapon::Class c, const std::string &name)
+: Weapon(Item::Type::RANGEDWEAPON, c, name)
{
}
@@ -11,7 +11,11 @@ bool RangedWeapon::use(Actor &user, Actor &actor)
{
//TODO implement attack probability
if (_charged) {
- actor.damage(user.attack() + _damage - actor.defence());
+ actor.damage(user.stat(Actor::Stat::ATTACK)
+ + _damage
+ - actor.stat(Actor::Stat::DEFENCE)
+ );
+
_charged = false;
}
@@ -20,26 +24,26 @@ bool RangedWeapon::use(Actor &user, Actor &actor)
bool RangedWeapon::reload(Actor &actor)
{
+ Bullet *bullet = nullptr;
+
//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);
+ bullet = dynamic_cast<Bullet*>(item);
break;
}
}
- // TODO remove
- return true;
+ if (bullet == nullptr) {
+ return false;
+ }
- /*
if (bullet->decreaseAmount(1)) {
_charged = true;
return true;
- } else {
- return false;
}
- */
+ return false;
}