Example #1
0
        private DiscordPlayer CreateAndGetDiscordPlayer(ulong userId, string name, bool isBot)
        {
            var discordPlayer = _db.DiscordPlayers
                                .Include(x => x.Player)
                                .Where(x => x.GuildId == _guildId)
                                .SingleOrDefault(x => x.UserId == userId);

            if (discordPlayer != null)
            {
                return(discordPlayer);
            }

            discordPlayer = new DiscordPlayer
            {
                GuildId         = _guildId,
                UserId          = userId,
                IsAdministrator = false,
                Player          = new Player
                {
                    Name = name
                },
                IsBot  = isBot,
                BotKey = name
            };
            _db.DiscordPlayers.Add(discordPlayer);
            _db.SaveChanges();

            return(discordPlayer);
        }
Example #2
0
        public void CalculateAndSaveElo()
        {
            _match.CalculateElos(20);

            var playerResults = _match.GetPlayers();

            foreach (var playerData in playerResults)
            {
                SetEloForPlayer(playerData.PlayerId, playerData.EloPost);
            }
            _db.SaveChanges();
        }
Example #3
0
        public void SetPlayerDice(int playerId, string dice)
        {
            var gamePlayer = _game.GamePlayers.Single(x => x.Player.Id == playerId);

            gamePlayer.CurrentGamePlayerRound.Dice = dice;
            _db.SaveChanges();
        }