CreatureLib/src/Battling/Models/BattleParty.hpp

54 lines
1.7 KiB
C++

#ifndef CREATURELIB_BATTLEPARTY_HPP
#define CREATURELIB_BATTLEPARTY_HPP
#include <Arbutils/Assert.hpp>
#include <Arbutils/Collections/List.hpp>
#include "CreatureIndex.hpp"
#include "CreatureParty.hpp"
using namespace Arbutils::Collections;
namespace CreatureLib::Battling {
class BattleParty {
CreatureParty* _party;
List<CreatureIndex> _responsibleIndices;
public:
BattleParty(CreatureParty* party, const List<CreatureIndex>& responsibleIndices)
: _party(party), _responsibleIndices(responsibleIndices) {
AssertNotNull(_party)
}
inline CreatureParty* GetParty() const { return _party; }
inline const List<CreatureIndex>& GetResponsibleIndices() const { return _responsibleIndices; }
inline bool IsResponsibleForIndex(const CreatureIndex& index) const {
return _responsibleIndices.Contains(index);
}
inline bool IsResponsibleForIndex(uint8_t side, uint8_t index) const {
for (const auto& i : _responsibleIndices) {
if (i.GetSideIndex() == side && i.GetCreatureIndex() == index)
return true;
}
return false;
}
inline bool HasCreaturesNotInField() const {
auto p = _party->GetParty();
for (const auto& creature : p) {
if (creature == nullptr)
continue;
if (creature->IsFainted())
continue;
if (creature->IsOnBattleField())
continue;
return true;
}
return false;
}
};
}
#endif // CREATURELIB_BATTLEPARTY_HPP