Esempio n. 1
0
        public void CreateScore(ScoreModel scoreModel)
        {
            var score = _mapper.Map <Score>(scoreModel);

            var topScore = GetTop10Scores().FirstOrDefault();
            var topScorePlayerAchievement = _playerAchievementRepository.Get(score.PlayerId, 3);

            if (score.Result > topScore.Result && topScorePlayerAchievement == null)
            {
                _playerAchievementRepository.Create(score.PlayerId, 3);
            }

            var score3000PlayerAchievement  = _playerAchievementRepository.Get(score.PlayerId, 2);
            var score5000PlayerAchievememnt = _playerAchievementRepository.Get(score.PlayerId, 4);

            if (score.Result >= 3000 && score3000PlayerAchievement == null)
            {
                _playerAchievementRepository.Create(score.PlayerId, 2);
            }

            if (score.Result >= 5000 && score5000PlayerAchievememnt == null)
            {
                _playerAchievementRepository.Create(score.PlayerId, 4);
            }

            _scoreRepository.Create(score);
        }
Esempio n. 2
0
        public async Task <IdentityResult> IncreaseSuccessfulLoginCount(Player player)
        {
            player.SuccessfulLoginCount += 1;

            var result = await UpdateAsync(player);

            var loginPlayerAchievement = _playerAchievementRepository.Get(player.Id, 1);

            if (player.SuccessfulLoginCount >= 3 && loginPlayerAchievement == null)
            {
                _playerAchievementRepository.Create(player.Id, 1);
            }

            return(result);
        }