C interface for Battle Side.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
bool BattleSide::AllChoicesSet() const { return _choicesSet == _creaturesPerSide; }
|
||||
bool BattleSide::AllChoicesSet() const noexcept { return _choicesSet == _creaturesPerSide; }
|
||||
|
||||
bool BattleSide::AllPossibleSlotsFilled() const {
|
||||
AssertNotNull(_battle)
|
||||
@@ -19,14 +19,14 @@ bool BattleSide::AllPossibleSlotsFilled() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void BattleSide::ResetChoices() {
|
||||
void BattleSide::ResetChoices() noexcept {
|
||||
_choicesSet = 0;
|
||||
for (uint8_t i = 0; i < _creaturesPerSide; i++) {
|
||||
_choices[i] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
const List<BaseTurnChoice*>& BattleSide::GetChoices() const { return _choices; }
|
||||
const List<BaseTurnChoice*>& BattleSide::GetChoices() const noexcept { return _choices; }
|
||||
|
||||
void BattleSide::SetChoice(BaseTurnChoice* choice) {
|
||||
AssertNotNull(choice)
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace CreatureLib::Battling {
|
||||
bool _hasFled = false;
|
||||
|
||||
public:
|
||||
explicit BattleSide(uint8_t index, Battle* battle, uint8_t creaturesPerSide)
|
||||
BattleSide(uint8_t index, Battle* battle, uint8_t creaturesPerSide) noexcept
|
||||
: _index(index), _creaturesPerSide(creaturesPerSide), _creatures(creaturesPerSide),
|
||||
_choices(creaturesPerSide), _fillableSlots(creaturesPerSide), _battle(battle) {
|
||||
for (size_t i = 0; i < creaturesPerSide; i++) {
|
||||
@@ -35,24 +35,24 @@ namespace CreatureLib::Battling {
|
||||
|
||||
virtual ~BattleSide() = default;
|
||||
|
||||
[[nodiscard]] bool AllChoicesSet() const;
|
||||
[[nodiscard]] const List<BaseTurnChoice*>& GetChoices() const;
|
||||
[[nodiscard]] bool AllChoicesSet() const noexcept;
|
||||
[[nodiscard]] const List<BaseTurnChoice*>& GetChoices() const noexcept;
|
||||
|
||||
[[nodiscard]] bool AllPossibleSlotsFilled() const;
|
||||
|
||||
void SetChoice(BaseTurnChoice* choice);
|
||||
void ResetChoices();
|
||||
void ResetChoices() noexcept;
|
||||
|
||||
void SetCreature(Creature* creature, uint8_t index);
|
||||
|
||||
Creature* GetCreature(uint8_t index) const;
|
||||
bool CreatureOnSide(const Creature* creature) const;
|
||||
|
||||
void GetActiveScripts(Arbutils::Collections::List<ScriptWrapper>& scripts) final;
|
||||
void GetActiveScripts(Arbutils::Collections::List<ScriptWrapper>& scripts) override;
|
||||
|
||||
const List<Creature*>& GetCreatures() { return _creatures; }
|
||||
|
||||
uint8_t GetSideIndex() { return _index; }
|
||||
uint8_t GetSideIndex() noexcept { return _index; }
|
||||
uint8_t GetCreatureIndex(Creature* c) {
|
||||
for (size_t i = 0; i < _creatures.Count(); i++) {
|
||||
if (c == _creatures[i])
|
||||
@@ -61,7 +61,7 @@ namespace CreatureLib::Battling {
|
||||
throw CreatureException("Unable to find creature on field.");
|
||||
}
|
||||
|
||||
void MarkSlotAsUnfillable(Creature* creature) {
|
||||
void MarkSlotAsUnfillable(Creature* creature) noexcept {
|
||||
for (uint8_t i = 0; i < _creaturesPerSide; i++) {
|
||||
if (_creatures[i] == creature) {
|
||||
_fillableSlots.At(i) = false;
|
||||
@@ -70,7 +70,7 @@ namespace CreatureLib::Battling {
|
||||
}
|
||||
}
|
||||
|
||||
bool IsDefeated() {
|
||||
bool IsDefeated() noexcept {
|
||||
for (auto b : _fillableSlots) {
|
||||
if (b)
|
||||
return false;
|
||||
@@ -78,9 +78,9 @@ namespace CreatureLib::Battling {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HasFled() { return _hasFled; }
|
||||
bool HasFled() noexcept { return _hasFled; }
|
||||
|
||||
void MarkAsFled() { _hasFled = true; }
|
||||
void MarkAsFled() noexcept { _hasFled = true; }
|
||||
|
||||
uint8_t GetRandomCreatureIndex();
|
||||
};
|
||||
|
||||
@@ -103,8 +103,8 @@ void Battling::Creature::OnFaint() {
|
||||
_battle->TriggerEventListener(new FaintEvent(this));
|
||||
}
|
||||
_library->GetExperienceLibrary()->HandleExperienceGain(this, _seenOpponents);
|
||||
|
||||
if (!_battle->CanSlotBeFilled(_side->GetSideIndex(), _side->GetCreatureIndex(this))) {
|
||||
auto sideIndex = _side->GetCreatureIndex(this);
|
||||
if (!_battle->CanSlotBeFilled(_side->GetSideIndex(), sideIndex)) {
|
||||
_side->MarkSlotAsUnfillable(this);
|
||||
}
|
||||
_battle->ValidateBattleState();
|
||||
|
||||
Reference in New Issue
Block a user