Example #1
0
        private void ReadAutoAnswer(XmlReader xmlReader)
        {
            bool active;

            if (!bool.TryParse(xmlReader[ConstAttibuteDoAutoAnswer], out active))
            {
                active = ConstDoAutoAnswerDefault;
            }

            DoAutoAnswer = active;
            if (xmlReader[ConstAttibuteAutoAnswer] != null)
            {
                AutoAnswer = xmlReader[ConstAttibuteAutoAnswer];
            }

            AutoAnswerMachine.SetAnswers(AutoAnswer);
        }
Example #2
0
        internal static string ChatFilter(string message)
        {
            var xpstr = HelperStrings.SubString(message, "Получено <font color=#CC0000>боевого</font> опыта: <b><font color=#CC0000>", "</font></b>.");

            if (!string.IsNullOrEmpty(xpstr))
            {
                long xp;
                if (long.TryParse(xpstr, out xp))
                {
                    try
                    {
                        if (AppVars.MainForm != null)
                        {
                            AppVars.MainForm.BeginInvoke(
                                new UpdateXPIncDelegate(AppVars.MainForm.UpdateXPInc),
                                new object[] { xp });
                        }
                    }
                    catch (InvalidOperationException)
                    {
                    }
                }
            }

            // <font class=chattime>&nbsp;23:56:08&nbsp;</font>
            // Результат обыска бота: <B>Денежные средства «19 NV», Денежные средства «30 NV»</B>.
            // Результат обыска бота: <B>Вещь «Кинжал Разбойника»</B>.

            //message =
            //    "<font class=chattime>&nbsp;23:56:08&nbsp;</font> <font color=000000><B><font color=#CC0000>Внимание!</font> Системная информация.</B> Результат обыска бота: <B>Денежные средства «19 NV», Денежные средства «30 NV»</B>.</font><br>";

            var thingstr = HelperStrings.SubString(message, "Результат обыска бота: <B>", "</B>.");

            if (!string.IsNullOrEmpty(thingstr))
            {
                var timestr = HelperStrings.SubString(message, "<font class=chattime>&nbsp;", "&nbsp;</font> <font color=000000><B><font color=#CC0000>Внимание!</font> Системная информация.</B> Результат обыска бота: ");
                if (!string.IsNullOrEmpty(timestr))
                {
                    var          thinglist = new List <string>();
                    const string pattern   = @"«([^»]+)»";
                    foreach (Match match in Regex.Matches(thingstr, pattern))
                    {
                        thinglist.Add(match.ToString().Trim(new[] { '«', '»' }));
                    }

                    if (thinglist.Count > 0)
                    {
                        try
                        {
                            if (AppVars.MainForm != null)
                            {
                                AppVars.MainForm.BeginInvoke(
                                    new UpdateThingIncDelegate(AppVars.MainForm.UpdateThingInc),
                                    new object[] { timestr, thinglist });
                            }
                        }
                        catch (InvalidOperationException)
                        {
                        }
                    }
                }
            }

            // <font class=clchattime>&nbsp;16:45:54&nbsp;</font> >>> <SPAN alt="%Josaphina">Josaphina</SPAN>  > clan: > <SPAN alt="%Josaphina">Райская Птица</SPAN>: <font color=CC0099>+</font>

            if (message.IndexOf("<font color=#000000><b>Системная информация.</b></font> Поединок завершён.", StringComparison.OrdinalIgnoreCase) != -1)
            {
                // Конец боя
                if (!string.IsNullOrEmpty(AppVars.LastBoiLog) &&
                    !string.IsNullOrEmpty(AppVars.LastBoiSostav) &&
                    !string.IsNullOrEmpty(AppVars.LastBoiTravm) &&
                    !string.IsNullOrEmpty(AppVars.LastBoiUron))
                {
                    var newLog =
                        "Бой" +
                        AppVars.LastBoiTravm +
                        " против " +
                        AppVars.LastBoiSostav +
                        @" завершен (<a href=http://www.neverlands.ru/logs.fcg?fid=" +
                        AppVars.LastBoiLog +
                        @" onclick=""window.open(this.href);"">лог</a> боя). Нанесено урона: <FONT color=#339900><b>" +
                        AppVars.LastBoiUron +
                        "</b></FONT>";

                    /*@" target=_blank>лог</a> боя). Нанесено урона: <FONT color=#339900><b>" +*/
                    /*@" onclick=""window.open(this.href);"">лог</a> боя). Нанесено урона: <FONT color=#339900><b>" +*/

                    message = message.Replace("Поединок завершён", newLog);
                    var pos = message.IndexOf("Получено <font color=#004BBB>магического", StringComparison.OrdinalIgnoreCase);
                    if (pos != -1)
                    {
                        const string se   = "</font></b>.";
                        var          spos = message.IndexOf(se, pos, StringComparison.OrdinalIgnoreCase);
                        if (spos != -1)
                        {
                            message = message.Remove(pos, spos + se.Length - pos);
                        }
                    }

                    var texlogMessage =
                        "Бой против " +
                        AppVars.LastBoiSostav +
                        @" завершен (" +
                        AppVars.LastBoiLog +
                        @")";
                    try
                    {
                        if (AppVars.MainForm != null)
                        {
                            AppVars.MainForm.BeginInvoke(
                                new UpdateTexLogDelegate(AppVars.MainForm.UpdateTexLog),
                                new object[] { texlogMessage });
                        }
                    }
                    catch (InvalidOperationException)
                    {
                    }

                    AppVars.LastBoiLog    = string.Empty;
                    AppVars.LastBoiSostav = string.Empty;
                }
            }
            else
            {
                /*
                 * message = "<font class=prchattime>&nbsp;11:22:41&nbsp;</font> >>> <SPAN alt=\"%МасКит\">МасКит</SPAN>  > <SPAN alt=\"%Умник\">Умник</SPAN>: <font color=000000>хай</font> ";
                 * message = "<font class=yochattime>&nbsp;10:46:03&nbsp;</font> <SPAN>МасКит</SPAN>&nbsp;для <SPAN alt=\"Умник\">Умник</SPAN>: <font color=000000>я, а что?</font> ";
                 * message = "<font class=clchattime>&nbsp;16:45:54&nbsp;</font> >>> <SPAN alt=\"%Josaphina\">Josaphina</SPAN>  > clan: > <SPAN alt=\"%Умник\">Умник</SPAN>: <font color=CC0099>+</font> ";
                 */

                var posSpanEnd = message.IndexOf(@""">" + AppVars.Profile.UserNick + "</SPAN>", StringComparison.OrdinalIgnoreCase);
                if (posSpanEnd != -1)
                {
                    const string strSpanStart = "<SPAN title=\"";
                    const string strSpanEnd   = "\">";
                    var          fromNick     = HelperStrings.SubString(message, strSpanStart, strSpanEnd).TrimStart(new[] { '%' });
                    if (!fromNick.Equals(AppVars.Profile.UserNick, StringComparison.OrdinalIgnoreCase))
                    {
                        EventSounds.PlaySndMsg();
                        var istoclan = message.IndexOf(" > clan: ", StringComparison.OrdinalIgnoreCase) != -1;
                        var istopair = message.IndexOf(" > pair: ", StringComparison.OrdinalIgnoreCase) != -1;
                        if (AppVars.Profile.DoAutoAnswer)
                        {
                            var answer = "%<" + fromNick + "> " + AutoAnswerMachine.GetNextAnswer();
                            if (istoclan)
                            {
                                answer = answer.Insert(0, "%clan%");
                            }
                            else
                            if (istopair)
                            {
                                answer = answer.Insert(0, "%pair%");
                            }

                            Chat.AddAnswer(answer);
                        }
                    }
                }

                if (AppVars.Profile.DoChatLevels)
                {
                    posSpanEnd = message.IndexOf("</SPAN>", StringComparison.OrdinalIgnoreCase);
                    if (posSpanEnd != -1)
                    {
                        var posSpanTagEnd = message.LastIndexOf('>', posSpanEnd);
                        if (posSpanTagEnd != -1)
                        {
                            var sayNick = message.Substring(posSpanTagEnd + 1, posSpanEnd - posSpanTagEnd - 1);
                            if (ChatUsersManager.Exists(sayNick))
                            {
                                var posSpanTagStart = message.LastIndexOf('<', posSpanTagEnd);
                                if (posSpanTagStart != -1)
                                {
                                    var chatUser = ChatUsersManager.GetUserData(sayNick);
                                    if (!string.IsNullOrEmpty(chatUser.Level))
                                    {
                                        message = message.Insert(posSpanEnd + "</SPAN>".Length,
                                                                 "&nbsp;[" + chatUser.Level +
                                                                 @"]<a href=""http://www.neverlands.ru/pinfo.cgi?" +
                                                                 chatUser.Nick +
                                                                 @""" onclick=""window.open(this.href);""><img src=http://image.neverlands.ru/chat/info.gif width=11 height=12 border=0 align=bottom></a>");
                                    }

                                    var sb = new StringBuilder();
                                    if (!string.IsNullOrEmpty(chatUser.Sign))
                                    {
                                        sb.Append("<img src=http://image.neverlands.ru/signs/");
                                        sb.Append(chatUser.Sign);
                                        sb.Append(@" width=15 height=12 align=bottom title=""");
                                        sb.Append(chatUser.Status);
                                        sb.Append(@""">&nbsp;");
                                    }

                                    message = message.Insert(posSpanTagStart, sb.ToString());
                                }
                            }
                        }
                    }
                }
            }

            // >>> <SPAN alt="%Not Alone">Not Alone</SPAN>  > clan: > <SPAN alt="%Not Alone">Райская Птица</SPAN>:

            if (message.IndexOf("pair:", StringComparison.OrdinalIgnoreCase) != -1)
            {
                message = message.Replace("<SPAN title=\"%", "<SPAN title=\"%%%");
            }
            else
            {
                if (message.IndexOf("clan:", StringComparison.OrdinalIgnoreCase) != -1)
                {
                    message = message.Replace("<SPAN title=\"%", "<SPAN title=\"%%");
                }
            }

            do
            {
                var pos1 = message.IndexOf("[[[", StringComparison.Ordinal);
                if (pos1 == -1)
                {
                    break;
                }

                var pos2 = message.IndexOf("]]]", pos1, StringComparison.Ordinal);
                if (pos2 == -1)
                {
                    break;
                }

                var    sorig = message.Substring(pos1 + 3, pos2 - pos1 - 3);
                string msg   = string.Empty;
                if (!sorig.Contains(":"))
                {
                    msg =
                        $"<a href=http://www.neverlands.ru/logs.fcg?fid={sorig} onclick=\"window.open(this.href);\">лог</a> боя";
                }

                message = string.Concat(message.Substring(0, pos1), msg, message.Substring(pos2 + 3));
            } while (true);

            Chat.AddStringToChat(message);
            return(message);
        }
Example #3
0
        private void OnButtonOkClick(object sender, EventArgs e)
        {
            AppVars.Profile.DoAutoDrinkBlaz = checkBoxDoAutoDrinkBlaz.Checked;
            int autoDrinkBlazTied;

            if (!int.TryParse(textBoxAutoDrinkBlazTied.Text, out autoDrinkBlazTied))
            {
                autoDrinkBlazTied = 84;
            }

            AppVars.Profile.AutoDrinkBlazTied = autoDrinkBlazTied;

            AppVars.Profile.DoPromptExit    = checkboxDoPromptExit.Checked;
            AppVars.Profile.DoTray          = checkboxDoTray.Checked;
            AppVars.Profile.ShowTrayBaloons = checkboxShowTrayBaloons.Checked;

            AppVars.Profile.ChatKeepMoving = checkboxDoKeepChatMoving.Checked;
            AppVars.Profile.ChatKeepGame   = checkboxDoKeepChatGame.Checked;
            AppVars.Profile.ChatKeepLog    = checkboxDoKeepChatLog.Checked;
            AppVars.Profile.ChatSizeLog    = (int)linkChatSizeLog.Tag;
            AppVars.Profile.DoChatLevels   = checkDoChatLevels.Checked;

            AppVars.Profile.DoRob = checkDoRob.Checked;

            if (!AppVars.Profile.Stat.Reset && checkStatReset.Checked)
            {
                AppVars.Profile.Stat.LastUpdateDay = DateTime.Now.DayOfYear;
            }

            AppVars.Profile.Stat.Reset = checkStatReset.Checked;

            AppVars.Profile.RazdChatReport = checkboxRazdChatReport.Checked;

            AppVars.Profile.CureNV[0]             = (int)numCureNV1.Value;
            AppVars.Profile.CureNV[1]             = (int)numCureNV2.Value;
            AppVars.Profile.CureNV[2]             = (int)numCureNV3.Value;
            AppVars.Profile.CureNV[3]             = (int)numCureNV4.Value;
            AppVars.Profile.CureAsk[0]            = textCureAsk1.Text;
            AppVars.Profile.CureAsk[1]            = textCureAsk2.Text;
            AppVars.Profile.CureAsk[2]            = textCureAsk3.Text;
            AppVars.Profile.CureAsk[3]            = textCureAsk4.Text;
            AppVars.Profile.CureAdv               = textCureAdv.Text;
            AppVars.Profile.CureAfter             = textCureAfter.Text;
            AppVars.Profile.CureBoi               = textCureBoi.Text;
            AppVars.Profile.CureEnabled[0]        = checkE1.Checked;
            AppVars.Profile.CureEnabled[1]        = checkE2.Checked;
            AppVars.Profile.CureEnabled[2]        = checkE3.Checked;
            AppVars.Profile.CureEnabled[3]        = checkE4.Checked;
            AppVars.Profile.CureDisabledLowLevels = checkD04.Checked;

            AppVars.Profile.MapShowExtend         = checkBoxDoExtendMap.Checked;
            AppVars.Profile.MapBigWidth           = (int)numBigMapWidth.Value;
            AppVars.Profile.MapBigHeight          = (int)numBigMapHeight.Value;
            AppVars.Profile.MapBigScale           = (int)numBigMapScale.Value;
            AppVars.Profile.MapBigTransparency    = (int)numBigMapTransparency.Value;
            AppVars.Profile.MapShowBackColorWhite = checkBoxBigMapBackColorWhite.Checked;
            AppVars.Profile.MapDrawRegion         = checkBoxMapDrawRegion.Checked;

            AppVars.Profile.MapMiniWidth   = (int)numMiniMapWidth.Value;
            AppVars.Profile.MapMiniHeight  = (int)numMiniMapHeight.Value;
            AppVars.Profile.MapMiniScale   = (int)numMiniMapScale.Value;
            AppVars.Profile.MapShowMiniMap = checkShowMiniMap.Checked;

            AppVars.Profile.FishStopOverWeight = checkboxStopOverW.Checked;

            AppVars.Profile.Sound.Enabled       = checkUseSounds.Checked;
            AppVars.Profile.Sound.DoPlayDigits  = checkDoPlayDigits.Checked;
            AppVars.Profile.Sound.DoPlayAttack  = checkDoPlayAttack.Checked;
            AppVars.Profile.Sound.DoPlaySndMsg  = checkDoPlaySndMsg.Checked;
            AppVars.Profile.Sound.DoPlayRefresh = checkDoPlayRefresh.Checked;
            AppVars.Profile.Sound.DoPlayAlarm   = checkDoPlayAlarm.Checked;
            AppVars.Profile.Sound.DoPlayTimer   = checkDoPlayTimer.Checked;

            AppVars.Profile.AutoAdv.Phraz = textPhraz.Text;
            AppVars.Profile.AutoAdv.Sec   = (int)((numAdvMin.Value * 60) + numAdvSec.Value);
            if (AppVars.Profile.AutoAdv.Sec < 30)
            {
                AppVars.Profile.AutoAdv.Sec = 600;
            }

            AppVars.Profile.FishAutoWear = checkFishAutoWear.Checked;
            AppVars.Profile.FishHandOne  = (string)comboFishHand1.SelectedItem;
            AppVars.Profile.FishHandTwo  = (string)comboFishHand2.SelectedItem;

            AppVars.Profile.FishTiedHigh = (int)numFishTiedHigh.Value;
            AppVars.Profile.FishTiedZero = checkFishTiedZero.Checked;

            AppVars.Profile.FishEnabledPrims = 0;
            if (checkPrimBread.Checked)
            {
                AppVars.Profile.FishEnabledPrims += (int)Prims.Bread;
            }

            if (checkPrimWorm.Checked)
            {
                AppVars.Profile.FishEnabledPrims += (int)Prims.Worm;
            }

            if (checkPrimBigWorm.Checked)
            {
                AppVars.Profile.FishEnabledPrims += (int)Prims.BigWorm;
            }

            if (checkPrimStink.Checked)
            {
                AppVars.Profile.FishEnabledPrims += (int)Prims.Stink;
            }

            if (checkPrimFly.Checked)
            {
                AppVars.Profile.FishEnabledPrims += (int)Prims.Fly;
            }

            if (checkPrimLight.Checked)
            {
                AppVars.Profile.FishEnabledPrims += (int)Prims.Light;
            }

            if (checkPrimDonka.Checked)
            {
                AppVars.Profile.FishEnabledPrims += (int)Prims.Donka;
            }

            if (checkPrimMorm.Checked)
            {
                AppVars.Profile.FishEnabledPrims += (int)Prims.Morm;
            }

            if (checkPrimHiFlight.Checked)
            {
                AppVars.Profile.FishEnabledPrims += (int)Prims.HiFlight;
            }

            AppVars.Profile.FishChatReport      = checkboxFishChatReport.Checked;
            AppVars.Profile.FishChatReportColor = checkboxFishChatReportColor.Checked;

            AppVars.Profile.DoAutoAnswer = checkAutoAnswer.Checked;
            AppVars.Profile.AutoAnswer   = textAutoAnswer.Text.Trim().Replace(Environment.NewLine, AppConsts.Br);
            AutoAnswerMachine.SetAnswers(AppVars.Profile.AutoAnswer);

            AppVars.Profile.LightForum = checkLightForum.Checked;

            AppVars.Profile.TorgTabl = textTorgTable.Text;
            TorgList.Parse(textTorgTable.Text);
            AppVars.Profile.TorgMessageAdv = textTorgMessageAdv.Text;

            int advTime;

            if (int.TryParse(textTorgAdvTime.Text, out advTime))
            {
                AppVars.Profile.TorgAdvTime = advTime;
            }

            AppVars.Profile.TorgMessageNoMoney = textTorgMessageNoMoney.Text;
            AppVars.Profile.TorgMessageTooExp  = textTorgMessageTooExp.Text;
            AppVars.Profile.TorgMessageThanks  = textTorgMessageThanks.Text;
            AppVars.Profile.TorgMessageLess90  = textTorgMessageLess90.Text;
            AppVars.Profile.TorgSliv           = checkTorgSliv.Checked;

            int minlevel;

            if (int.TryParse(textTorgMinLevel.Text, out minlevel))
            {
                AppVars.Profile.TorgMinLevel = minlevel;
            }

            AppVars.Profile.TorgEx   = textTorgEx.Text;
            AppVars.Profile.TorgDeny = textTorgDeny.Text;

            AppVars.Profile.DoInvPack     = checkDoInvPack.Checked;
            AppVars.Profile.DoInvPackDolg = checkDoInvPackDolg.Checked;
            AppVars.Profile.DoInvSort     = checkDoInvSort.Checked;

            AppVars.Profile.DoShowFastAttack               = checkDoShowFastAttack.Checked;
            AppVars.Profile.DoShowFastAttackBlood          = checkDoShowFastAttackBlood.Checked;
            AppVars.Profile.DoShowFastAttackUltimate       = checkDoShowFastAttackUltimate.Checked;
            AppVars.Profile.DoShowFastAttackClosedUltimate = checkDoShowFastAttackClosedUltimate.Checked;
            AppVars.Profile.DoShowFastAttackClosed         = checkDoShowFastAttackClosed.Checked;
            AppVars.Profile.DoShowFastAttackFist           = checkDoShowFastAttackFist.Checked;
            AppVars.Profile.DoShowFastAttackClosedFist     = checkDoShowFastAttackClosedFist.Checked;
            AppVars.Profile.DoShowFastAttackOpenNevid      = checkDoShowFastAttackOpenNevid.Checked;
            AppVars.Profile.DoShowFastAttackPoison         = checkDoShowFastAttackPoison.Checked;
            AppVars.Profile.DoShowFastAttackStrong         = checkDoShowFastAttackStrong.Checked;
            AppVars.Profile.DoShowFastAttackNevid          = checkDoShowFastAttackNevid.Checked;
            AppVars.Profile.DoShowFastAttackFog            = checkDoShowFastAttackFog.Checked;
            AppVars.Profile.DoShowFastAttackZas            = checkDoShowFastAttackZas.Checked;
            AppVars.Profile.DoShowFastAttackTotem          = checkDoShowFastAttackTotem.Checked;
            AppVars.Profile.DoShowFastAttackPortal         = checkDoShowFastAttackPortal.Checked;

            AppVars.Profile.ShowOverWarning = checkShowOverWarning.Checked;
            AppVars.Profile.DoStopOnDig     = checkDoStopOnDig.Checked;

            AppVars.Profile.DoAutoCure       = checkDoAutoCure.Checked;
            AppVars.Profile.AutoWearComplect = textAutoWearComplect.Text;

            AppVars.Profile.AutoDrinkBlazOrder = comboBoxDoAutoDrinkBlaz.SelectedIndex;

            if (radioSayNo.Checked)
            {
                AppVars.Profile.BossSay = LezSayType.No;
            }

            if (radioSayChat.Checked)
            {
                AppVars.Profile.BossSay = LezSayType.Chat;
            }

            if (radioSayClan.Checked)
            {
                AppVars.Profile.BossSay = LezSayType.Clan;
            }

            if (radioSayPair.Checked)
            {
                AppVars.Profile.BossSay = LezSayType.Pair;
            }

            AppVars.Profile.Save();
        }