Added C Interface for BattleParty.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-03-08 15:19:19 +01:00
parent bbe99da0f0
commit 1afb13cfd1
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
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(); }

View File

@ -10,6 +10,7 @@ namespace CreatureLib::Battling {
uint8_t _creature;
public:
CreatureIndex() : _side(0), _creature(0) {}
CreatureIndex(uint8_t side, uint8_t creature) : _side(side), _creature(creature) {}
uint8_t GetSideIndex() const { return _side; }