Fixes and tweaks for CreatureParty, added C Interface.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
1d18066bcc
commit
bbe99da0f0
|
@ -0,0 +1,24 @@
|
||||||
|
#include "../../src/Battling/Models/CreatureParty.hpp"
|
||||||
|
#define export extern "C"
|
||||||
|
using namespace CreatureLib::Battling;
|
||||||
|
|
||||||
|
export CreatureParty* CreatureLib_CreatureParty_ConstructWithSize(size_t size) { return new CreatureParty(size); }
|
||||||
|
export CreatureParty* CreatureLib_CreatureParty_ConstructFromArray(Creature* creatures[], size_t size) {
|
||||||
|
return new CreatureParty(std::vector<Creature*>(creatures, creatures + size));
|
||||||
|
}
|
||||||
|
|
||||||
|
export void CreatureLib_CreatureParty_Destruct(const CreatureParty* p) { delete p; }
|
||||||
|
|
||||||
|
export Creature* CreatureLib_CreatureParty_GetAtIndex(const CreatureParty* p, size_t index) {
|
||||||
|
return p->GetAtIndex(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
export void CreatureLib_CreatureParty_Switch(CreatureParty* p, size_t a, size_t b) { p->Switch(a, b); }
|
||||||
|
|
||||||
|
export bool CreatureLib_CreatureParty_HasAvailableCreatures(const CreatureParty* p) {
|
||||||
|
return p->HasAvailableCreatures();
|
||||||
|
}
|
||||||
|
|
||||||
|
export size_t CreatureLib_CreatureParty_GetLength(const CreatureParty* p) { return p->GetLength(); }
|
||||||
|
|
||||||
|
export Creature** CreatureLib_CreatureParty_GetParty(CreatureParty* p) { return p->GetParty().data(); }
|
|
@ -9,6 +9,7 @@ namespace CreatureLib::Battling {
|
||||||
std::vector<Creature*> _party;
|
std::vector<Creature*> _party;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
CreatureParty(size_t size) : _party(size) {}
|
||||||
CreatureParty(std::vector<Creature*> party) : _party(party) {}
|
CreatureParty(std::vector<Creature*> party) : _party(party) {}
|
||||||
CreatureParty(std::initializer_list<Creature*> party) : _party(party) {}
|
CreatureParty(std::initializer_list<Creature*> party) : _party(party) {}
|
||||||
|
|
||||||
|
@ -18,9 +19,9 @@ namespace CreatureLib::Battling {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Creature* GetAtIndex(int index) const { return _party[index]; }
|
Creature* GetAtIndex(size_t index) const { return _party[index]; }
|
||||||
|
|
||||||
void Switch(int a, int b) {
|
void Switch(size_t a, size_t b) {
|
||||||
auto ca = _party[a];
|
auto ca = _party[a];
|
||||||
_party[a] = _party[b];
|
_party[a] = _party[b];
|
||||||
_party[b] = ca;
|
_party[b] = ca;
|
||||||
|
@ -38,6 +39,9 @@ namespace CreatureLib::Battling {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Creature*>& GetParty() { return _party; }
|
std::vector<Creature*>& GetParty() { return _party; }
|
||||||
|
const std::vector<Creature*>& GetParty() const { return _party; }
|
||||||
|
|
||||||
|
size_t GetLength() const { return _party.size(); }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue