Support for attack when other attacks can't be used in MiscLibrary.
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
#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 {
|
||||
@@ -11,9 +13,26 @@ namespace CreatureLib::Battling {
|
||||
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) {
|
||||
auto library = battle->GetLibrary();
|
||||
_attackScript = library->LoadScript(ScriptCategory::Attack, _attack->GetAttack()->GetName());
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
AttackTurnChoice(Creature* user, LearnedAttack* attack, const CreatureIndex& target)
|
||||
: BaseTurnChoice(user), _attack(attack), _target(target) {}
|
||||
: BaseTurnChoice(user), _attack(attack), _target(target) {
|
||||
ResolveScript();
|
||||
}
|
||||
AttackTurnChoice(Creature* user, LearnedAttack* attack, const CreatureIndex& target, Script* script)
|
||||
: BaseTurnChoice(user), _attack(attack), _target(target), _attackScript(script) {}
|
||||
|
||||
inline LearnedAttack* GetAttack() const { return _attack; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user