コード例 #1
0
        public void FindScoreById_Should_Return_Correct_Score()
        {
            var id = Guid.NewGuid();

            UserScores.AddRange(new []
            {
                new UserScore
                {
                    Id         = 1,
                    Score      = 10,
                    Timestamp  = SystemTime.Now().AddDays(-3),
                    ActionType = UserAction.AccountActivated,
                    UserId     = id
                },
                new UserScore
                {
                    Id         = 2,
                    Score      = 20,
                    Timestamp  = SystemTime.Now().AddDays(-2),
                    ActionType = UserAction.StorySubmitted,
                    UserId     = id
                }
            }
                                );


            var score = _userRepository.FindScoreById(id, SystemTime.Now().AddMonths(-1), SystemTime.Now());

            Assert.Equal(30, score);
        }
コード例 #2
0
        public void FindTop_Should_Return_Top_Users()
        {
            UserScores.AddRange(
                new[]
            {
                new UserScore
                {
                    Id         = 1,
                    Score      = 10,
                    Timestamp  = SystemTime.Now().AddDays(-1),
                    ActionType = UserAction.AccountActivated,
                    User       = new User {
                        Id = Guid.NewGuid(), Role = Roles.User
                    }
                },
                new UserScore
                {
                    Id         = 1,
                    Score      = 10,
                    Timestamp  = SystemTime.Now().AddHours(-12),
                    ActionType = UserAction.AccountActivated,
                    User       = new User {
                        Id = Guid.NewGuid(), Role = Roles.User
                    }
                },
            }
                );

            Users.AddRange(UserScores.Select(us => us.User));

            var pagedResult = _userRepository.FindTop(SystemTime.Now().AddMonths(-1), SystemTime.Now(), 0, 10);

            Assert.Equal(2, pagedResult.Result.Count);
            Assert.Equal(2, pagedResult.Total);
        }
コード例 #3
0
 private void LoadSetting()
 {
     using (var sr = new StreamReader(K_SCORES_CONF))
     {
         var scoresJson = sr.ReadToEnd();
         _UserScores = JsonConvert.DeserializeObject <UserScores>(scoresJson);
     }
 }
コード例 #4
0
        public void RemoveClock(int userId)
        {
            if (!UserScores.TryGetValue(userId, out var data))
            {
                return;
            }

            ((SpectatingTrackedUserData)data).Clock = null;
        }
コード例 #5
0
        public void AddClock(int userId, IClock clock)
        {
            if (!UserScores.TryGetValue(userId, out var data))
            {
                return;
            }

            ((SpectatingTrackedUserData)data).Clock = clock;
        }
コード例 #6
0
        public void RemoveClock(int userId)
        {
            if (!UserScores.TryGetValue(userId, out var data))
            {
                throw new ArgumentException(@"Provided user is not tracked by this leaderboard", nameof(userId));
            }

            ((SpectatingTrackedUserData)data).Clock = null;
        }
コード例 #7
0
        public void AddClock(int userId, IClock clock)
        {
            if (!UserScores.TryGetValue(userId, out var data))
            {
                throw new ArgumentException(@"Provided user is not tracked by this leaderboard", nameof(userId));
            }

            data.ScoreProcessor.ReferenceClock = clock;
        }
コード例 #8
0
ファイル: User.cs プロジェクト: szymczakk/dotnetomaniak
        private void AddScore(decimal score, UserAction reason)
        {
            var userScore = new UserScore
            {
                Timestamp  = SystemTime.Now(),
                Score      = score,
                ActionType = reason,
            };

            UserScores.Add(userScore);
        }
コード例 #9
0
    public void SetScoreBar(string number, UserScores userScores, Color thisColor)
    {
        this.serialNo.text = number;

        this.win.text        = userScores.win;
        this.lost.text       = userScores.lost;
        this.draw.text       = userScores.draw;
        this.forfeit.text    = userScores.forfeit;
        this.playerName.text = userScores.name;
        this.rank.text       = userScores.rank;

        Image[] allImages = GetComponentsInChildren <Image>();
        for (int i = 0; i < allImages.Length; i++)
        {
            allImages[i].color = thisColor;
        }

        gameObject.SetActive(true);
    }