Beispiel #1
0
        public static async Task <bool> runDayPhase(GamePlayerList g, DiscordClient _client)
        {
            EventHandler <MessageEventArgs> voteHandler = null;

            voteHandler              = new EventHandler <MessageEventArgs>((s, e) => VoteHandler(s, e, g, _client));
            _client.MessageReceived += voteHandler;

            await Task.Delay(TimeConverter.MinToMS((g.PhaseLengthInMin / 2)), g.Token.Token);

            VoteTallyCommand.countVotes(g);
            int           i = 0; string playerList = "";
            List <Player> SortedList = g.Objects.Where(x => x.Alive == true).OrderByDescending(o => o.VotesOn).ToList();

            foreach (var item in SortedList)
            {
                i++;
                try
                {
                    playerList += $"{i}. {item.User.Name} " + item.VotesOn + ": " + VoteTallyCommand.votedFor(SortedList, item) + "\n";
                }
                catch (Exception) { }
            }
            await g.GameChat.SendMessage($":warning: There are only {g.PhaseLengthInMin/2} minutes left in the day phase. :warning:\n\nMid day vote count:\n```{playerList}```");

            await Task.Delay(TimeConverter.MinToMS((g.PhaseLengthInMin / 2)), g.Token.Token);

            _client.MessageReceived -= voteHandler;
            return(true);
        }
Beispiel #2
0
        public static async Task <bool> runDayRecap(GamePlayerList g)
        {
            g.Phase = Phases.Night;

            await g.GameChat.SendMessage(":city_sunset: @everyone the Day phase has ended! Recapping now... :city_sunset: ");

            foreach (var item in g.Objects.Where(x => x.Alive == true))
            {
                await g.GameChat.AddPermissionsRule(item.User, new ChannelPermissionOverrides(readMessages : PermValue.Allow, sendMessages : PermValue.Deny));
            }

            VoteTallyCommand.countVotes(g);

            Player[] list = g.Objects.OrderByDescending(x => x.VotesOn).ToArray();

            if (list.Where(x => x.VotesOn == list[0].VotesOn).Count() > 1)
            {
                await g.GameChat.SendMessage("It seems like everyone was very indecisive today,\nand because of there being no majority, nobody got lynched.");
            }
            else
            {
                list[0].Alive = false;
                if (list[0].Role.Allignment == Roles.RoleUtil.Allignment.Mafia)
                {
                    g.MafiaAlive--;
                }
                else if (list[0].Role.Allignment == Roles.RoleUtil.Allignment.Town)
                {
                    g.TownAlive--;
                }

                await g.GameChat.SendMessage($"It seems like all of you have decided on your lynch target, **{list[0].User.Name}**, so let's see what they are!");

                await g.GameChat.SendMessage($"**Role PM:**\n```{list[0].Role.RolePM}```\n");
            }

            if (await checkWinConditions(g))
            {
                return(true);
            }

            await g.GameChat.SendMessage($":full_moon: It is now Night {g.PhaseCounter}. The phase will end in {g.PhaseLengthInMin/2} minutes. :full_moon:");

            foreach (var item in g.Objects)
            {
                if (item.Alive == true)
                {
                    await g.GameChat.AddPermissionsRule(item.User, new ChannelPermissionOverrides(readMessages : PermValue.Allow, sendMessages : PermValue.Allow));
                }
                else
                {
                    if (item.Role.Allignment == Roles.RoleUtil.Allignment.Mafia)
                    {
                        await g.MafiaChat.AddPermissionsRule(item.User, new ChannelPermissionOverrides(readMessages : PermValue.Allow, sendMessages : PermValue.Deny));
                    }
                }

                item.LynchTarget = null;
            }
            return(true);
        }