CreatureLib/CInterface/Battling/BattleParty.cpp

28 lines
1.4 KiB
C++

#include "../../src/Battling/Models/BattleParty.hpp"
#include "../Core.hpp"
using namespace CreatureLib::Battling;
// Note that creatureIndices should be twice the size of numberOfIndices, and have index of side, index of creature on
// side, one after the other.
export uint8_t CreatureLib_BattleParty_Construct(BattleParty*& out, CreatureParty* p, uint8_t creatureIndices[],
size_t numberOfIndices) {
Try(ArbUt::List<CreatureIndex> indices(numberOfIndices); for (size_t i = 0; i < numberOfIndices; i++) {
indices[i] = CreatureIndex(creatureIndices[i * 2], creatureIndices[i * 2 + 1]);
} out = new BattleParty(p, indices);)
}
export void CreatureLib_BattleParty_Destruct(const BattleParty* p) { delete p; }
export uint8_t CreatureLib_BattleParty_IsResponsibleForIndex(bool& out, const BattleParty* p, uint8_t side,
uint8_t creature) {
Try(out = p->IsResponsibleForIndex(side, creature);)
}
export bool CreatureLib_BattleParty_HasCreaturesNotInField(const BattleParty* p) { return p->HasCreaturesNotInField(); }
inline bool BattleParty::IsResponsibleForIndex(uint8_t side, uint8_t index) const {
return std::any_of(_responsibleIndices.begin(), _responsibleIndices.end(), [side, index](const CreatureIndex& ci) {
return ci.GetSideIndex() == side && ci.GetCreatureIndex() == index;
});
}