Exemple #1
0
        public async Task Elo(params string[] options)
        {
            var gameMode = GameMode.Variable;

            var suddendeathList = new List <string> {
                "suddendeath", "sd", "sudden", "death"
            };

            if (suddendeathList.Contains(options.FirstOrDefault()?.ToLower()))
            {
                gameMode = GameMode.SuddenDeath;
            }

            var eloHandler = new EloHandler(_db, Context.Guild.Id, gameMode);
            var eloSeason  = eloHandler.GetCurrentEloSeason();

            var message = $"`{gameMode}: {eloSeason.SeasonName}`";

            var playerElos = eloSeason.PlayerElos
                             .Where(x => x.GameMode == gameMode) // TODO: shouldn't have to do this since we instantiated the elohandler with gamemode. something needs to be fixed.
                             .OrderByDescending(x => x.Rating)
                             .ToList();

            foreach (var playerElo in playerElos)
            {
                message += $"\n{playerElo.Player.Name}: {playerElo.Rating}";
            }
            await SendMessageAsync(message);
        }
Exemple #2
0
        public void Test1()
        {
            ulong guildId   = 111111;
            ulong channelId = 123456;

            var game = new GameObject(_db, channelId, guildId);

            game.CreateGame();

            game.AddPlayer(1, "Dave");
            game.AddPlayer(2, "Courtney");
            game.SetModeSuddenDeath();
            //game.ShufflePlayers();
            game.StartNewRound(); // Rename to "Start Game" and then auto-call this after "Liar" ??
            game.SetPlayerDice(1, "1,2,3,4,5");
            game.SetPlayerDice(2, "2,3,4,5,6");

            game.Bid(1, 10, 6);
            var liarResult = game.Liar(2);

            var wasEliminated         = liarResult.PlayerWhoLostDice.IsEliminated;
            var numberOfDiceRemaining = liarResult.PlayerWhoLostDice.NumberOfDice;

            var gameMode    = game.GetGameMode();
            var eloHandler  = new EloHandler(_db, guildId, gameMode);
            var gamePlayers = game.GetAllPlayers();

            foreach (var gamePlayer in gamePlayers)
            {
                eloHandler.AddPlayer(gamePlayer.PlayerId, gamePlayer.Rank);
            }
            eloHandler.CalculateAndSaveElo();

            var eloResults = eloHandler.GetEloResults();

            var daveElo     = eloResults.Single(x => x.PlayerId == 1);
            var courtneyElo = eloResults.Single(x => x.PlayerId == 2);

            Assert.AreEqual(1510, courtneyElo.Elo);
            Assert.AreEqual(1500, courtneyElo.PreviousElo);
            Assert.AreEqual(1490, daveElo.Elo);
            Assert.AreEqual(1500, daveElo.PreviousElo);

            var eloSeason = eloHandler.GetCurrentEloSeason();

            Assert.AreEqual("Season Zero", eloSeason.SeasonName);
        }