Better handling of filling empty slots.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -26,6 +26,9 @@ bool Battle::TrySetChoice(BaseTurnChoice* choice) {
|
||||
|
||||
void Battle::CheckChoicesSetAndRun() {
|
||||
for (auto side : _sides) {
|
||||
if (!side->AllPossibleSlotsFilled()) {
|
||||
return;
|
||||
}
|
||||
if (!side->AllChoicesSet()) {
|
||||
return;
|
||||
}
|
||||
@@ -34,8 +37,11 @@ void Battle::CheckChoicesSetAndRun() {
|
||||
auto i = 0;
|
||||
for (auto side : _sides) {
|
||||
for (BaseTurnChoice* choice : side->GetChoices()) {
|
||||
if (choice == nullptr) {
|
||||
throw CreatureException("Choice was null");
|
||||
}
|
||||
if (choice->GetKind() == TurnChoiceKind::Attack) {
|
||||
auto attack = dynamic_cast<const AttackTurnChoice*>(choice)->GetAttack();
|
||||
auto attack = (dynamic_cast<AttackTurnChoice*>((choice)))->GetAttack();
|
||||
uint8_t uses = 1;
|
||||
// HOOK: change number of uses needed.
|
||||
if (attack->GetRemainingUses() < uses) {
|
||||
@@ -70,23 +76,21 @@ bool Battle::CreatureInField(const Creature* creature) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Battle::HasRecalledSlots() const { return _numberOfRecalledSlots > 0; }
|
||||
void Battle::ForceRecall(uint8_t side, uint8_t index) { _sides[side]->SetCreature(nullptr, index); }
|
||||
|
||||
void Battle::ForceRecall(uint8_t side, uint8_t index) {
|
||||
_numberOfRecalledSlots++;
|
||||
// TODO: Switch out.
|
||||
}
|
||||
|
||||
void Battle::FillRecall(uint8_t side, uint8_t, Creature* c) {
|
||||
_numberOfRecalledSlots--;
|
||||
// TODO: switch in.
|
||||
if (_numberOfRecalledSlots == 0 && _currentTurnQueue != nullptr) {
|
||||
TurnHandler::RunTurn(this, _currentTurnQueue);
|
||||
}
|
||||
}
|
||||
void Battle::FillEmptySlot(uint8_t side, uint8_t index, Creature* c) { _sides[side]->SetCreature(c, index); }
|
||||
|
||||
void Battle::GetActiveScripts(std::vector<ScriptWrapper>& scripts) { scripts.emplace_back(&_volatile); }
|
||||
void Battle::SwitchCreature(uint8_t sideIndex, uint8_t index, Creature* c) {
|
||||
auto side = this->_sides[sideIndex];
|
||||
side->SetCreature(c, index);
|
||||
}
|
||||
bool Battle::CanSlotBeFilled(uint8_t side, uint8_t index) const {
|
||||
for (const auto& party : _parties) {
|
||||
if (party.IsResponsibleForIndex(side, index)) {
|
||||
if (party.HasCreaturesNotInField())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user