Add support for swapping in and out of a party.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-07-25 14:35:13 +02:00
parent 3f447a3e16
commit 8f921ce89b
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
2 changed files with 10 additions and 0 deletions

View File

@ -15,6 +15,10 @@ export uint8_t CreatureLib_CreatureParty_GetAtIndex(Creature*& out, const Creatu
export uint8_t CreatureLib_CreatureParty_Switch(CreatureParty* p, size_t a, size_t b) { Try(p->Switch(a, b);) }
export Creature* CreatureLib_CreatureParty_SwapInto(CreatureParty* p, size_t index, Creature* creature) {
return p->SwapInto(index, creature);
}
export bool CreatureLib_CreatureParty_HasAvailableCreatures(const CreatureParty* p) {
return p->HasAvailableCreatures();
}

View File

@ -23,6 +23,12 @@ namespace CreatureLib::Battling {
_party[b] = ca;
}
Creature* SwapInto(size_t index, Creature* creature) {
auto p = _party.TakeOwnership(index);
_party.Set(index, creature);
return p;
}
bool HasAvailableCreatures() const noexcept {
for (Creature* c : _party) {
if (c == nullptr)