Initialize script with move effect parameters.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-04-10 17:18:19 +02:00
parent 49e0f00237
commit 1537a5f316
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
2 changed files with 7 additions and 3 deletions

View File

@ -1,8 +1,8 @@
#ifndef CREATURELIB_SCRIPT_HPP #ifndef CREATURELIB_SCRIPT_HPP
#define CREATURELIB_SCRIPT_HPP #define CREATURELIB_SCRIPT_HPP
#include <Arbutils/Collections/List.hpp>
#include <Arbutils/ConstString.hpp> #include <Arbutils/ConstString.hpp>
#include <any>
#include <string> #include <string>
#include <utility> #include <utility>
#include <vector> #include <vector>
@ -25,6 +25,7 @@ namespace CreatureLib::Battling {
virtual const ConstString& GetName() const noexcept = 0; virtual const ConstString& GetName() const noexcept = 0;
virtual void OnInitialize(const Arbutils::Collections::List<void*>& parameters){};
virtual void OnBeforeTurn(const BaseTurnChoice* choice){}; virtual void OnBeforeTurn(const BaseTurnChoice* choice){};
virtual void ChangeAttack(AttackTurnChoice* choice, ConstString* outAttack){}; virtual void ChangeAttack(AttackTurnChoice* choice, ConstString* outAttack){};

View File

@ -23,8 +23,11 @@ namespace CreatureLib::Battling {
if (battle != nullptr) { if (battle != nullptr) {
if (_attack->GetAttack()->HasSecondaryEffect()) { if (_attack->GetAttack()->HasSecondaryEffect()) {
auto library = battle->GetLibrary(); auto library = battle->GetLibrary();
_attackScript = library->LoadScript(ScriptCategory::Attack, auto& effect = _attack->GetAttack()->GetSecondaryEffect();
_attack->GetAttack()->GetSecondaryEffect().GetEffectName()); _attackScript = library->LoadScript(ScriptCategory::Attack, effect.GetEffectName());
if (_attackScript != nullptr) {
_attackScript->OnInitialize(effect.GetParameters());
}
} }
} }
} }