Store time in turn execution on battle class.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
parent
d2e72deeca
commit
32f75f4a47
|
@ -79,3 +79,5 @@ export uint8_t CreatureLib_Battle_RegisterEventListener(Battle* p, void (*func)(
|
|||
Try(p->RegisterEventListener(func);)
|
||||
}
|
||||
export const HistoryHolder* CreatureLib_Battle_GetHistory(Battle* p) { return &p->GetHistory(); }
|
||||
|
||||
SIMPLE_GET_FUNC(Battle, GetLastTurnTimeMicroseconds, long);
|
|
@ -46,6 +46,7 @@ void Battle::CheckChoicesSetAndRun() {
|
|||
THROW("Exception during choices set validation: '" << e.what() << "'.")
|
||||
}
|
||||
|
||||
auto begin = std::chrono::steady_clock::now();
|
||||
auto choices = std::vector<std::shared_ptr<BaseTurnChoice>>(_numberOfSides * _creaturesPerSide);
|
||||
auto i = 0;
|
||||
try {
|
||||
|
@ -90,6 +91,8 @@ void Battle::CheckChoicesSetAndRun() {
|
|||
this->_currentTurnQueue = nullptr;
|
||||
}
|
||||
TriggerEventListener<TurnEndEvent>();
|
||||
auto end = std::chrono::steady_clock::now();
|
||||
_lastTurnTime = std::chrono::duration_cast<std::chrono::microseconds>(end - begin).count();
|
||||
}
|
||||
|
||||
ArbUt::BorrowedPtr<ChoiceQueue> Battle::GetCurrentTurnQueue() const noexcept { return _currentTurnQueue; }
|
||||
|
|
|
@ -34,6 +34,7 @@ namespace CreatureLib::Battling {
|
|||
uint32_t _currentTurn = 0;
|
||||
|
||||
ScriptSet _volatile;
|
||||
long _lastTurnTime;
|
||||
|
||||
public:
|
||||
Battle(const BattleLibrary* library, ArbUt::List<BattleParty*> parties, bool canFlee = true,
|
||||
|
@ -113,6 +114,8 @@ namespace CreatureLib::Battling {
|
|||
, "Exception occurred during history element registration.");
|
||||
}
|
||||
const HistoryHolder& GetHistory() const noexcept { return _historyHolder; }
|
||||
|
||||
long GetLastTurnTimeMicroseconds() const noexcept { return _lastTurnTime; }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue