Handling for tie breaking
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-04-22 23:09:54 +02:00
parent 1709617e10
commit 742d0c772c
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
3 changed files with 6 additions and 1 deletions

View File

@ -25,7 +25,7 @@ public:
if (aSpeed != bSpeed) if (aSpeed != bSpeed)
return aSpeed > bSpeed; return aSpeed > bSpeed;
return true; return a->__GetRandomValue() > b->__GetRandomValue();
} }
}; };

View File

@ -54,6 +54,7 @@ void Battle::CheckChoicesSetAndRun() {
} }
// HOOK: Check if we need to change the move // HOOK: Check if we need to change the move
} }
choice->__SetRandomValue(_random.Get());
choices[i] = choice; choices[i] = choice;
i++; i++;
} }

View File

@ -10,6 +10,7 @@ namespace CreatureLib::Battling {
class BaseTurnChoice : public ScriptSource { class BaseTurnChoice : public ScriptSource {
Creature* _user; Creature* _user;
int32_t _randomValue;
protected: protected:
BaseTurnChoice(Creature* user) noexcept : _user(user){}; BaseTurnChoice(Creature* user) noexcept : _user(user){};
@ -18,6 +19,9 @@ namespace CreatureLib::Battling {
virtual ~BaseTurnChoice() = default; virtual ~BaseTurnChoice() = default;
[[nodiscard]] virtual TurnChoiceKind GetKind() const noexcept = 0; [[nodiscard]] virtual TurnChoiceKind GetKind() const noexcept = 0;
[[nodiscard]] inline Creature* GetUser() const noexcept { return _user; } [[nodiscard]] inline Creature* GetUser() const noexcept { return _user; }
inline void __SetRandomValue(int32_t val) noexcept { _randomValue = val; }
inline int32_t __GetRandomValue() const noexcept { return _randomValue; }
}; };
} }