From 98ac59a9400bcfde2dab1dbfd29d7a5d759ab2f8 Mon Sep 17 00:00:00 2001 From: Vincent Stumpf Date: Sat, 17 Jun 2023 02:00:01 +0000 Subject: [PATCH] change to oop --- src/map/skills/skill.hpp | 22 +++------------------- src/map/skills/swordsman/bash.hpp | 6 ++---- src/map/skills/swordsman/provoke.hpp | 3 +-- 3 files changed, 6 insertions(+), 25 deletions(-) diff --git a/src/map/skills/skill.hpp b/src/map/skills/skill.hpp index 38cb7700e2..a191b21718 100644 --- a/src/map/skills/skill.hpp +++ b/src/map/skills/skill.hpp @@ -12,18 +12,11 @@ constexpr int MAX_SKILL_LEVEL = 13; -template class Skill { public: - int castend_damage_id() const { - return as_underlying().castendDamageId(); - }; - int castend_nodamage_id() const { - return as_underlying().castendNoDamageId(); - }; - int castend_pos2() const { - return as_underlying().castendPos2(); - }; + virtual int castendDamageId() const; + virtual int castendNodamageId() const; + virtual int castendPos2() const; uint16_t getSkillID() const { return nameid; @@ -32,20 +25,11 @@ public: protected: explicit Skill(e_skill skillid) : nameid(static_cast(skillid)) {}; private: - friend T; uint16_t nameid; std::string name; std::string desc; std::array range; - - inline T& as_underlying() { - return static_cast(*this); - } - - inline const T& as_underlying() const { - return static_cast(*this); - } }; diff --git a/src/map/skills/swordsman/bash.hpp b/src/map/skills/swordsman/bash.hpp index fcbd4e0b7c..37cc672779 100644 --- a/src/map/skills/swordsman/bash.hpp +++ b/src/map/skills/swordsman/bash.hpp @@ -5,16 +5,14 @@ #include "../skills.hpp" -class Bash : public Skill { +class Bash : public Skill { public: int castendDamageId() const { - return 0; + skill_attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); }; Bash() : Skill(e_skill::SM_BASH) {}; -private: - friend class Skill; }; #endif // SKILLS_SWORDSMAN_BASH_HPP diff --git a/src/map/skills/swordsman/provoke.hpp b/src/map/skills/swordsman/provoke.hpp index bb4e43db3a..3503728817 100644 --- a/src/map/skills/swordsman/provoke.hpp +++ b/src/map/skills/swordsman/provoke.hpp @@ -4,7 +4,7 @@ #include "../skill.hpp" -class Provoke : public Skill { +class Provoke : public Skill { public: int castendNoDamageId() const { return 0; @@ -13,7 +13,6 @@ public: Provoke() : Skill(e_skill::SM_PROVOKE) {}; private: - friend class Skill; }; #endif // SKILLS_SWORDSMAN_PROVOKE_HPP