Added C Interface for BattleParty.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-03-08 15:19:19 +01:00
parent bbe99da0f0
commit 1afb13cfd1
2 changed files with 23 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
#include "../../src/Battling/Models/BattleParty.hpp"
#define export extern "C"
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 BattleParty* CreatureLib_BattleParty_Construct(CreatureParty* p, uint8_t creatureIndices[],
size_t numberOfIndices) {
std::vector<CreatureIndex> indices(numberOfIndices);
for (size_t i = 0; i < numberOfIndices; i++) {
indices[i] = CreatureIndex(creatureIndices[i * 2], creatureIndices[i * 2 + 1]);
}
return new BattleParty(p, indices);
}
export void CreatureLib_BattleParty_Destruct(const BattleParty* p) { delete p; }
export bool CreatureLib_BattleParty_IsResponsibleForIndex(const BattleParty* p, uint8_t side, uint8_t creature) {
return p->IsResponsibleForIndex(side, creature);
}
export bool CreatureLib_BattleParty_HasCreaturesNotInField(const BattleParty* p) { return p->HasCreaturesNotInField(); }