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>
|
2020-03-22 18:21:40 +00:00
|
|
|
#include <Arbutils/Collections/List.hpp>
|
2019-12-05 11:56:41 +00:00
|
|
|
#include "CreatureIndex.hpp"
|
|
|
|
#include "CreatureParty.hpp"
|
2020-03-22 18:21:40 +00:00
|
|
|
|
2019-12-05 11:56:41 +00:00
|
|
|
namespace CreatureLib::Battling {
|
|
|
|
class BattleParty {
|
|
|
|
CreatureParty* _party;
|
2020-05-26 16:31:06 +00:00
|
|
|
ArbUt::List<CreatureIndex> _responsibleIndices;
|
2019-12-05 11:56:41 +00:00
|
|
|
|
|
|
|
public:
|
2020-05-26 16:31:06 +00:00
|
|
|
BattleParty(CreatureParty* party, const ArbUt::List<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; }
|
2020-05-26 16:31:06 +00:00
|
|
|
inline const ArbUt::List<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 {
|
2020-03-22 18:21:40 +00:00
|
|
|
return _responsibleIndices.Contains(index);
|
2019-12-07 11:13:12 +00:00
|
|
|
}
|
|
|
|
|
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
|