#ifndef CREATURELIB_ATTACKTURNCHOICE_HPP #define CREATURELIB_ATTACKTURNCHOICE_HPP #include "../Models/Battle.hpp" #include "../Models/CreatureIndex.hpp" #include "../Models/LearnedAttack.hpp" #include "../ScriptHandling/ScriptCategory.hpp" #include "BaseTurnChoice.hpp" namespace CreatureLib::Battling { class AttackTurnChoice : public BaseTurnChoice { LearnedAttack* _attack; CreatureIndex _target; Script* _attackScript = nullptr; void ResolveScript() { if (_attackScript != nullptr) return; auto user = GetUser(); if (user == nullptr) return; auto battle = user->GetBattle(); if (battle != nullptr) { if (_attack->GetAttack()->HasSecondaryEffect()) { auto library = battle->GetLibrary(); _attackScript = library->LoadScript(ScriptCategory::Attack, _attack->GetAttack()->GetSecondaryEffect().GetEffectName()); } } } public: AttackTurnChoice(Creature* user, LearnedAttack* attack, const CreatureIndex& target) : BaseTurnChoice(user), _attack(attack), _target(target) { AssertNotNull(attack) ResolveScript(); } AttackTurnChoice(Creature* user, LearnedAttack* attack, const CreatureIndex& target, Script* script) noexcept : BaseTurnChoice(user), _attack(attack), _target(target), _attackScript(script) {} inline LearnedAttack* GetAttack() const noexcept { return _attack; } TurnChoiceKind GetKind() const noexcept override { return TurnChoiceKind ::Attack; } int8_t GetPriority() const { // HOOK: Change priority return _attack->GetAttack()->GetPriority(); } const CreatureIndex& GetTarget() const noexcept { return _target; } Script* GetAttackScript() const noexcept { return _attackScript; } protected: void GetActiveScripts(Arbutils::Collections::List& scripts) override { scripts.Append(&_attackScript); GetUser()->GetActiveScripts(scripts); } }; } #endif // CREATURELIB_ATTACKTURNCHOICE_HPP