Example #1
0
        public bool AddReward(int actorId, int gameId, Reward reward)
        {
            var evaluationDataController = new EvaluationDataController(EvaluationDataLogger, ContextFactory, reward.EvaluationDataCategory);

            var evaluationData = new EvaluationData {
                Key                = reward.EvaluationDataKey,
                GameId             = gameId,
                ActorId            = actorId,
                Category           = reward.EvaluationDataCategory,
                EvaluationDataType = reward.EvaluationDataType,
                Value              = reward.Value
            };

            if (reward.EvaluationDataCategory == Common.EvaluationDataCategory.Resource)
            {
                var current = evaluationDataController.Get(gameId, actorId, new[] { reward.EvaluationDataKey });
                if (current.Any())
                {
                    evaluationData.Value = (long.Parse(reward.Value) + long.Parse(current.Single().Value)).ToString();

                    evaluationDataController.Update(evaluationData);
                }
                else
                {
                    evaluationDataController.Add(evaluationData);
                }
            }
            else
            {
                evaluationDataController.Add(evaluationData);
            }

            _logger.LogInformation($"Game Data: {evaluationData.Id} for ActorId: {actorId}, GameId: {gameId}, Reward: {reward.Id}");

            return(true);
        }
Example #2
0
 public List <EvaluationData> GetData(int matchId, string[] keys = null)
 {
     return(_evaluationDataController.Get(matchId, keys));
 }
Example #3
0
        public List <EvaluationData> Get(int gameId, int?actorId, string[] keys = null)
        {
            var results = EnforceNoDuplicates(_evaluationDataController.Get(gameId, actorId, keys));

            return(results);
        }
 public List <EvaluationData> Get(int gameId, int actorId, params string[] keys)
 {
     return(_evaluationDataController.Get(gameId, actorId, keys));
 }