Check if target of attack is a valid target for that attack.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "Battle.hpp"
|
||||
#include "../EventHooks/EventDataClasses.hpp"
|
||||
#include "../Flow/ResolveTarget.hpp"
|
||||
#include "../Flow/TurnHandler.hpp"
|
||||
#include "../Flow/TurnOrdering.hpp"
|
||||
|
||||
@@ -10,8 +11,15 @@ const ArbUt::BorrowedPtr<const BattleLibrary>& Battle::GetLibrary() const noexce
|
||||
|
||||
bool Battle::CanUse(const ArbUt::BorrowedPtr<BaseTurnChoice>& choice) {
|
||||
if (choice->GetKind() == TurnChoiceKind::Attack) {
|
||||
auto attack = choice.ForceAs<AttackTurnChoice>();
|
||||
// HOOK: change number of uses needed.
|
||||
return choice.ForceAs<AttackTurnChoice>()->GetAttack()->GetRemainingUses() >= 1;
|
||||
if (attack->GetAttack()->GetRemainingUses() < 1) {
|
||||
return false;
|
||||
}
|
||||
if (!TargetResolver::IsValidTarget(attack->GetTarget(), attack->GetAttack()->GetAttack()->GetTarget(),
|
||||
attack->GetUser())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user