Support for ending battles when only one side has creatures that are available for battle.

This commit is contained in:
2019-12-07 21:56:29 +01:00
parent 0483e635ea
commit 262279bd2c
9 changed files with 117 additions and 6 deletions

View File

@@ -11,6 +11,7 @@ namespace CreatureLib::Battling {
uint8_t _creaturesPerSide;
std::vector<Creature*> _creatures;
std::vector<BaseTurnChoice*> _choices;
std::vector<bool> _fillableSlots;
uint8_t _choicesSet = 0;
ScriptSet _volatile;
Battle* _battle;
@@ -20,9 +21,11 @@ namespace CreatureLib::Battling {
: _index(index), _creaturesPerSide(creaturesPerSide), _battle(battle) {
_creatures = std::vector<Creature*>(creaturesPerSide);
_choices = std::vector<BaseTurnChoice*>(creaturesPerSide);
_fillableSlots = std::vector<bool>(creaturesPerSide);
for (size_t i = 0; i < creaturesPerSide; i++) {
_creatures[i] = nullptr;
_choices[i] = nullptr;
_fillableSlots[i] = true;
}
ResetChoices();
}
@@ -43,6 +46,22 @@ namespace CreatureLib::Battling {
bool CreatureOnSide(const Creature* creature) const;
void GetActiveScripts(std::vector<ScriptWrapper>& scripts) final;
void MarkSlotAsUnfillable(Creature* creature){
for (uint8_t i = 0; i < _creaturesPerSide; i++){
if (_creatures[i] == creature){
_fillableSlots[i] = false;
return;
}
}
}
bool IsDefeated(){
for (auto b: _fillableSlots){
if (b) return false;
}
return true;
}
};
}