Support turn queue return prematurely when a creature is recalled, and the ability to resume it later.
This commit is contained in:
@@ -38,7 +38,7 @@ void Battle::CheckChoicesSetAndRun() {
|
||||
for (auto side: _sides){
|
||||
for (auto choice: side->GetChoices()){
|
||||
if (choice->GetKind() == TurnChoiceKind::Attack){
|
||||
auto attack = static_cast<const AttackTurnChoice*>(choice)->GetAttack();
|
||||
auto attack = dynamic_cast<const AttackTurnChoice*>(choice)->GetAttack();
|
||||
uint8_t uses = 1;
|
||||
//HOOK: change number of uses needed.
|
||||
if (attack->GetRemainingUses() < uses){
|
||||
@@ -52,10 +52,11 @@ void Battle::CheckChoicesSetAndRun() {
|
||||
}
|
||||
}
|
||||
TurnOrdering::OrderChoices(choices, _random);
|
||||
auto choiceQueue = ChoiceQueue(choices);
|
||||
this->_currentTurnQueue = &choiceQueue;
|
||||
TurnHandler::RunTurn(choiceQueue);
|
||||
this->_currentTurnQueue = nullptr;
|
||||
auto choiceQueue = new ChoiceQueue(choices);
|
||||
this->_currentTurnQueue = choiceQueue;
|
||||
TurnHandler::RunTurn(this, choiceQueue);
|
||||
if (choiceQueue->HasCompletedQueue)
|
||||
_currentTurnQueue = nullptr;
|
||||
}
|
||||
|
||||
ChoiceQueue* Battle::GetCurrentTurnQueue() const {
|
||||
@@ -73,3 +74,20 @@ 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) {
|
||||
_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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user