Adds Miss event.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
parent
bb35248174
commit
50236f4ece
|
@ -102,6 +102,15 @@ namespace CreatureLib::Battling {
|
|||
const ArbUt::StringView& GetText() const noexcept { return _text; }
|
||||
};
|
||||
|
||||
class MissEvent : public EventData {
|
||||
ArbUt::BorrowedPtr<Creature> _creature;
|
||||
|
||||
public:
|
||||
MissEvent(const ArbUt::BorrowedPtr<Creature>& creature) noexcept : _creature(creature) {}
|
||||
EventDataKind GetKind() const noexcept override { return EventDataKind ::Miss; }
|
||||
const ArbUt::BorrowedPtr<Creature>& GetCreature() const noexcept { return _creature; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // CREATURELIB_EVENTDATA_HPP
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <Arbutils/Enum.hpp>
|
||||
|
||||
namespace CreatureLib::Battling {
|
||||
ENUM(EventDataKind, uint8_t, Damage, Heal, Faint, Switch, TurnStart, TurnEnd, ExperienceGain, DisplayText)
|
||||
ENUM(EventDataKind, uint8_t, Damage, Heal, Faint, Switch, TurnStart, TurnEnd, ExperienceGain, Miss, DisplayText)
|
||||
}
|
||||
|
||||
#endif // CREATURELIB_EVENTDATAKIND_HPP
|
||||
|
|
|
@ -122,7 +122,7 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, const ArbUt::Bo
|
|||
if (user->GetBattle()->HasEnded())
|
||||
return;
|
||||
|
||||
auto targetSource = target;
|
||||
const auto& targetSource = target;
|
||||
auto userSource = attack;
|
||||
|
||||
bool fail = false;
|
||||
|
@ -142,6 +142,7 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, const ArbUt::Bo
|
|||
auto numberOfHits = attack->GetNumberOfHits();
|
||||
if (numberOfHits == 0) {
|
||||
HOOK(OnAttackMiss, targetSource, attack, target.GetRaw());
|
||||
user->GetBattle()->TriggerEventListener<MissEvent>(user);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue