private void OnTick(object?sender, SecondTimerArgs args) { if (_State != MatchState.RUNNING) { return; } _MatchTicks += args.ElapsedTicks; int matchLength = (int)Math.Round(_MatchTicks / TICKS_PER_SECOND); _MatchEvents.EmitTimerEvent(matchLength); if (_AutoSettings.Enabled) { if ((matchLength - _AutoSettings.StartDelay) % _AutoSettings.Interval == 0) { _Logger.LogInformation($"Starting new auto challenge"); StartAutoChallenge(); } } foreach (IndexedChallenge entry in _Challenges.GetRunning()) { if (entry.Challenge.DurationType != ChallengeDurationType.TIMED) { continue; } entry.TickCount += args.ElapsedTicks; //_Logger.LogTrace($"{entry.Index} {entry.Challenge.ID}/{entry.Challenge.Name} total ticks: {entry.TickCount}"); _ChallengeEvents.EmitChallengeUpdate(entry); if ((int)Math.Round(entry.TickCount / TICKS_PER_SECOND) > entry.Challenge.Duration) { _Logger.LogDebug($"{entry.Index} {entry.Challenge.ID}/{entry.Challenge.Name} done"); _Challenges.End(entry.Index); } } }
public void End(int index) { _Challenges.End(index); }