Пример #1
0
        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);
                }
            }
        }
Пример #2
0
        public void Running()
        {
            List <IndexedChallenge> challs = _Challenges.GetRunning();

            _Logger.LogInformation($"Active challenges:\n{String.Join("\n", challs.Select(iter => $"\t{iter.Index}@ {iter.Challenge.ID}/{iter.Challenge.Name}: {iter.Challenge.Description}"))}");
        }