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); }
private async Task CalculateEloAsync(GameObject game) { var gameMode = game.GetGameMode(); var eloHandler = new EloHandler(_db, Context.Guild.Id, gameMode); var gamePlayers = game.GetAllPlayers() .OrderBy(x => x.Rank); foreach (var gamePlayer in gamePlayers) { eloHandler.AddPlayer(gamePlayer.PlayerId, gamePlayer.Rank); } eloHandler.CalculateAndSaveElo(); var eloResults = eloHandler.GetEloResults(); foreach (var gamePlayer in gamePlayers) { var eloResult = eloResults.Single(x => x.PlayerId == gamePlayer.PlayerId); await SendMessageAsync($"`{gamePlayer.Rank}` {gamePlayer.Name} `{eloResult.PreviousElo}` => `{eloResult.Elo}` ({eloResult.Elo - eloResult.PreviousElo})"); Thread.Sleep(1500); // For suspense! } }