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

@@ -1,7 +1,7 @@
#include "ChoiceQueue.hpp"
bool CreatureLib::Battling::ChoiceQueue::MoveCreatureChoiceNext(CreatureLib::Battling::Creature* creature) {
AssertNotNull(creature)
EnsureNotNull(creature)
// Find which index the creature choice is at.
size_t choiceIndex = SIZE_MAX;
for (size_t index = _current; index < _queue.size(); index++) {

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) {

View File

@@ -15,8 +15,8 @@ public:
if (aKind == TurnChoiceKind::Attack) {
auto aAttack = std::dynamic_pointer_cast<AttackTurnChoice>(a);
auto bAttack = std::dynamic_pointer_cast<AttackTurnChoice>(b);
AssertNotNull(aAttack);
AssertNotNull(bAttack);
EnsureNotNull(aAttack);
EnsureNotNull(bAttack);
auto aPriority = aAttack->GetPriority();
auto bPriority = bAttack->GetPriority();
if (aPriority != bPriority)
@@ -24,8 +24,6 @@ public:
}
auto aUser = a->GetUser();
auto bUser = b->GetUser();
AssertNotNull(aUser);
AssertNotNull(bUser);
auto aSpeed = aUser->GetBoostedStat(Library::Statistic::Speed);
auto bSpeed = bUser->GetBoostedStat(Library::Statistic::Speed);
if (aSpeed != bSpeed)
@@ -37,10 +35,10 @@ public:
void TurnOrdering::OrderChoices(std::vector<std::shared_ptr<BaseTurnChoice>>& vec) {
for (const auto& item : vec) {
AssertNotNull(item);
EnsureNotNull(item);
if (item->GetKind() == TurnChoiceKind::Attack) {
auto attackChoice = std::dynamic_pointer_cast<AttackTurnChoice>(item);
AssertNotNull(attackChoice);
EnsureNotNull(attackChoice);
auto priority = attackChoice->GetPriority();
HOOK(ChangePriority, attackChoice, attackChoice.get(), &priority);
attackChoice->SetPriority(priority);