Check if target of attack is a valid target for that attack.
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
2021-05-24 10:57:17 +02:00
parent 69dab061da
commit 8241a2d7b1
3 changed files with 66 additions and 1 deletions

View File

@@ -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;
}