Beispiel #1
0
        public static void AddVote(string Choice, GamePlayer Player)
        {
            if (m_IPsVotedAndVote.ContainsKey(Player.Client.TcpEndpointAddress))
            {
                //
                string oldVote = m_IPsVotedAndVote[Player.Client.TcpEndpointAddress];
                // int oldCount = m_MapsAndVotes[oldVote];
                int oldCount = 0;
                if (m_MapsAndVotes.ContainsKey(oldVote))
                {
                    oldCount = m_MapsAndVotes[oldVote] - 1;
                    m_MapsAndVotes.Remove(oldVote);
                }
                m_MapsAndVotes.Add(oldVote, oldCount);


                m_IPsVotedAndVote.Remove(Player.Client.TcpEndpointAddress);
                m_IPsVotedAndVote.Add(Player.Client.TcpEndpointAddress, Choice);

                //int newCount = m_MapsAndVotes[Choice];
                int newCount = 1;
                if (m_MapsAndVotes.ContainsKey(Choice))
                {
                    newCount = m_MapsAndVotes[Choice] + 1;
                    m_MapsAndVotes.Remove(Choice);
                }
                m_MapsAndVotes.Add(Choice, newCount);
            }
            else
            {
                m_IPsVotedAndVote.Add(Player.Client.TcpEndpointAddress, Choice);

                //int newCount = m_MapsAndVotes[Choice];
                int newCount = 1;
                if (m_MapsAndVotes.ContainsKey(Choice))
                {
                    newCount = m_MapsAndVotes[Choice] + 1;
                    m_MapsAndVotes.Remove(Choice);
                }
                m_MapsAndVotes.Add(Choice, newCount);
            }

            if (NumberOfVotes(Choice) > 29)
            {
                PvPHandler.setPvPZone(Choice);
            }
        }
Beispiel #2
0
        public string GetAllPorts(bool addAmounts)
        {
            string         str             = "";
            List <GameNPC> pvpSetupMarkers = WorldMgr.GetNPCsByGuild("PvP Setup", eRealm.None);

            if (pvpSetupMarkers.Count > 0)
            {
                foreach (GameNPC npc in pvpSetupMarkers)
                {
                    if (addAmounts)
                    {
                        str += "(" + PvPHandler.NumberOfVotes(npc.Name) + " Votes)";
                    }
                    str += " [" + npc.Name + "]\n";
                }
            }
            return(str);
        }
Beispiel #3
0
        public override bool WhisperReceive(GameLiving source, string text)
        {
            if (base.WhisperReceive(source, text))
            {
                GamePlayer player = source as GamePlayer;
                if (player == null)
                {
                    return(false);
                }

                if (text == "Change")
                {
                    PvPHandler.setPvPZone(PvPHandler.ZoneWithHighestAmountOfVotes());
                }
                if (text == "Voting")
                {
                    player.TempProperties.setProperty(IS_VOTING, true);
                    string str = "Which PvP Area do you wish to vote for? \n" + GetAllPorts(true) + " [Cancel] voting";
                    SendReply(player, str);
                }
                if (text == "Cancel" && player.TempProperties.getProperty <bool>(IS_VOTING) == true)
                {
                    player.TempProperties.removeProperty(IS_VOTING);
                    SendReply(player, "You have now cancelled your vote");
                }
                if (text == "Setup")
                {
                    player.MoveTo(70, 565006, 536702, 5983, 2561);
                    player.Bind(true);
                    return(true);
                }
                if (text == "PvP Zone")
                {
                    if (!PvPHandler.playerHasVoted(player))
                    {
                        player.TempProperties.setProperty(IS_VOTING, true);
                        string str = "Which PvP Area do you wish to vote for? \n" + GetAllPorts(true) + "";
                        SendReply(player, str);
                        return(true);
                    }
                    else
                    {
                        PvPHandler.PortToPvPZone(player);
                        return(true);
                    }
                }
                if (player.TempProperties.getProperty <bool>(IS_VOTING) == true)
                {
                    if (CheckIfStrIsAMob(text))
                    {
                        PvPHandler.AddVote(text, player);
                        player.TempProperties.removeProperty(IS_VOTING);
                        SendReply(player, "You have voted for " + text);
                    }
                }
                else if (player.Client.Account.PrivLevel > 2)
                {
                    if (CheckIfStrIsAMob(text))
                    {
                        PvPHandler.setPvPZone(text);
                    }
                }
                return(true);
            }

            return(false);
        }