diff --git a/CInterface/Battling/BattleParty.cpp b/CInterface/Battling/BattleParty.cpp new file mode 100644 index 0000000..e6ea5bd --- /dev/null +++ b/CInterface/Battling/BattleParty.cpp @@ -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 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(); } diff --git a/src/Battling/Models/CreatureIndex.hpp b/src/Battling/Models/CreatureIndex.hpp index f10e2cb..3c541a5 100644 --- a/src/Battling/Models/CreatureIndex.hpp +++ b/src/Battling/Models/CreatureIndex.hpp @@ -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; }