Clearer errors for C Interface.
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:
@@ -28,15 +28,21 @@ bool Battle::TrySetChoice(BaseTurnChoice* choice) {
|
||||
}
|
||||
|
||||
void Battle::CheckChoicesSetAndRun() {
|
||||
for (auto side : _sides) {
|
||||
if (!side->AllChoicesSet()) {
|
||||
return;
|
||||
try {
|
||||
for (auto side : _sides) {
|
||||
if (!side->AllChoicesSet()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto side : _sides) {
|
||||
if (!side->AllPossibleSlotsFilled()) {
|
||||
return;
|
||||
for (auto side : _sides) {
|
||||
if (!side->AllPossibleSlotsFilled()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (const CreatureException& e) {
|
||||
throw e;
|
||||
} catch (const std::exception& e) {
|
||||
THROW_CREATURE("Exception during choices set validation: '" << e.what() << "'.");
|
||||
}
|
||||
|
||||
auto choices = std::vector<std::shared_ptr<BaseTurnChoice>>(_numberOfSides * _creaturesPerSide);
|
||||
@@ -71,7 +77,13 @@ void Battle::CheckChoicesSetAndRun() {
|
||||
THROW_CREATURE("Exception during turn ordering: '" << e.what() << "'.")
|
||||
}
|
||||
this->_currentTurnQueue.reset(new ChoiceQueue(choices));
|
||||
TurnHandler::RunTurn(this->_currentTurnQueue);
|
||||
try {
|
||||
TurnHandler::RunTurn(this->_currentTurnQueue);
|
||||
} catch (const CreatureException& e) {
|
||||
throw e;
|
||||
} catch (const std::exception& e) {
|
||||
THROW_CREATURE("Error during running a turn: '" << e.what() << "'.");
|
||||
}
|
||||
if (this->_currentTurnQueue->HasCompletedQueue) {
|
||||
this->_currentTurnQueue = nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user