C interface for Battle Side.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-04-04 17:03:06 +02:00
parent 3429f1647c
commit 3dd5aeffd8
4 changed files with 57 additions and 15 deletions

View File

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