Example #1
0
        public void AllIrcServerShutdown(string Message, bool reload = false)
        {
            foreach(var nw in _networks)
                nw.Value.sSender.Quit(Message);

            int i = 0;

            while(true)
            {
                if(i >= 30 && !reload)
                    break;

                var list = new List<bool>();

                foreach(var nw in _networks)
                    list.Add(nw.Value.Shutdown);

                if(list.CompareDataInBlock())
                {
                    list.Clear();
                    break;
                }
                else
                    Thread.Sleep(200);

                i++;
                list.Clear();
            }
        }
Example #2
0
        private void Game()
        {
            var sSendMessage = sIrcBase.Networks[_servername].sSendMessage;
            var text = sLManager.GetCommandTexts("maffiagame/base/game", _channel, _servername);
            if(text.Length < 43)
            {
                sSendMessage.SendCMPrivmsg(_channel, sLConsole.Translations("NoFound2", sLManager.GetChannelLocalization(_channel, _servername)));
                return;
            }

            try
            {
                bool newghost = false;
                bool enabledk = false;
                bool enableddoctor = false;
                bool enabledkiller = false;
                bool enableddetective = false;
                string names = string.Empty;
                string newkillghost = string.Empty;

                if(_players < 8)
                    sSendMessage.SendCMPrivmsg(_channel, text[0]);
                else if(_players >= 8 && _players < 15)
                    sSendMessage.SendCMPrivmsg(_channel, text[1]);
                else if(_players >= 15)
                    sSendMessage.SendCMPrivmsg(_channel, text[2]);

                sSendMessage.SendCMPrivmsg(_channel, text[3]);
                sSendMessage.SendCMPrivmsg(_channel, text[4]);
                sSendMessage.SendCMPrivmsg(_channel, text[5]);
                Thread.Sleep(2000);

                for(;;)
                {
                    Thread.Sleep(1000);

                    if(_killerlist.Count == 1 && Started)
                    {
                        foreach(var function in _playerflist)
                        {
                            if(function.Value.Rank == Rank.Killer && !function.Value.RName.IsNullOrEmpty() && !function.Value.Ghost)
                            {
                                newkillghost = GetPlayerName(function.Value.RName.Trim());
                                enabledkiller = true;
                            }
                            else if(function.Value.Rank == Rank.Killer && function.Value.RName.IsNullOrEmpty() && !function.Value.Ghost)
                                enabledkiller = false;
                        }
                    }
                    else if(_killerlist.Count == 2 && Started)
                    {
                        var list = new List<string>();

                        foreach(var function in _playerflist)
                        {
                            if(function.Value.Rank == Rank.Killer && !function.Value.RName.IsNullOrEmpty() && !function.Value.Ghost)
                                list.Add(function.Value.RName);
                            else if(function.Value.Rank == Rank.Killer && function.Value.RName.IsNullOrEmpty() && !function.Value.Ghost)
                                enabledkiller = false;
                        }

                        if(list.Count == 2)
                        {
                            if(list.CompareDataInBlock() && !enabledk)
                            {
                                foreach(var kill in _killerlist)
                                    sSendMessage.SendCMPrivmsg(kill.Key, text[6]);

                                enabledk = true;
                                newkillghost = GetPlayerName(list[0].Trim());
                                enabledkiller = true;
                            }
                            else if(!list.CompareDataInBlock())
                            {
                                enabledk = false;
                                newkillghost = string.Empty;
                                enabledkiller = false;
                            }
                        }

                        list.Clear();
                    }
                    else if(_killerlist.Count == 3 && Started)
                    {
                        var list = new List<string>();

                        foreach(var function in _playerflist)
                        {
                            if(function.Value.Rank == Rank.Killer && !function.Value.RName.IsNullOrEmpty() && !function.Value.Ghost)
                                list.Add(function.Value.RName);
                            else if(function.Value.Rank == Rank.Killer && function.Value.RName.IsNullOrEmpty() && !function.Value.Ghost)
                                enabledkiller = false;
                        }

                        if(list.Count == 3)
                        {
                            if(list.CompareDataInBlock() && !enabledk)
                            {
                                foreach(var kill in _killerlist)
                                    sSendMessage.SendCMPrivmsg(kill.Key, text[6]);

                                enabledk = true;
                                newkillghost = GetPlayerName(list[0].Trim());
                                enabledkiller = true;
                            }
                            else if(!list.CompareDataInBlock())
                            {
                                enabledk = false;
                                newkillghost = string.Empty;
                                enabledkiller = false;
                            }
                        }

                        list.Clear();
                    }

                    if(_detectivelist.Count == 1 && Started)
                    {
                        foreach(var function in _playerflist)
                        {
                            if(function.Value.Rank == Rank.Detective && function.Value.Detective && !function.Value.Ghost)
                                enableddetective = true;
                            else if(function.Value.Rank == Rank.Detective && !function.Value.Detective && !function.Value.Ghost)
                                enableddetective = false;
                        }
                    }
                    else if(_detectivelist.Count == 2 && Started)
                    {
                        int number = 0;

                        foreach(var function in _playerflist)
                        {
                            if(function.Value.Rank == Rank.Detective && function.Value.Detective && !function.Value.Ghost)
                                number++;
                            else if(function.Value.Rank == Rank.Detective && !function.Value.Detective && !function.Value.Ghost)
                                enableddetective = false;
                        }

                        if(number == 2)
                            enableddetective = true;
                    }
                    else if(_detectivelist.Count == 0 && Started)
                        enableddetective = true;

                    if(_doctorlist.Count == 1 && Started)
                    {
                        foreach(var function in _playerflist)
                        {
                            if(function.Value.Rank == Rank.Doctor && !function.Value.Ghost && (!function.Value.RName.IsNullOrEmpty() ||
                               function.Value.RName == "áá(%[[]][[]]killer[[]][[]]%)áá"))
                                enableddoctor = true;
                            else if(function.Value.Rank == Rank.Doctor && !function.Value.Ghost && function.Value.RName.IsNullOrEmpty())
                                enableddoctor = false;
                        }
                    }
                    else if(_doctorlist.Count == 0 && Started)
                        enableddoctor = true;

                    if(enabledkiller && enableddetective && enableddoctor && Started && Running)
                    {
                        foreach(var function in _playerflist)
                        {
                            if(function.Value.Rank == Rank.Doctor)
                            {
                                if((newkillghost.ToLower() != function.Value.RName) && (!newkillghost.ToLower().IsNullOrEmpty()) &&
                                   (newkillghost.ToLower() != "áá(%[[]][[]]killer[[]][[]]%)áá"))
                                    newghost = true;
                            }

                            function.Value.RName = string.Empty;
                        }

                        foreach(var function in _playerflist)
                        {
                            if(function.Value.Rank == Rank.Detective && function.Value.Detective && function.Value.DRank != Rank.None)
                            {
                                if((function.Key == newkillghost.ToLower() && newghost) ||
                                   (function.Key == newkillghost.ToLower() && _players < 8))
                                {
                                    function.Value.Detective = false;
                                    function.Value.DRank = Rank.None;
                                    continue;
                                }

                                if(function.Value.DRank == Rank.Killer)
                                    sSendMessage.SendCMPrivmsg(function.Key, text[7]);
                                else if(function.Value.DRank == Rank.Normal)
                                    sSendMessage.SendCMPrivmsg(function.Key, text[8]);
                                else if(function.Value.DRank == Rank.Doctor)
                                    sSendMessage.SendCMPrivmsg(function.Key, text[9]);
                                else if(function.Value.DRank == Rank.Detective)
                                    sSendMessage.SendCMPrivmsg(function.Key, text[10]);

                                function.Value.Detective = false;
                                function.Value.DRank = Rank.None;
                            }
                        }

                        _day = true;
                        _stop = false;
                        enabledk = false;
                        enabledkiller = false;
                        enableddoctor = false;
                        enableddetective = false;

                        if(_players >= 8)
                        {
                            if(newghost)
                                RemovePlayer(newkillghost, newkillghost);
                        }
                        else
                        {
                            newghost = true;
                            RemovePlayer(newkillghost, newkillghost);
                        }

                        EndGame(newkillghost, true);
                    }

                    if(!Started)
                        StopThread();

                    if(!_lynch)
                        EndGame();

                    if(!_day)
                    {
                        if(_stop)
                            continue;

                        _stop = true;

                        foreach(var function in _playerflist)
                            function.Value.Lynch.Clear();

                        if(NoVoice)
                            RemoveRanks(true);

                        names = string.Empty;

                        foreach(var name in _playerlist)
                            names += ", " + DisableHl(name.Value);

                        sSendMessage.SendCMPrivmsg(_channel, text[11], names.Remove(0, 2, ", "));
                        sSendMessage.SendCMPrivmsg(_channel, text[12]);
                        sSendMessage.SendCMPrivmsg(_channel, text[13]);
                        Thread.Sleep(1000);

                        foreach(var name in _killerlist)
                        {
                            sSendMessage.SendCMPrivmsg(name.Key, text[14]);
                            sSendMessage.SendCMPrivmsg(name.Key, text[15]);
                            sSendMessage.SendCMPrivmsg(name.Key, text[16]);
                            Thread.Sleep(400);
                        }

                        if(_players >= 8 && _players < 15 && _killerlist.Count == 2)
                        {
                            names = string.Empty;
                            foreach(var name in _killerlist)
                                names += SchumixBase.Space + name.Key;

                            names = names.Remove(0, 1, SchumixBase.Space);
                            var split = names.Split(SchumixBase.Space);

                            foreach(var name in _killerlist)
                            {
                                if(name.Key == split[0])
                                    sSendMessage.SendCMPrivmsg(name.Key, text[17], split[1]);
                                else
                                    sSendMessage.SendCMPrivmsg(name.Key, text[17], split[0]);

                                Thread.Sleep(400);
                            }
                        }
                        else if(_players >= 15)
                        {
                            foreach(var name in _killerlist)
                            {
                                sSendMessage.SendCMPrivmsg(name.Key, text[18], _killerchannel);
                                Thread.Sleep(400);
                            }
                        }

                        if(_players >= 8)
                        {
                            foreach(var name in _doctorlist)
                            {
                                sSendMessage.SendCMPrivmsg(name.Key, text[19]);
                                sSendMessage.SendCMPrivmsg(name.Key, text[20]);
                                Thread.Sleep(400);
                            }
                        }

                        foreach(var name in _detectivelist)
                        {
                            sSendMessage.SendCMPrivmsg(name.Key, text[21]);
                            sSendMessage.SendCMPrivmsg(name.Key, text[22]);
                            Thread.Sleep(400);
                        }
                    }
                    else
                    {
                        if(_stop)
                            continue;

                        _stop = true;
                        sSendMessage.SendCMPrivmsg(_channel, text[23]);

                        if(NoVoice)
                            AddRanks();

                        if(newghost)
                        {
                            sSendMessage.SendCMPrivmsg(_channel, text[24], DisableHl(newkillghost));

                            if(GetPlayerMaster(newkillghost))
                                sSendMessage.SendCMPrivmsg(_channel, text[25]);

                            Corpse(newkillghost);
                            sSendMessage.SendCMPrivmsg(_channel, text[26], DisableHl(newkillghost));
                        }
                        else
                            sSendMessage.SendCMPrivmsg(_channel, text[27]);

                        newghost = false;
                        newkillghost = string.Empty;

                        names = string.Empty;
                        foreach(var name in _playerlist)
                            names += ", " + name.Value;

                        sSendMessage.SendCMPrivmsg(_channel, text[28], names.Remove(0, 2, ", "));

                        /*names = string.Empty;
                        foreach(var name in _ghostlist)
                            names += ", " + DisableHl(name.Value);

                        sSendMessage.SendCMPrivmsg(_channel, "\u0002A következő személyek halottak: {0}\u000f", names.Remove(0, 2, ", "));*/
                        sSendMessage.SendCMPrivmsg(_channel, text[29], _ghostlist.Count);

                        if(!NoLynch)
                        {
                            sSendMessage.SendCMPrivmsg(_channel, text[30]);
                            sSendMessage.SendCMPrivmsg(_channel, text[31]);
                            sSendMessage.SendCMPrivmsg(_channel, text[32]);
                            sSendMessage.SendCMPrivmsg(_channel, text[33]);
                            sSendMessage.SendCMPrivmsg(_channel, text[34]);
                        }
                        else
                        {
                            sSendMessage.SendCMPrivmsg(_channel, text[35]);
                            sSendMessage.SendCMPrivmsg(_channel, text[36]);
                            Thread.Sleep(30*1000);
                            sSendMessage.SendCMPrivmsg(_channel, text[37]);
                            Thread.Sleep(30*1000);
                            sSendMessage.SendCMPrivmsg(_channel, text[38]);
                            Thread.Sleep(30*1000);
                            sSendMessage.SendCMPrivmsg(_channel, text[39]);
                            Thread.Sleep(20*1000);
                            sSendMessage.SendCMPrivmsg(_channel, text[40]);
                            Thread.Sleep(5*1000);
                            sSendMessage.SendCMPrivmsg(_channel, text[41]);
                            Thread.Sleep(5*1000);
                            sSendMessage.SendCMPrivmsg(_channel, text[42]);

                            _day = false;
                            _stop = false;
                        }
                    }
                }
            }
            catch(Exception e)
            {
                if(Running && Started)
                {
                    RemoveRanks();
                    sSendMessage.SendCMPrivmsg(_channel, sLManager.GetCommandText("maffiagame/base/exception", _channel, _servername), e.Message);
                    EndGameText();
                    EndText();
                    StopThread();
                }

                return;
            }
        }