diff options
author | Your Name <you@example.com> | 2021-05-01 15:10:54 -0400 |
---|---|---|
committer | Your Name <you@example.com> | 2021-05-01 15:10:54 -0400 |
commit | 7b5d1e3d46e94262a9c0fd3a01ab4685aea9d12d (patch) | |
tree | d9b808542216f71dbab053ad23145903e96c6401 /src/creature.h | |
parent | 5a813a75412ac9b8fadb90c9abd46dd95aee8e9b (diff) | |
download | dmtool-7b5d1e3d46e94262a9c0fd3a01ab4685aea9d12d.tar.gz dmtool-7b5d1e3d46e94262a9c0fd3a01ab4685aea9d12d.tar.bz2 dmtool-7b5d1e3d46e94262a9c0fd3a01ab4685aea9d12d.zip |
Added bash completion, amongst others
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); } |