protected float EvaluateFloat(int gameId, int actorId, EvaluationCriteria completionCriteria) { var evaluationDataController = new EvaluationDataController(EvaluationDataLogger, ContextFactory, completionCriteria.EvaluationDataCategory); switch (completionCriteria.CriteriaQueryType) { case CriteriaQueryType.Any: var any = evaluationDataController.List(gameId, actorId, completionCriteria.EvaluationDataKey, EvaluationDataType.Float); return(!any.Any() ? 0 : any.Max(value => CompareValues(float.Parse(value.Value), float.Parse(completionCriteria.Value), completionCriteria.ComparisonType, completionCriteria.EvaluationDataType))); case CriteriaQueryType.Sum: var sum = evaluationDataController.SumFloat(gameId, actorId, completionCriteria.EvaluationDataKey); return(CompareValues(sum, float.Parse(completionCriteria.Value), completionCriteria.ComparisonType, completionCriteria.EvaluationDataType)); case CriteriaQueryType.Latest: if (!evaluationDataController.TryGetLatest(gameId, actorId, completionCriteria.EvaluationDataKey, out var latest, EvaluationDataType.Float)) { return(0); } return(CompareValues(float.Parse(latest.Value), float.Parse(completionCriteria.Value), completionCriteria.ComparisonType, completionCriteria.EvaluationDataType)); case CriteriaQueryType.Count: var count = evaluationDataController.List(gameId, actorId, completionCriteria.EvaluationDataKey, EvaluationDataType.Float).Count; return(CompareValues(count, long.Parse(completionCriteria.Value), completionCriteria.ComparisonType, EvaluationDataType.Long)); default: return(0); } }
protected float EvaluateManyFloat(int gameId, List <int> actors, EvaluationCriteria completionCriteria) { var evaluationDataController = new EvaluationDataController(EvaluationDataLogger, ContextFactory, completionCriteria.EvaluationDataCategory); switch (completionCriteria.CriteriaQueryType) { case CriteriaQueryType.Sum: var totalSum = actors.Sum(a => evaluationDataController.SumFloat(gameId, a, completionCriteria.EvaluationDataKey)); return(CompareValues(totalSum, float.Parse(completionCriteria.Value), completionCriteria.ComparisonType, completionCriteria.EvaluationDataType)); case CriteriaQueryType.Count: var count = actors .Sum(actorId => evaluationDataController .List(gameId, actorId, completionCriteria.EvaluationDataKey, EvaluationDataType.Float) .Count); return(CompareValues(count, long.Parse(completionCriteria.Value), completionCriteria.ComparisonType, EvaluationDataType.Long)); default: return(0); } }