#include "Weapon.hpp" #include "MeleeWeapon.hpp" #include "Actor.hpp" #include #include MeleeWeapon::MeleeWeapon(Weapon::Class weaponClass, const std::string &name, bool throwable) : Weapon(Item::Type::MELEEWEAPON, weaponClass, name), _throwable(throwable) { if (!(weaponClass == Weapon::Class::SWORD || weaponClass == Weapon::Class::AXE || weaponClass == Weapon::Class::LANCE)) { throw std::invalid_argument("Invalid class type for MeleeWeapon"); } } bool MeleeWeapon::use(Actor &user, Actor &actor) { //TODO implements attack probability //TODO balance advantages int bonus = 0; MeleeWeapon *userWeapon = dynamic_cast(user.weapon()); // MeleeWeapon *actorWeapon = dynamic_cast(actor.weapon()); if (userWeapon == nullptr) { return false; } // if (user.skill(userWeapon->weaponClass) <= _requiredLevel) { // return false; // } /* if (actorWeapon != nullptr) { switch (userWeapon->weaponType) { case MeleeWeapon::Type::AXE: switch (actorWeapon->weaponType) { 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 (actorWeapon->weaponType) { 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 (actorWeapon->weaponType) { case MeleeWeapon::Type::AXE: bonus = 10; break; case MeleeWeapon::Type::LANCE: bonus = -10; break; case MeleeWeapon::Type::SWORD: bonus = 0; break; } break; } } */ actor.damage(_damage + user.stat(Actor::Stat::ATTACK) - actor.stat(Actor::Stat::DEFENCE) + bonus ); return true; }