Implements replacement attack when an attack can't be used anymore, adds clearer exception handling.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
36f1e5beeb
commit
1d03adf0d1
|
@ -14,7 +14,14 @@ void TurnHandler::RunTurn(ArbUt::BorrowedPtr<ChoiceQueue> queue) {
|
|||
}
|
||||
while (queue->HasNext()) {
|
||||
auto item = queue->Dequeue();
|
||||
try {
|
||||
ExecuteChoice(item.get());
|
||||
} catch (const std::exception& e) {
|
||||
THROW_CREATURE("Executing choice failed for choice by mon on side "
|
||||
<< item.get()->GetUser()->GetBattleSide()->GetSideIndex() << " and index "
|
||||
<< item.get()->GetUser()->GetBattleSide()->GetCreatureIndex(item->GetUser())
|
||||
<< " with message '" << e.what() << "'.");
|
||||
}
|
||||
}
|
||||
queue->HasCompletedQueue = true;
|
||||
}
|
||||
|
|
|
@ -41,16 +41,17 @@ void Battle::CheckChoicesSetAndRun() {
|
|||
|
||||
auto choices = std::vector<std::shared_ptr<BaseTurnChoice>>(_numberOfSides * _creaturesPerSide);
|
||||
auto i = 0;
|
||||
try {
|
||||
for (auto side : _sides) {
|
||||
for (const auto& choice : side->GetChoices()) {
|
||||
for (auto choice : side->GetChoices()) {
|
||||
AssertNotNull(choice)
|
||||
if (choice->GetKind() == TurnChoiceKind::Attack) {
|
||||
auto attack = ((AttackTurnChoice*)choice.get())->GetAttack();
|
||||
uint8_t uses = 1;
|
||||
// HOOK: change number of uses needed.
|
||||
if (attack->GetRemainingUses() < uses) {
|
||||
// TODO: Implement default move
|
||||
throw NotImplementedException("Not enough remaining uses, change to default move.");
|
||||
choice = std::shared_ptr<BaseTurnChoice>(_library->GetMiscLibrary()->ReplacementAttack(
|
||||
choice->GetUser().GetRaw(), ((AttackTurnChoice*)choice.get())->GetTarget()));
|
||||
}
|
||||
// HOOK: Check if we need to change the move
|
||||
}
|
||||
|
@ -60,8 +61,15 @@ void Battle::CheckChoicesSetAndRun() {
|
|||
}
|
||||
side->ResetChoices();
|
||||
}
|
||||
} catch (const std::exception& e) {
|
||||
THROW_CREATURE("Exception during turn initialization: '" << e.what() << "'.")
|
||||
}
|
||||
_currentTurn++;
|
||||
try {
|
||||
TurnOrdering::OrderChoices(choices, _random.GetRNG());
|
||||
} catch (const std::exception& e) {
|
||||
THROW_CREATURE("Exception during turn ordering: '" << e.what() << "'.")
|
||||
}
|
||||
this->_currentTurnQueue.reset(new ChoiceQueue(choices));
|
||||
TurnHandler::RunTurn(this->_currentTurnQueue);
|
||||
if (this->_currentTurnQueue->HasCompletedQueue) {
|
||||
|
|
Loading…
Reference in New Issue