Update to latest Arbutils.
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
2020-12-13 12:15:40 +01:00
parent 2055837980
commit e642f374b9
25 changed files with 69 additions and 120 deletions

View File

@@ -7,16 +7,14 @@
using namespace CreatureLib::Battling;
void TurnHandler::RunTurn(ArbUt::BorrowedPtr<ChoiceQueue> queue) {
AssertNotNull(queue)
for (auto choice : queue->GetInnerQueue()) {
HOOK(OnBeforeTurn, choice, choice.get());
}
while (queue->HasNext()) {
auto item = queue->Dequeue();
AssertNotNull(item)
AssertNotNull(item->GetUser())
Assert(item->GetUser()->GetBattle().HasValue())
Assert(item->GetUser()->GetBattleSide().HasValue())
EnsureNotNull(item)
Ensure(item->GetUser()->GetBattle().HasValue())
Ensure(item->GetUser()->GetBattleSide().HasValue())
auto index = (uint32_t)item->GetUser()->GetBattleSide().GetValue()->GetCreatureIndex(item->GetUser());
try_creature(ExecuteChoice(item.get()),
@@ -30,13 +28,11 @@ void TurnHandler::RunTurn(ArbUt::BorrowedPtr<ChoiceQueue> queue) {
}
void TurnHandler::ExecuteChoice(ArbUt::BorrowedPtr<BaseTurnChoice> choice) {
AssertNotNull(choice)
auto choiceKind = choice->GetKind();
if (choiceKind == TurnChoiceKind::Pass) {
return;
}
auto user = choice->GetUser();
AssertNotNull(user)
if (!user->GetBattle().HasValue())
return;
auto battle = user->GetBattle().GetValue();
@@ -68,7 +64,6 @@ void TurnHandler::ExecuteChoice(ArbUt::BorrowedPtr<BaseTurnChoice> choice) {
}
void TurnHandler::ExecuteAttackChoice(const ArbUt::BorrowedPtr<AttackTurnChoice>& choice) {
AssertNotNull(choice)
auto battle = choice->GetUser()->GetBattle();
auto attackName = choice->GetAttack()->GetAttack()->GetName();
HOOK(ChangeAttack, choice, choice.GetRaw(), &attackName);
@@ -78,7 +73,7 @@ void TurnHandler::ExecuteAttackChoice(const ArbUt::BorrowedPtr<AttackTurnChoice>
auto targetType = choice->GetAttack()->GetAttack()->GetTarget();
ArbUt::List<ArbUt::OptionalBorrowedPtr<Creature>> targets;
Assert(battle.HasValue());
Ensure(battle.HasValue());
try_creature(targets = TargetResolver::ResolveTargets(choice->GetTarget(), targetType, battle.GetValue());
, "Exception during target determination");
@@ -124,12 +119,10 @@ void TurnHandler::ExecuteAttackChoice(const ArbUt::BorrowedPtr<AttackTurnChoice>
}
void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, const ArbUt::BorrowedPtr<Creature>& target) {
AssertNotNull(attack)
EnsureNotNull(attack)
auto& user = attack->GetUser();
AssertNotNull(user)
AssertNotNull(target)
auto& battle = user->GetBattle();
Assert(battle.HasValue())
Ensure(battle.HasValue())
if (battle.GetValue()->HasEnded())
return;
@@ -155,18 +148,15 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, const ArbUt::Bo
}
auto& learnedAttack = attack->GetAttack();
AssertNotNull(learnedAttack);
auto& attackData = learnedAttack->GetAttack();
AssertNotNull(attackData);
auto& library = battle.GetValue()->GetLibrary();
AssertNotNull(library)
auto& dmgLibrary = library->GetDamageLibrary();
auto& typeLibrary = library->GetTypeLibrary();
auto& miscLibrary = library->GetMiscLibrary();
AssertNotNull(dmgLibrary)
AssertNotNull(typeLibrary)
AssertNotNull(miscLibrary)
EnsureNotNull(dmgLibrary)
EnsureNotNull(typeLibrary)
EnsureNotNull(miscLibrary)
auto hitIterator = attack->GetTargetIteratorBegin(target);
for (uint8_t hitIndex = 0; hitIndex < numberOfHits; hitIndex++) {
@@ -229,7 +219,7 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, const ArbUt::Bo
hasSecondaryEffect = true;
} else {
auto random = battle.GetValue()->GetRandom();
AssertNotNull(random);
EnsureNotNull(random);
hasSecondaryEffect = random->EffectChance(effect->GetChance(), attack, target.GetRaw());
}
if (hasSecondaryEffect) {