Support for failing an AttackTurnChoice.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This is handled before the actual ExecutingAttack is created, so allows for failing a move a lot earlier than before.
This commit is contained in:
parent
1a3b7fe50a
commit
33d384c464
|
@ -134,6 +134,11 @@ void TurnHandler::ExecuteAttackChoice(const ArbUt::BorrowedPtr<AttackTurnChoice>
|
|||
return;
|
||||
}
|
||||
|
||||
if (choice->HasFailed()) {
|
||||
FAIL_HANDLING_NO_TARGET(choice, choice->GetUser());
|
||||
return;
|
||||
}
|
||||
|
||||
auto* attack = attackScoped.TakeOwnership();
|
||||
battle.GetValue()->TriggerEventListener<AttackUseEvent>(attack);
|
||||
battle.GetValue()->RegisterHistoryElement<AttackUseHistory>(attack);
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace CreatureLib::Battling {
|
|||
CreatureIndex _target;
|
||||
std::unique_ptr<BattleScript> _attackScript = nullptr;
|
||||
int8_t _priority = 0;
|
||||
bool _hasFailed = false;
|
||||
|
||||
void ResolveScript(ArbUt::BorrowedPtr<const CreatureLib::Library::AttackData> attack) {
|
||||
if (_attackScript != nullptr)
|
||||
|
@ -73,6 +74,9 @@ namespace CreatureLib::Battling {
|
|||
void GetOwnScripts(ArbUt::List<ScriptWrapper>& scripts) override {
|
||||
scripts.Append(ScriptWrapper::FromScript(&_attackScript));
|
||||
}
|
||||
|
||||
inline bool HasFailed() const noexcept { return _hasFailed; }
|
||||
inline void Fail() noexcept { _hasFailed = true; }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue