diff --git a/src/Battling/Models/Battle.cpp b/src/Battling/Models/Battle.cpp index 3641d76..a8f1338 100644 --- a/src/Battling/Models/Battle.cpp +++ b/src/Battling/Models/Battle.cpp @@ -131,3 +131,4 @@ void Battle::AddVolatileScript(const std::string& key) { void Battle::AddVolatileScript(Script* script) { return _volatile.Add(script); } void Battle::RemoveVolatileScript(const std::string& name) { _volatile.Remove(name); } void Battle::RemoveVolatileScript(Script* script) { _volatile.Remove(script->GetName()); } +void Battle::HasVolatileScript(const std::string& name) const { _volatile.Has(name); } diff --git a/src/Battling/Models/Battle.hpp b/src/Battling/Models/Battle.hpp index c9fe1f9..e6603d2 100644 --- a/src/Battling/Models/Battle.hpp +++ b/src/Battling/Models/Battle.hpp @@ -80,6 +80,7 @@ namespace CreatureLib::Battling { void AddVolatileScript(Script* script); void RemoveVolatileScript(const std::string& name); void RemoveVolatileScript(Script* script); + void HasVolatileScript(const std::string& name) const; void RegisterEventListener(EVENT_HOOK_FUNC(listener)) { this->_eventHook.RegisterListener(listener); } void TriggerEventListener(EventData* data) { this->_eventHook.TriggerEvent(data); } diff --git a/src/Battling/Models/Creature.cpp b/src/Battling/Models/Creature.cpp index 7dda176..d89cef4 100644 --- a/src/Battling/Models/Creature.cpp +++ b/src/Battling/Models/Creature.cpp @@ -198,3 +198,4 @@ void Battling::Creature::AddVolatileScript(const std::string& name) { void Battling::Creature::AddVolatileScript(Script* script) { _volatile.Add(script); } void Battling::Creature::RemoveVolatileScript(const std::string& name) { _volatile.Remove(name); } void Battling::Creature::RemoveVolatileScript(Battling::Script* script) { _volatile.Remove(script->GetName()); } +void Battling::Creature::HasVolatileScript(const std::string& name) const { _volatile.Has(name); } diff --git a/src/Battling/Models/Creature.hpp b/src/Battling/Models/Creature.hpp index 4e045a8..2df8012 100644 --- a/src/Battling/Models/Creature.hpp +++ b/src/Battling/Models/Creature.hpp @@ -120,6 +120,7 @@ namespace CreatureLib::Battling { void AddVolatileScript(Script* script); void RemoveVolatileScript(const std::string& name); void RemoveVolatileScript(Script* script); + void HasVolatileScript(const std::string& name) const; std::vector& GetAttacks() { return _attacks; } diff --git a/src/Battling/ScriptHandling/ScriptSet.hpp b/src/Battling/ScriptHandling/ScriptSet.hpp index 7055b57..503fa90 100644 --- a/src/Battling/ScriptHandling/ScriptSet.hpp +++ b/src/Battling/ScriptHandling/ScriptSet.hpp @@ -55,6 +55,11 @@ namespace CreatureLib::Battling { _lookup.clear(); } + bool Has(const std::string& key) { + auto find = _lookup.find(key); + return find != _lookup.end(); + } + size_t Count() const { return _scripts.size(); } const std::vector* GetIterator() const { return &_scripts; }