Adds swap event when two creatures swap positions.
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
acacd02ef9
commit
23bd0da646
|
@ -13,6 +13,7 @@
|
|||
#include "Events/FaintEvent.hpp"
|
||||
#include "Events/HealEvent.hpp"
|
||||
#include "Events/MissEvent.hpp"
|
||||
#include "Events/SwapEvent.hpp"
|
||||
#include "Events/SwitchEvent.hpp"
|
||||
#include "Events/TurnEvents.hpp"
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
namespace CreatureLib::Battling {
|
||||
ENUM(EventDataKind, uint8_t, Damage, Heal, Faint, Switch, TurnStart, TurnEnd, ExperienceGain, Miss, DisplayText,
|
||||
ChangeSpecies, ChangeVariant, AttackUse, ChangeStatBoost)
|
||||
ChangeSpecies, ChangeVariant, AttackUse, ChangeStatBoost, Fail, Swap)
|
||||
}
|
||||
|
||||
#endif // CREATURELIB_EVENTDATAKIND_HPP
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace CreatureLib::Battling {
|
|||
|
||||
public:
|
||||
FailEvent(ArbUt::BorrowedPtr<Creature> c) noexcept : _creature(c) {}
|
||||
EventDataKind GetKind() const noexcept override { return EventDataKind ::Faint; }
|
||||
EventDataKind GetKind() const noexcept override { return EventDataKind ::Fail; }
|
||||
const ArbUt::BorrowedPtr<Creature>& GetCreature() const noexcept { return _creature; }
|
||||
};
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef SWAPEVENT_HPP
|
||||
#define SWAPEVENT_HPP
|
||||
|
||||
namespace CreatureLib::Battling {
|
||||
class SwapEvent final : public EventData {
|
||||
u8 _sideIndex;
|
||||
u8 _positionA;
|
||||
u8 _positionB;
|
||||
|
||||
public:
|
||||
SwapEvent(u8 sideIndex, u8 positionA, u8 positionB) noexcept
|
||||
: _sideIndex(sideIndex), _positionA(positionA), _positionB(positionB) {}
|
||||
EventDataKind GetKind() const noexcept override { return EventDataKind ::Swap; }
|
||||
|
||||
inline u8 GetSideIndex() const noexcept { return _sideIndex; }
|
||||
inline u8 GetPositionA() const noexcept { return _positionA; }
|
||||
inline u8 GetPositionB() const noexcept { return _positionB; }
|
||||
};
|
||||
}
|
||||
|
||||
#endif // SWAPEVENT_HPP
|
|
@ -120,5 +120,6 @@ bool BattleSide::SwapPositions(u8 a, u8 b) {
|
|||
auto creatureA = _creatures[a];
|
||||
_creatures[a] = _creatures[b];
|
||||
_creatures[b] = creatureA;
|
||||
_battle->TriggerEventListener<SwapEvent>(_index, a, b);
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue