예제 #1
0
        private string provideRoleCardString(ResistancePlayer player)
        {
            string toSend = "";

            toSend += "```" + player.getPlayerName() + ", you are a " + player.getPlayerRoleString() + " in a RESISTANCE lobby on server " + getClient().GetServer(getGameServerID()).Name;
            if (player.getAllegiance() == ALLEGIANCE.SPY)
            {
                toSend += "\n\nThe list of spies are: " + getSpies();
            }
            toSend += "```";
            return(toSend);
        }
예제 #2
0
        private string getCurrentTeamString()
        {
            Mission thisMission = getCurrentMission();
            string  listPlayers = "```";

            listPlayers += "Current team composition for mission " + currentMission + "\n\n";
            if (!playersOnMission.Any())
            {
                listPlayers += "There is no team currently proposed.\n\n";
            }
            else
            {
                for (int i = 0; i < playersOnMission.Count(); i++)
                {
                    int list = i + 1;
                    ResistancePlayer currentPlayer = playersOnMission.ElementAt(i);
                    listPlayers += list + ") " + currentPlayer.getPlayerName() + "\n";
                }
            }
            listPlayers += "\nThis team requires " + thisMission.getRequiredPlayers() + " players. Spies need " + thisMission.getRequiredFails() + " fails to sabotage this mission.```";
            return(listPlayers);
        }
예제 #3
0
        private string presentMissionLeader()
        {
            ResistancePlayer player = players.ElementAt(missionLeaderIndex);

            return("The current mission leader is " + player.getPlayerNickname());
        }
