Use smart pointers for BattleSide.
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -9,14 +9,14 @@ using namespace Battling;
|
||||
class ChoiceCompare {
|
||||
public:
|
||||
explicit ChoiceCompare() {}
|
||||
bool operator()(const BaseTurnChoice* a, const BaseTurnChoice* b) {
|
||||
bool operator()(const std::shared_ptr<BaseTurnChoice>& a, const std::shared_ptr<BaseTurnChoice>& b) {
|
||||
auto aKind = a->GetKind();
|
||||
auto bKind = b->GetKind();
|
||||
if (aKind != bKind)
|
||||
return aKind > bKind;
|
||||
if (aKind == TurnChoiceKind::Attack) {
|
||||
auto aPriority = dynamic_cast<const AttackTurnChoice*>(a)->GetPriority();
|
||||
auto bPriority = dynamic_cast<const AttackTurnChoice*>(b)->GetPriority();
|
||||
auto aPriority = dynamic_cast<const AttackTurnChoice*>(a.get())->GetPriority();
|
||||
auto bPriority = dynamic_cast<const AttackTurnChoice*>(b.get())->GetPriority();
|
||||
if (aPriority != bPriority)
|
||||
return aPriority > bPriority;
|
||||
}
|
||||
@@ -29,6 +29,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
void TurnOrdering::OrderChoices(std::vector<BaseTurnChoice*>& vec, ArbUt::Random& rand) {
|
||||
void TurnOrdering::OrderChoices(std::vector<std::shared_ptr<BaseTurnChoice>>& vec, ArbUt::Random& rand) {
|
||||
std::sort(vec.begin(), vec.end(), ChoiceCompare());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user