2019-12-05 11:56:41 +00:00
|
|
|
#ifndef CREATURELIB_BATTLEPARTY_HPP
|
|
|
|
#define CREATURELIB_BATTLEPARTY_HPP
|
|
|
|
|
2020-03-22 12:42:26 +00:00
|
|
|
#include <Arbutils/Assert.hpp>
|
2019-12-05 11:56:41 +00:00
|
|
|
#include "CreatureIndex.hpp"
|
|
|
|
#include "CreatureParty.hpp"
|
|
|
|
namespace CreatureLib::Battling {
|
|
|
|
class BattleParty {
|
|
|
|
CreatureParty* _party;
|
|
|
|
std::vector<CreatureIndex> _responsibleIndices;
|
|
|
|
|
|
|
|
public:
|
|
|
|
BattleParty(CreatureParty* party, std::vector<CreatureIndex> responsibleIndices)
|
2020-03-22 12:42:26 +00:00
|
|
|
: _party(party), _responsibleIndices(responsibleIndices) {
|
|
|
|
AssertNotNull(_party)
|
|
|
|
}
|
2019-12-05 11:56:41 +00:00
|
|
|
|
2020-03-07 10:00:48 +00:00
|
|
|
inline CreatureParty* GetParty() const { return _party; }
|
|
|
|
inline const std::vector<CreatureIndex>& GetResponsibleIndices() const { return _responsibleIndices; }
|
2019-12-07 11:13:12 +00:00
|
|
|
|
2020-03-07 10:00:48 +00:00
|
|
|
inline bool IsResponsibleForIndex(const CreatureIndex& index) const {
|
2019-12-07 11:13:12 +00:00
|
|
|
for (const auto& i : _responsibleIndices) {
|
|
|
|
if (i == index)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-03-07 10:00:48 +00:00
|
|
|
inline bool IsResponsibleForIndex(uint8_t side, uint8_t index) const {
|
2019-12-07 11:13:12 +00:00
|
|
|
for (const auto& i : _responsibleIndices) {
|
|
|
|
if (i.GetSideIndex() == side && i.GetCreatureIndex() == index)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-03-07 10:00:48 +00:00
|
|
|
inline bool HasCreaturesNotInField() const {
|
2019-12-07 11:13:12 +00:00
|
|
|
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;
|
|
|
|
}
|
2019-12-05 11:56:41 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // CREATURELIB_BATTLEPARTY_HPP
|