#include "Weapon.hpp" #include "MeleeWeapon.hpp" #include "Actor.hpp" #include 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 implements attack probability //TODO balance advantages MeleeWeapon* weapon = dynamic_cast (user.weapon()); int bonus; if (MeleeWeapon* enemyWeapon = dynamic_cast (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; } }