2019-10-29 10:19:25 +00:00
|
|
|
#ifndef CREATURELIB_ATTACKTURNCHOICE_HPP
|
|
|
|
#define CREATURELIB_ATTACKTURNCHOICE_HPP
|
|
|
|
|
2020-03-12 10:15:00 +00:00
|
|
|
#include "../Models/Battle.hpp"
|
2019-12-05 08:53:48 +00:00
|
|
|
#include "../Models/CreatureIndex.hpp"
|
2019-10-29 10:19:25 +00:00
|
|
|
#include "../Models/LearnedAttack.hpp"
|
2020-03-12 10:15:00 +00:00
|
|
|
#include "../ScriptHandling/ScriptCategory.hpp"
|
2019-11-28 11:55:22 +00:00
|
|
|
#include "BaseTurnChoice.hpp"
|
2019-10-29 10:19:25 +00:00
|
|
|
|
2019-11-28 11:55:22 +00:00
|
|
|
namespace CreatureLib::Battling {
|
2019-10-29 10:19:25 +00:00
|
|
|
class AttackTurnChoice : public BaseTurnChoice {
|
|
|
|
LearnedAttack* _attack;
|
2019-12-05 08:53:48 +00:00
|
|
|
CreatureIndex _target;
|
2019-12-05 11:56:41 +00:00
|
|
|
Script* _attackScript = nullptr;
|
2019-11-28 11:55:22 +00:00
|
|
|
|
2020-03-12 10:15:00 +00:00
|
|
|
void ResolveScript() {
|
|
|
|
if (_attackScript != nullptr)
|
|
|
|
return;
|
|
|
|
auto user = GetUser();
|
|
|
|
if (user == nullptr)
|
|
|
|
return;
|
|
|
|
auto battle = user->GetBattle();
|
|
|
|
if (battle != nullptr) {
|
|
|
|
auto library = battle->GetLibrary();
|
|
|
|
_attackScript = library->LoadScript(ScriptCategory::Attack, _attack->GetAttack()->GetName());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-29 10:19:25 +00:00
|
|
|
public:
|
2019-12-05 08:53:48 +00:00
|
|
|
AttackTurnChoice(Creature* user, LearnedAttack* attack, const CreatureIndex& target)
|
2020-03-12 10:15:00 +00:00
|
|
|
: BaseTurnChoice(user), _attack(attack), _target(target) {
|
2020-03-22 12:42:26 +00:00
|
|
|
AssertNotNull(attack)
|
2020-03-12 10:15:00 +00:00
|
|
|
ResolveScript();
|
|
|
|
}
|
|
|
|
AttackTurnChoice(Creature* user, LearnedAttack* attack, const CreatureIndex& target, Script* script)
|
|
|
|
: BaseTurnChoice(user), _attack(attack), _target(target), _attackScript(script) {}
|
2019-10-29 10:19:25 +00:00
|
|
|
|
2019-11-28 11:55:22 +00:00
|
|
|
inline LearnedAttack* GetAttack() const { return _attack; }
|
2019-10-31 11:02:23 +00:00
|
|
|
|
2019-11-28 11:55:22 +00:00
|
|
|
TurnChoiceKind GetKind() const override { return TurnChoiceKind ::Attack; }
|
2019-10-31 11:31:31 +00:00
|
|
|
|
2019-11-28 11:55:22 +00:00
|
|
|
int8_t GetPriority() const {
|
|
|
|
// HOOK: Change priority
|
2019-10-31 11:31:31 +00:00
|
|
|
return _attack->GetAttack()->GetPriority();
|
|
|
|
}
|
2019-11-02 12:57:43 +00:00
|
|
|
|
2019-12-05 08:53:48 +00:00
|
|
|
const CreatureIndex& GetTarget() const { return _target; }
|
2019-11-10 13:32:05 +00:00
|
|
|
|
2020-03-11 11:22:13 +00:00
|
|
|
Script* GetAttackScript() const { return _attackScript; }
|
2019-11-24 10:06:51 +00:00
|
|
|
|
2019-11-10 16:08:42 +00:00
|
|
|
protected:
|
2020-03-22 18:21:40 +00:00
|
|
|
void GetActiveScripts(Arbutils::Collections::List<ScriptWrapper>& scripts) override {
|
|
|
|
scripts.Append(&_attackScript);
|
2019-11-10 16:08:42 +00:00
|
|
|
GetUser()->GetActiveScripts(scripts);
|
2019-11-10 13:32:05 +00:00
|
|
|
}
|
2019-10-29 10:19:25 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-11-28 11:55:22 +00:00
|
|
|
#endif // CREATURELIB_ATTACKTURNCHOICE_HPP
|