diff --git a/src/Battling/Flow/ResolveTarget.cpp b/src/Battling/Flow/ResolveTarget.cpp index eab79f7..fc34a48 100644 --- a/src/Battling/Flow/ResolveTarget.cpp +++ b/src/Battling/Flow/ResolveTarget.cpp @@ -3,6 +3,8 @@ using namespace ArbUt; using namespace CreatureLib::Library; using namespace CreatureLib::Battling; +using TargetList = List>; + static inline constexpr uint8_t GetOppositeSide(uint8_t v) { if (v == 1) { return 0; @@ -10,8 +12,8 @@ static inline constexpr uint8_t GetOppositeSide(uint8_t v) { return 1; } -static inline List> GetAll(const BorrowedPtr& battle) { - List> arr(battle->GetCreaturesPerSide() * battle->GetSides().Count()); +static inline TargetList GetAll(const BorrowedPtr& battle) { + TargetList arr(battle->GetCreaturesPerSide() * battle->GetSides().Count()); for (auto* side : battle->GetSides()) { for (const auto& mon : side->GetCreatures()) { arr.Append(mon); @@ -20,8 +22,7 @@ static inline List> GetAll(const BorrowedPtr> GetAllAdjacent(const CreatureIndex& index, - const BorrowedPtr& battle) { +static inline TargetList GetAllAdjacent(const CreatureIndex& index, const BorrowedPtr& battle) { auto left = index.GetCreatureIndex() - 1; auto right = index.GetCreatureIndex() + 1; if (left < 0 && right >= battle->GetCreaturesPerSide()) { @@ -41,8 +42,7 @@ static inline List> GetAllAdjacent(const CreatureI battle->GetCreature(GetOppositeSide(index.GetSideIndex()), index.GetCreatureIndex())}; } -static inline List> GetAllAdjacentOpponent(const CreatureIndex& index, - const BorrowedPtr& battle) { +static inline TargetList GetAllAdjacentOpponent(const CreatureIndex& index, const BorrowedPtr& battle) { auto left = index.GetCreatureIndex() - 1; auto right = index.GetCreatureIndex() + 1; if (left < 0 && right >= battle->GetCreaturesPerSide()) { @@ -58,8 +58,8 @@ static inline List> GetAllAdjacentOpponent(const C return {battle->GetCreature(index), battle->GetCreature(index.GetSideIndex(), right)}; } -List> TargetResolver::ResolveTargets(const CreatureIndex& index, AttackTarget target, - const BorrowedPtr& battle) { +TargetList TargetResolver::ResolveTargets(const CreatureIndex& index, AttackTarget target, + const BorrowedPtr& battle) { switch (target) { // Single targets should just return the mon at the index. case AttackTarget::Adjacent: @@ -81,18 +81,18 @@ List> TargetResolver::ResolveTargets(const Creatur return GetAllAdjacentOpponent(index, battle); } case AttackTarget::AllAlly: { - List> arr(battle->GetCreaturesPerSide()); + TargetList arr(battle->GetCreaturesPerSide()); for (const auto& mon : battle->GetSides()[index.GetSideIndex()]->GetCreatures()) { arr.Append(mon); } return arr; } case AttackTarget::AllOpponent: { - List> arr(battle->GetCreaturesPerSide()); + TargetList arr(battle->GetCreaturesPerSide()); for (const auto& mon : battle->GetSides()[index.GetSideIndex()]->GetCreatures()) { arr.Append(mon); } - return List>(arr); + return arr; } } THROW("Unknown attack target kind: '" << AttackTargetHelper::ToString(target) << "'.") diff --git a/src/Battling/Flow/ResolveTarget.hpp b/src/Battling/Flow/ResolveTarget.hpp index a0044bf..926ac6a 100644 --- a/src/Battling/Flow/ResolveTarget.hpp +++ b/src/Battling/Flow/ResolveTarget.hpp @@ -4,14 +4,14 @@ #include "../Models/Battle.hpp" #include "../Models/Creature.hpp" #include "../Models/CreatureIndex.hpp" -using namespace CreatureLib::Battling; namespace CreatureLib::Battling { class TargetResolver { + typedef ArbUt::List> TargetList; + public: - static ArbUt::List> - ResolveTargets(const CreatureIndex& index, CreatureLib::Library::AttackTarget target, - const ArbUt::BorrowedPtr& battle); + static TargetList ResolveTargets(const CreatureIndex& index, CreatureLib::Library::AttackTarget target, + const ArbUt::BorrowedPtr& battle); }; }