diff options
author | mafaldo <mafaldo@heavyhammer.home> | 2018-02-17 00:29:32 +0100 |
---|---|---|
committer | mafaldo <mafaldo@heavyhammer.home> | 2018-02-17 00:29:32 +0100 |
commit | af3e76c5ee367ceffb78fa4a8ffc0eadf90e5de3 (patch) | |
tree | 24dcdaa94c20211974fca97e41647ff0dec31923 /src/main/cpp/MeleeWeapon.cpp | |
parent | Add cpack directive and update README (diff) | |
download | Subconscious-old-af3e76c5ee367ceffb78fa4a8ffc0eadf90e5de3.tar.gz Subconscious-old-af3e76c5ee367ceffb78fa4a8ffc0eadf90e5de3.zip |
add Item type, use for MeleeWeapon
Diffstat (limited to 'src/main/cpp/MeleeWeapon.cpp')
-rw-r--r-- | src/main/cpp/MeleeWeapon.cpp | 64 |
1 files changed, 60 insertions, 4 deletions
diff --git a/src/main/cpp/MeleeWeapon.cpp b/src/main/cpp/MeleeWeapon.cpp index 92c7632..8c7ffce 100644 --- a/src/main/cpp/MeleeWeapon.cpp +++ b/src/main/cpp/MeleeWeapon.cpp @@ -1,15 +1,71 @@ +#include "Weapon.hpp" #include "MeleeWeapon.hpp" #include "Actor.hpp" #include <string> -MeleeWeapon::MeleeWeapon(Type t, const std::string &name) -: Weapon(name), type(t) +MeleeWeapon::MeleeWeapon(Type t, const std::string &name, bool throwable) +: Weapon(Item::Type::MELEEWEAPON, name), type(t), _throwable(throwable) { } bool MeleeWeapon::use(Actor &user, Actor &actor) { - //TODO implement attack probability - //actor.damage(_damage); + //TODO implements attack probability + //TODO balance advantages + MeleeWeapon* weapon = dynamic_cast <MeleeWeapon*> (user.weapon()); + int bonus; + + if (MeleeWeapon* enemyWeapon = dynamic_cast <MeleeWeapon*> (actor.weapon())) { + switch (weapon->type) { + case MeleeWeapon::Type::AXE: + switch (enemyWeapon->type) { + case MeleeWeapon::Type::AXE: + bonus = 0; + break; + case MeleeWeapon::Type::LANCE: + bonus = 10; + break; + case MeleeWeapon::Type::SWORD: + bonus = -10; + break; + } + break; + case MeleeWeapon::Type::LANCE: + switch (enemyWeapon->type) { + case MeleeWeapon::Type::AXE: + bonus = -10; + break; + case MeleeWeapon::Type::LANCE: + bonus = 0; + break; + case MeleeWeapon::Type::SWORD: + bonus = 10; + break; + } + break; + case MeleeWeapon::Type::SWORD: + switch (enemyWeapon->type) { + case MeleeWeapon::Type::AXE: + bonus = 10; + break; + case MeleeWeapon::Type::LANCE: + bonus = -10; + break; + case MeleeWeapon::Type::SWORD: + bonus = 0; + break; + } + break; + } + } else { + bonus = 0; + } + + if (actor.levelAxe() <= _requiredLevel) { + actor.damage(_damage + user.attack() - actor.defence() + bonus); + return true; + } else { + return false; + } } |