diff options
Diffstat (limited to 'src/creature.h')
-rw-r--r-- | src/creature.h | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/creature.h b/src/creature.h index c3ce5ae..e89978e 100644 --- a/src/creature.h +++ b/src/creature.h @@ -8,6 +8,8 @@ namespace entry { class Feature; class Item; + class Weapon; + class Attack; } typedef nlohmann::json json; @@ -20,7 +22,7 @@ namespace creature { dmgType(const json& data) : type(data["type"]), qualifiers(data["qualifiers"]) {} std::string type; std::vector<std::string> qualifiers; - operator string() const { + std::string getText() const { if(qualifiers.empty()) { return type; } @@ -121,15 +123,9 @@ namespace creature { }; - // Convenience function to get any instances of T (subclass of Item) in the inventory - template<typename T> std::vector<std::shared_ptr<T>> getItems(const Creature& c) { - std::vector<std::shared_ptr<T>> Ts; - for(auto item : c.getInventory()) { - std::shared_ptr<T> t = dynamic_pointer_cast<T>(item); - if(t) { - Ts.push_back(t); - } - } - return Ts; - } + // Helper function to get all attacks (weapons and pseudo-weapons included) + std::vector<std::shared_ptr<entry::Weapon>> getAttacks(const Creature& c); + + // Helper function to get the best ability for this creature (chooses arbitrarily in case of ties) + rules::Ability getBestAbility(const std::vector<rules::Ability>& abilities, const Creature& c); } |