Esempio n. 1
0
        public void AddProgress(ConcurrentProgressCache addConcurrentProgressCache, Func <float, bool> addCondition = null)
        {
            foreach (var addGameProgress in addConcurrentProgressCache._progress)
            {
                if (!_progress.TryGetValue(addGameProgress.Key, out var existingGameProgress))
                {
                    existingGameProgress           = new ConcurrentDictionary <int, ConcurrentDictionary <Evaluation, float> >();
                    _progress[addGameProgress.Key] = existingGameProgress;
                }

                foreach (var addActorProgress in addGameProgress.Value)
                {
                    if (!existingGameProgress.TryGetValue(addActorProgress.Key, out var existingActorProgress))
                    {
                        existingActorProgress = new ConcurrentDictionary <Evaluation, float>();
                        existingGameProgress[addActorProgress.Key] = existingActorProgress;
                    }

                    foreach (var addEvaluationProgress in addActorProgress.Value)
                    {
                        if (addCondition == null || addCondition(addEvaluationProgress.Value))
                        {
                            existingActorProgress[addEvaluationProgress.Key] = addEvaluationProgress.Value;
                        }
                    }
                }
            }
        }
Esempio n. 2
0
 private void AddProgress(ConcurrentProgressCache concurrentProgress, Evaluation evaluation, Session session)
 {
     if (evaluation.ActorType != Common.ActorType.Group && !_evaluationController.IsAlreadyCompleted(evaluation, session.ActorId))
     {
         var progressValue = _evaluationController.EvaluateProgress(evaluation, session.ActorId);
         concurrentProgress.AddProgress(session.GameId, session.ActorId, evaluation, progressValue);
     }
 }
Esempio n. 3
0
        public ConcurrentProgressCache EvaluateSessions(ICollection <Session> sessions, Evaluation evaluation)
        {
            var progress = new ConcurrentProgressCache();

            foreach (var session in sessions)
            {
                AddProgress(progress, evaluation, session);
            }

            return(progress);
        }
Esempio n. 4
0
        public ConcurrentProgressCache EvaluateActor(List <Evaluation> evaluations, Session session)
        {
            var progress = new ConcurrentProgressCache();

            foreach (var evaluation in evaluations)
            {
                AddProgress(progress, evaluation, session);
            }

            return(progress);
        }
 public void Update(ConcurrentProgressCache addProgress, float minProgress = 1f)   // todo make this config driven (should probably be stored on the achievemnt as notification progress interval)
 {
     _pendingNotifications.AddProgress(addProgress, progress => progress >= minProgress);
 }