Ejemplo n.º 1
0
        private async Task EndGameWithWinner(GroupType winningGroup)
        {
            List <PlayerReward> players = await RewardPlayers(Phases.ToList(), winningGroup);

            await DayChannel.SendMessageAsync(GameEndView.Message(winningGroup));

            await DayChannel.SendMessageAsync(string.Empty, false, GameEndView.Of(winningGroup, players));

            await Dispose();
        }
Ejemplo n.º 2
0
        public async Task PlayerRewardsTest()
        {
            IEnumerable <IUser> users          = _client.Guilds.SelectMany(g => g.Users).Take(8);
            GameObject          game           = new GameObject(users.ToList());
            Random random                      = new Random(Guid.NewGuid().GetHashCode());
            ICollection <GamePhase> gamePhases = new List <GamePhase>();

            while (!InformedGroupWins(game) && !InformedGroupWins(game))
            {
                List <Player> activePlayers     = game.Players.Where(p => p.Active).ToList();
                Player        playerToBeRemoved = activePlayers[random.Next(activePlayers.Count)];
                RemoveUserFromPlay(playerToBeRemoved.User, game);
                gamePhases.Add(new GamePhase
                {
                    Target = playerToBeRemoved.User,
                    Phase  = playerToBeRemoved.Group == GroupType.Informed ? PhaseType.Day : PhaseType.Night
                });
            }
            GroupType           winers  = InformedGroupWins(game) ? GroupType.Informed : GroupType.Uninformed;
            List <PlayerReward> rewards = GetPlayerRewards(game, gamePhases, game.Players.ToList(), winers);
            IUser me = _client.Guilds.SelectMany(g => g.Users).FirstOrDefault(u => u.Username == "JJ 3maj");
            await me.SendMessageAsync(string.Empty, false, GameEndView.Of(winers, rewards));
        }