Added HasVolatileScript function to Creature and Battle.
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Deukhoofd 2020-02-23 16:17:57 +01:00
parent 4728be18b2
commit 3802587313
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
5 changed files with 9 additions and 0 deletions

View File

@ -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); }

View File

@ -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); }

View File

@ -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); }

View File

@ -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<LearnedAttack*>& GetAttacks() { return _attacks; }

View File

@ -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<Script*>* GetIterator() const { return &_scripts; }