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:
@@ -9,12 +9,16 @@ bool BattleSide::AllChoicesSet() const noexcept { return _choicesSet == _creatur
|
||||
|
||||
bool BattleSide::AllPossibleSlotsFilled() const {
|
||||
AssertNotNull(_battle)
|
||||
for (size_t i = 0; i < _creatures.Count(); i++) {
|
||||
auto c = _creatures[i];
|
||||
if (c == nullptr || c->IsFainted()) {
|
||||
if (_battle->CanSlotBeFilled(_index, i))
|
||||
return false;
|
||||
try {
|
||||
for (size_t i = 0; i < _creatures.Count(); i++) {
|
||||
auto c = _creatures[i];
|
||||
if (c == nullptr || c->IsFainted()) {
|
||||
if (_battle->CanSlotBeFilled(_index, i))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} catch (const std::exception& e) {
|
||||
THROW_CREATURE("Exception during AllPossibleSlotsFilled check: '" << e.what() << "'.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -28,12 +32,19 @@ void BattleSide::ResetChoices() noexcept {
|
||||
|
||||
void BattleSide::SetChoice(BaseTurnChoice* choice) {
|
||||
AssertNotNull(choice)
|
||||
auto find = std::find(_creatures.begin(), _creatures.end(), choice->GetUser());
|
||||
if (find == _creatures.end())
|
||||
THROW_CREATURE("User not found");
|
||||
uint8_t index = std::distance(_creatures.begin(), find);
|
||||
_choices[index] = std::shared_ptr<BaseTurnChoice>(choice);
|
||||
_choicesSet++;
|
||||
try {
|
||||
for (size_t i = 0; i < _creatures.Count(); i++) {
|
||||
auto& c = _creatures[i];
|
||||
if (c == choice->GetUser()) {
|
||||
_choices[i] = std::shared_ptr<BaseTurnChoice>(choice);
|
||||
_choicesSet++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (const std::exception& e) {
|
||||
THROW_CREATURE("Error during setting choice: '" << e.what() << "'.");
|
||||
}
|
||||
THROW_CREATURE("User not found");
|
||||
}
|
||||
|
||||
void BattleSide::SetCreature(ArbUt::BorrowedPtr<Creature> creature, uint8_t index) {
|
||||
|
||||
Reference in New Issue
Block a user