Beispiel #1
0
        public async Task <ActionResult> GetFursuitScoreboardEntriesAsync(int Top = 25)
        {
            Top = Math.Min(Top, 25);
            var result = await _collectingGameService.GetFursuitScoreboardEntriesAsync(Top);

            return(result.AsActionResult());
        }
        public async Task CollectingGameService_WhenPlayersOrFursuitsHaveSameCollectionCount_ThenWhoeverAchievedItFirstRanksHigher()
        {
            var players       = new RegSysIdentityRecord[3];
            var tokens        = new TokenRecord[3];
            var fursuitBadges = new FursuitBadgeRecord[3];

            // 3 players, each with suit
            for (int i = 0; i < 3; i++)
            {
                players[i] = await CreateRegSysIdentityAsync();

                tokens[i] = await CreateTokenAsync();

                fursuitBadges[i] = await CreateFursuitBadgeAsync(players[i].Uid);

                await _collectingGameService.RegisterTokenForFursuitBadgeForOwnerAsync(
                    players[i].Uid, fursuitBadges[i].Id, tokens[i].Value);
            }

            // Each catches everyone else.
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    if (j == i)
                    {
                        continue;
                    }

                    var result = await _collectingGameService.CollectTokenForPlayerAsync(
                        players[i].Uid, tokens[j].Value);

                    Assert.True(result.IsSuccessful);
                }
            }

            var playerScoreboard = await _collectingGameService.GetPlayerScoreboardEntriesAsync(5);

            var fursuitScoreboard = await _collectingGameService.GetFursuitScoreboardEntriesAsync(5);

            // 1 catches first, then 2, then 3
            Assert.Equal(3, playerScoreboard.Value.Length);
            Assert.True(playerScoreboard.Value.All(a => a.CollectionCount == 2));
            Assert.Equal(players[0].Username, playerScoreboard.Value[0].Name);
            Assert.Equal(players[1].Username, playerScoreboard.Value[1].Name);
            Assert.Equal(players[2].Username, playerScoreboard.Value[2].Name);

            // 3 gets the 2 catches first (by 1 + 2), then 1 (by 2 + 3), then 2
            Assert.Equal(3, fursuitScoreboard.Value.Length);
            Assert.True(fursuitScoreboard.Value.All(a => a.CollectionCount == 2));
            Assert.Equal(fursuitBadges[2].Id, fursuitScoreboard.Value[0].BadgeId);
            Assert.Equal(fursuitBadges[0].Id, fursuitScoreboard.Value[1].BadgeId);
            Assert.Equal(fursuitBadges[1].Id, fursuitScoreboard.Value[2].BadgeId);
        }