예제 #4
0
        public override async void evaluateInput(string input, MessageEventArgs e)
        {
            string[] toParse     = input.Split(' ');
            string   command     = toParse[0];
            int      inputLen    = toParse.Length;
            Channel  gameChannel = getClient().GetChannel(getTextChannelID());
            Server   gameServer  = getClient().GetServer(getGameServerID());

            if (command == "")
            {
                return;
            }
            else if (command == Constants.COMMAND_CANCELPARTYGAME && e.User.Id == getHostID())
            {
                if (!getGameStarted())
                {
                    setGameForDeletion();
                    await getClient().GetChannel(getParentChannel()).SendMessage(getGameType() + SystemMessages.MESSAGE_GAMECANCELED);
                }
            }
            else if (command == Constants.COMMAND_STARTGAME && e.User.Id == getHostID())
            {
                start = true;
            }
            else if (!getGameStarted())
            {
                return;
            }
            else
            {
                if (e.Channel.IsPrivate)
                {
                    string           toSend     = "";
                    ResistancePlayer thisPlayer = findPlayer(e.User.Id);
                    if (thisPlayer == null)
                    {
                        await getClient().GetChannel(getTextChannelID()).SendMessage("Exception: Resistance Player is null.");
                    }
                    else if (command == Constants.Resistance.PRIVATECOMMAND_ROLECARD)
                    {
                        await e.Channel.SendMessage(provideRoleCardString(thisPlayer));
                    }
                    else if (GameState() == GAMESTATE.VOTEONTEAM)
                    {
                        if (command == Constants.Resistance.PRIVATECOMMAND_ACCEPTTEAM)
                        {
                            if (thisPlayer.getTeamVote() != TEAMVOTE.NOTSUBMITTED)
                            {
                                toSend += "You have already submitted a vote!";
                            }
                            else
                            {
                                thisPlayer.setTeamVote(TEAMVOTE.APPROVED);
                                toSend += "You have approved this team draft.";
                            }
                            toSend += provideChannelLink();
                            await e.Channel.SendMessage(toSend);
                        }
                        else if (command == Constants.Resistance.PRIVATECOMMAND_REJECTTEAM)
                        {
                            if (thisPlayer.getTeamVote() != TEAMVOTE.NOTSUBMITTED)
                            {
                                toSend += "You have already submitted a vote!";
                            }
                            else
                            {
                                thisPlayer.setTeamVote(TEAMVOTE.REJECTED);
                                toSend += "You have rejected this team draft.";
                            }
                            toSend += provideChannelLink();
                            await e.Channel.SendMessage(toSend);
                        }
                    }
                    else if (GameState() == GAMESTATE.VOTEMISSION)
                    {
                        if (command == Constants.Resistance.PRIVATECOMMAND_PASS)
                        {
                            if (thisPlayer.getMissionVote() != MISSIONVOTE.NOTSUBMITTED)
                            {
                                toSend += "You have already submitted a vote!";
                            }
                            else
                            {
                                thisPlayer.setMissionVote(MISSIONVOTE.PASSED);
                                toSend += "You have succeeded your objective.";
                            }
                            toSend += provideChannelLink();
                            await e.Channel.SendMessage(toSend);
                        }
                        else if (command == Constants.Resistance.PRIVATECOMMAND_FAIL)
                        {
                            if (thisPlayer.getMissionVote() != MISSIONVOTE.NOTSUBMITTED)
                            {
                                toSend += "You have already submitted a vote!";
                            }
                            else if (thisPlayer.getAllegiance() == ALLEGIANCE.RESISTANCE)
                            {
                                thisPlayer.setMissionVote(MISSIONVOTE.PASSED);
                                toSend += "Resistance members can only choose to pass! Your vote has been submitted as " + Constants.Resistance.PRIVATECOMMAND_PASS + ".";
                            }
                            else
                            {
                                thisPlayer.setMissionVote(MISSIONVOTE.FAILED);
                                toSend += "You have sabotaged this mission.";
                            }
                            toSend += provideChannelLink();
                            await e.Channel.SendMessage(toSend);
                        }
                    }
                }
                else if (command == Constants.Resistance.COMMAND_HELP)
                {
                    await e.Channel.SendMessage(provideHelpString());
                }
                else if (command == Constants.Resistance.COMMAND_LISTPLAYERS)
                {
                    string listPlayers = "```";
                    for (int i = 0; i < players.Count(); i++)
                    {
                        int list = i + 1;
                        ResistancePlayer currentPlayer = players.ElementAt(i);
                        listPlayers += list + ") " + currentPlayer.getPlayerName() + "\n";
                    }
                    listPlayers += "```";
                    await getClient().GetChannel(getTextChannelID()).SendMessage(listPlayers);
                }
                else if (command == Constants.Resistance.COMMAND_LISTCURRENTTEAM)
                {
                    Mission thisMission = getCurrentMission();
                    if (GameState() == GAMESTATE.TEAMDRAFT || GameState() == GAMESTATE.VOTEONTEAM)
                    {
                        await getClient().GetChannel(getTextChannelID()).SendMessage(getCurrentTeamString());
                    }
                }
                else if (command == Constants.Resistance.COMMAND_CONFIRMDRAFT && GameState() == GAMESTATE.TEAMDRAFT)
                {
                    string confirm = "";
                    if (e.User.Id != missionLeader)
                    {
                        confirm += "You cannot draft a team because you are not the mission leader! The current mission leader is: " + players.ElementAt(missionLeaderIndex).getPlayerNickname();
                    }
                    else if (playersOnMission.Count() == getCurrentMission().getRequiredPlayers())
                    {
                        confirm += "After deliberation, " + players.ElementAt(missionLeaderIndex).getPlayerNickname()
                                   + " has decided to finalize on the team draft. Go to your PMs (top left corner of Discord client) OR click on "
                                   + getClient().CurrentUser.Mention + " and privately message me " + Constants.Resistance.PRIVATECOMMAND_ACCEPTTEAM
                                   + " if you agree with this team draft, or " + Constants.Resistance.PRIVATECOMMAND_REJECTTEAM + " if you disagree.";
                        foreach (ResistancePlayer player in players)
                        {
                            await gameServer.GetUser(player.getPlayerID()).SendMessage(getCurrentTeamString() + Constants.Resistance.PRIVATECOMMAND_ACCEPTTEAM
                                                                                       + " if you agree with this draft.\n" + Constants.Resistance.PRIVATECOMMAND_REJECTTEAM
                                                                                       + " if you disagree with this draft.");
                        }
                        setGameState(GAMESTATE.VOTEONTEAM);
                    }
                    else
                    {
                        confirm += "You must draft a full team before you can confirm it!";
                    }
                    await gameChannel.SendMessage(confirm);
                }
                else if (command == Constants.Resistance.COMMAND_CLEARDRAFT && GameState() == GAMESTATE.TEAMDRAFT)
                {
                    string confirm = "";
                    if (e.User.Id != missionLeader)
                    {
                        confirm += "You cannot draft a team because you are not the mission leader! The current mission leader is: " + players.ElementAt(missionLeaderIndex).getPlayerNickname();
                    }
                    else
                    {
                        confirm += "Team draft is cleared: please start a new draft.";
                        playersOnMission.Clear();
                    }
                    await gameChannel.SendMessage(confirm);
                }
                else if (command == Constants.Resistance.COMMAND_LISTSITUATION)
                {
                    await getClient().GetChannel(getTextChannelID()).SendMessage(getCurrentSituationString());
                }
                else if (command == Constants.Resistance.COMMAND_DRAFT && GameState() == GAMESTATE.TEAMDRAFT)
                {
                    string toSend = "";
                    if (e.User.Id != missionLeader)
                    {
                        toSend += "You cannot draft a team because you are not the mission leader! The current mission leader is: " + players.ElementAt(missionLeaderIndex).getPlayerNickname();
                        await gameChannel.SendMessage(toSend);

                        return;
                    }
                    else if (inputLen < 2)
                    {
                        toSend += "USAGE: " + Constants.Resistance.COMMAND_DRAFT + " #/name #/name ..., where # corresponds to the # the player is ordered in !mlistplayers, or their name.";
                        await gameChannel.SendMessage(toSend);

                        return;
                    }
                    else
                    {
                        for (int i = 1; i < toParse.Length; i++)
                        {
                            if (playersOnMission.Count() == getCurrentMission().getRequiredPlayers())
                            {
                                toSend += "The team is drafted. Use " + Constants.Resistance.COMMAND_CONFIRMDRAFT + " to confirm this draft or " + Constants.Resistance.COMMAND_CLEARDRAFT + " to clear this draft.";
                                await gameChannel.SendMessage(toSend + getCurrentTeamString());

                                return;
                            }
                            else
                            {
                                bool             dontAdd     = false;
                                ResistancePlayer toAddPlayer = retrievePlayer(toParse[i]);
                                if (toAddPlayer != null)
                                {
                                    if (!playersOnMission.Any())
                                    {
                                        playersOnMission.Add(toAddPlayer);
                                    }
                                    else
                                    {
                                        foreach (ResistancePlayer player in playersOnMission)
                                        {
                                            if (toAddPlayer.getPlayerID() == player.getPlayerID())
                                            {
                                                dontAdd = true;
                                                break;
                                            }
                                        }
                                        if (!dontAdd)
                                        {
                                            playersOnMission.Add(toAddPlayer);
                                        }
                                    }
                                }
                            }
                        }
                        toSend += getCurrentTeamString();
                    }
                    await gameChannel.SendMessage(toSend);
                }
            }
        }