Exemplo n.º 1
0
        private async Task DisplayCurrentStandings(Game game)
        {
            var players   = _perudoGameService.GetGamePlayers(game).Where(x => x.NumberOfDice > 0);
            var totalDice = players.Sum(x => x.NumberOfDice);



            var playerList = string.Join("\n", players.Select(x =>
                                                              $"`{x.NumberOfDice}` {x.PlayerId.GetChristmasEmoji(game.Id)} {x.Player.Nickname} {GetGhostStatus(x)}{GetDealStatus(x)}"));


            var diceRange = game.HighestPip - game.LowestPip + 1;
            //var wildsEnabled = game.LowestPip == 1;
            var probability = diceRange * 1.0;

            probability = probability / 2.0;

            var probabilityString = $"{probability:F1}";

            if (probability == Math.Floor(probability))
            {
                probabilityString = $"{probability:F0}";
            }

            var quickmaths = $"Quick maths: {totalDice}/{probabilityString} = `{totalDice / probability:F2}`";

            //if (game.NextRoundIsPalifico) quickmaths = $"Quick maths: {totalDice}/{diceRange} = `{totalDice / (diceRange * 1.0):F2}`";
            if (players.Sum(x => x.NumberOfDice) == 2 && game.FaceoffEnabled)
            {
                quickmaths = $"Quick maths:\n" +
                             $"1 = `{600 / 6.0:F2}%`\n" +
                             $"2 = `{500 / 6.0:F2}%`\n" +
                             $"3 = `{400 / 6.0:F2}%`\n" +
                             $"4 = `{300 / 6.0:F2}%`\n" +
                             $"5 = `{200 / 6.0:F2}%`\n" +
                             $"6 = `{100 / 6.0:F2}%`";
            }
            //if (game.LowestPip != 1 || game.HighestPip != 6)  quickmaths = "Quickmaths: :upside_down:";

            var builder = new EmbedBuilder()
                          .WithTitle(":deciduous_tree: Current standings :deciduous_tree:")
                          .AddField("Players", $"{playerList}\n\nTotal dice left: `{totalDice}`\n{quickmaths}", inline: false);
            var embed = builder.Build();

            await Context.Channel.SendMessageAsync(
                embed : embed)
            .ConfigureAwait(false);
        }
Exemplo n.º 2
0
        private async Task DisplayCurrentStandingsForBots(Game game)
        {
            return; // Andrey: Don't need bot standings for now, disabled to message spam

            var gamePlayers = _perudoGameService.GetGamePlayers(game);

            if (!gamePlayers.Any(x => x.Player.IsBot))
            {
                return;
            }

            gamePlayers = gamePlayers.Where(x => x.NumberOfDice > 0).ToList();
            var totalDice = gamePlayers.Sum(x => x.NumberOfDice);

            var currentStandings = new
            {
                Players      = gamePlayers.Select(x => new { Username = x.Player.Nickname, DiceCount = x.NumberOfDice }),
                TotalPlayers = gamePlayers.Count(),
                TotalDice    = totalDice
            };

            await SendMessageAsync($"Current standings for bots: ||{JsonConvert.SerializeObject(currentStandings)}||");
        }
Exemplo n.º 3
0
        public async Task NewGameAsync(params string[] stringArray)
        {
            if (_db.Games
                .AsQueryable()
                .Where(x => x.ChannelId == Context.Channel.Id)
                .Where(x => x.State == (int)(object)GameState.InProgress ||
                       x.State == (int)(object)GameState.Setup)
                .Any())
            {
                string message = $"A game already being set up or is in progress.";
                await SendMessageAsync(message);

                return;
            }

            var game = new Game
            {
                ChannelId               = Context.Channel.Id,
                State                   = 0,
                DateCreated             = DateTime.Now,
                NumberOfDice            = 5,
                Penalty                 = 0,
                NextRoundIsPalifico     = false,
                RandomizeBetweenRounds  = false,
                WildsEnabled            = true,
                ExactCallBonus          = 1,
                ExactCallPenalty        = 0,
                CanCallExactAnytime     = true,
                CanCallLiarAnytime      = true,
                CanBidAnytime           = false,
                Palifico                = true,
                IsRanked                = true,
                GuildId                 = Context.Guild.Id,
                FaceoffEnabled          = true,
                CanCallExactToJoinAgain = false,
                StatusMessage           = 0,
                LowestPip               = 1,
                HighestPip              = 6,
                PenaltyGainDice         = false,
                TerminatorMode          = false
            };

            _db.Games.Add(game);
            _db.SaveChanges();

            var commands =
                $"`!add/remove @player` to add/remove players.\n" +
                $"`!option xyz` to set round options.\n" +
                $"`!status` to view current status.\n" +
                $"`!start` to start the game.";

            var builder = new EmbedBuilder()
                          .WithTitle($"New game #{game.Id} created")
                          .AddField("Commands", commands, inline: false);
            var embed = builder.Build();
            await Context.Channel.SendMessageAsync(embed : embed).ConfigureAwait(false);

            AddUsers(game, Context.Message);
            try
            {
                await SetOptionsAsync(stringArray);
            }
            catch (Exception e)
            {
                var a = "monkey";
            }

            await Status();
            await ReplyAsync("PS: Palifico rounds _now count wilds_");
            await ReplyAsync("PPS: Exact will get you a die back _even when it's your turn_");
        }