private void textTorgTable_Validating(object sender, System.ComponentModel.CancelEventArgs e) { if (TorgList.Parse(textTorgTable.Text)) { return; } e.Cancel = true; textTorgTable.Text = AppVars.Profile.TorgTabl; errorTorg.SetError(textTorgTable, "Ошибка в таблице торга"); }
private static byte[] TradePhp(byte[] array) { var html = Russian.Codepage.GetString(array); if (html.IndexOf(@"onclick=""location='../main.php'"" value=""Отказаться от покупки"">", StringComparison.OrdinalIgnoreCase) == -1) { return(array); } var salesNick = HelperStrings.SubString(html, @"<font color=#cc0000>Купить вещь у ", " за "); var strSalesPrice = HelperStrings.SubString(html, @" за ", "NV?</font>"); if (strSalesPrice == null) { return(array); } int salesPrice; if (!int.TryParse(strSalesPrice, out salesPrice)) { return(array); } var nameThing = HelperStrings.SubString(html, @"NV?</font><br><br> ", "</b>"); var levelThing = HelperStrings.SubString(html, @" Уровень: <b>", "</b>"); var intLevelThing = -1; if (levelThing != null) { if (!int.TryParse(levelThing, out intLevelThing)) { intLevelThing = -1; } levelThing = '[' + levelThing + ']'; } var uidThing = HelperStrings.SubString(html, @"&tradeu=", "&"); if (uidThing == null) { return(array); } var regS = new Regex(@"Долговечность: <b>([\d]+)/([\d]+)</b>"); var matchS = regS.Match(html); if (matchS.Groups.Count != 3) { return(array); } int realDolg; if (!int.TryParse(matchS.Groups[1].Value, out realDolg)) { return(array); } int fullDolg; if (!int.TryParse(matchS.Groups[2].Value, out fullDolg)) { return(array); } if (fullDolg == 0) { return(array); } var strRealPrice = HelperStrings.SubString(html, @" Цена: <b>", " NV</b>"); if (strRealPrice == null) { return(array); } int realPrice; if (!int.TryParse(strRealPrice, out realPrice)) { return(array); } // Теперь считаем цену продажи if (realDolg < fullDolg) { realPrice = (realPrice * realDolg) / fullDolg; } var sb = new StringBuilder(); sb.Append("%<"); sb.Append(salesNick); sb.Append("> "); var sbmsg = new StringBuilder(); sbmsg.Append(" <b>"); sbmsg.Append(nameThing); sbmsg.Append(levelThing); sbmsg.Append("</b>, долговечность <b>"); sbmsg.Append(realDolg); sbmsg.Append('/'); sbmsg.Append(fullDolg); sbmsg.Append("</b>, (госцена <font color=#00cc00><b>"); sbmsg.Append(realPrice); sbmsg.Append("NV</b></font>) за <font color=#0000cc><b>"); sbmsg.Append(salesPrice); sbmsg.Append("NV</b></font> у <b>"); sbmsg.Append(salesNick); sbmsg.Append("</b>"); var price90 = (int)Math.Round(realPrice * 0.9); var calcPrice = TorgList.Calculate(realPrice); if (salesPrice > calcPrice) { // Слишком высокая цена try { if (AppVars.MainForm != null) { AppVars.MainForm.BeginInvoke( new UpdateChatDelegate(AppVars.MainForm.UpdateChat), new object[] { "<font color=#cc0000><b>Отказываемся</b></font> от покупки вещи" + sbmsg }); } } catch (InvalidOperationException) { } sb.Append(TorgList.DoFilter(AppVars.Profile.TorgMessageTooExp, nameThing, levelThing, salesPrice, calcPrice, realDolg, fullDolg, price90)); Chat.AddAnswer(sb.ToString()); AppVars.ContentMainPhp = BuildRedirect("Отказ от покупки", "../main.php"); return(Russian.Codepage.GetBytes(AppVars.ContentMainPhp)); } if (salesPrice < price90) { // Слишком низкая цена try { if (AppVars.MainForm != null) { AppVars.MainForm.BeginInvoke( new UpdateChatDelegate(AppVars.MainForm.UpdateChat), new object[] { "<font color=#cc0000><b>Отказываемся</b></font> от покупки вещи" + sbmsg }); } } catch (InvalidOperationException) { } sb.Append(TorgList.DoFilter(AppVars.Profile.TorgMessageLess90, nameThing, levelThing, salesPrice, calcPrice, realDolg, fullDolg, price90)); Chat.AddAnswer(sb.ToString()); AppVars.ContentMainPhp = BuildRedirect("Отказ от покупки", "../main.php"); return(Russian.Codepage.GetBytes(AppVars.ContentMainPhp)); } var spdeny = AppVars.Profile.TorgDeny.Trim().Split(';'); for (var i = 0; i < spdeny.Length; i++) { if (string.IsNullOrEmpty(spdeny[i])) { continue; } var keydeny = spdeny[i].Trim(); if ((keydeny.IndexOf(' ') == -1 && nameThing.IndexOf(keydeny, StringComparison.OrdinalIgnoreCase) != -1) || (keydeny.IndexOf(' ') != -1 && nameThing.Equals(keydeny, StringComparison.OrdinalIgnoreCase))) { try { if (AppVars.MainForm != null) { AppVars.MainForm.BeginInvoke( new UpdateChatDelegate(AppVars.MainForm.UpdateChat), new object[] { "В имени вещи содержится ключевое слово <b>" + keydeny + "</b>, указанное в настройках. Отказываемся от покупки." }); } } catch (InvalidOperationException) { } AppVars.ContentMainPhp = BuildRedirect("Отказ от покупки", "../main.php"); return(Russian.Codepage.GetBytes(AppVars.ContentMainPhp)); } } // Делаем попытку купить var linkPrefix = "../main.php?get_id=0"; var link = HelperStrings.SubString(html, linkPrefix, "'"); if (link == null) { return(array); } // Готовимся try { if (AppVars.MainForm != null) { AppVars.MainForm.BeginInvoke( new UpdateChatDelegate(AppVars.MainForm.UpdateChat), new object[] { "<font color=#00cc00><b>Покупаем</b></font> вещь" + sbmsg }); } } catch (InvalidOperationException) { } TorgList.TriggerBuy = false; if (AppVars.Profile.TorgSliv) { if (intLevelThing < AppVars.Profile.TorgMinLevel) { if (nameThing.IndexOf("(ап)", StringComparison.OrdinalIgnoreCase) == -1) { var isDisabled = false; var keyword = string.Empty; if (!string.IsNullOrEmpty(AppVars.Profile.TorgEx)) { var sp = AppVars.Profile.TorgEx.Trim().Split(';'); var i = 0; for (; i < sp.Length; i++) { keyword = sp[i].Trim(); if ((keyword.IndexOf(' ') == -1 && nameThing.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) == -1) || (keyword.IndexOf(' ') != -1 && !nameThing.Equals(keyword, StringComparison.OrdinalIgnoreCase))) { continue; } isDisabled = true; break; } } if (!isDisabled) { try { if (AppVars.MainForm != null) { AppVars.MainForm.BeginInvoke( new UpdateChatDelegate(AppVars.MainForm.UpdateChat), new object[] { "Делаем попытку сдать вещь в лавку..." }); } } catch (InvalidOperationException) { } TorgList.UidThing = uidThing; TorgList.TriggerBuy = true; } else { try { if (AppVars.MainForm != null) { AppVars.MainForm.BeginInvoke( new UpdateChatDelegate(AppVars.MainForm.UpdateChat), new object[] { "В имени вещи содержится ключевое слово <b>" + keyword + "</b>, указанное в настройках. Оставляем вещь себе." }); } } catch (InvalidOperationException) { } } } else { try { if (AppVars.MainForm != null) { AppVars.MainForm.BeginInvoke( new UpdateChatDelegate(AppVars.MainForm.UpdateChat), new object[] { "Вещь апнута, оставляем ее себе" }); } } catch (InvalidOperationException) { } } } else { try { if (AppVars.MainForm != null) { AppVars.MainForm.BeginInvoke( new UpdateChatDelegate(AppVars.MainForm.UpdateChat), new object[] { "Уровень вещи <b>[" + intLevelThing + "]</b> равен или превышает уровень <b>[" + AppVars.Profile.TorgMinLevel + "]</b>, указанный в настройках. Оставляем вещь себе." }); } } catch (InvalidOperationException) { } } } else { try { if (AppVars.MainForm != null) { AppVars.MainForm.BeginInvoke( new UpdateChatDelegate(AppVars.MainForm.UpdateChat), new object[] { "Перепродажа вещей в лавку отключена в настройках" }); } } catch (InvalidOperationException) { } } var sbyes = new StringBuilder(sb.ToString()); sbyes.Append(TorgList.DoFilter(AppVars.Profile.TorgMessageThanks, nameThing, levelThing, salesPrice, calcPrice, realDolg, fullDolg, price90)); TorgList.MessageThanks = sbyes.ToString(); var sbno = new StringBuilder(sb.ToString()); sbno.Append(TorgList.DoFilter(AppVars.Profile.TorgMessageNoMoney, nameThing, levelThing, salesPrice, calcPrice, realDolg, fullDolg, price90)); TorgList.MessageNoMoney = sbno.ToString(); TorgList.Trigger = true; AppVars.ContentMainPhp = BuildRedirect("Покупка", linkPrefix + link); return(Russian.Codepage.GetBytes(AppVars.ContentMainPhp)); }
private void ReadTorg(XmlReader xmlReader) { bool active; if (!bool.TryParse(xmlReader[ConstAttibuteTorgActive], out active)) { active = ConstTorgActiveDefault; } TorgActive = active; TorgTabl = xmlReader[ConstAttibuteTorgTabl] ?? ConstTorgTablDefault; if (!TorgList.Parse(TorgTabl)) { TorgTabl = ConstTorgTablDefault; TorgList.Parse(TorgTabl); } if (xmlReader[ConstAttibuteTorgMsgAdv] != null) { TorgMessageAdv = xmlReader[ConstAttibuteTorgMsgAdv]; TorgList.Parse(TorgMessageAdv); } int advTime; if (!int.TryParse(xmlReader[ConstAttibuteTorgAdvTime], out advTime)) { advTime = AppConsts.TorgAdvTimeDefault; } if (advTime < AppConsts.TorgAdvTimeMin || advTime > AppConsts.TorgAdvTimeMax) { advTime = AppConsts.TorgAdvTimeDefault; } TorgAdvTime = advTime; if (xmlReader[ConstAttibuteTorgMsgTooExp] != null) { TorgMessageTooExp = xmlReader[ConstAttibuteTorgMsgTooExp]; } if (xmlReader[ConstAttibuteTorgMsgThanks] != null) { TorgMessageThanks = xmlReader[ConstAttibuteTorgMsgThanks]; } if (xmlReader[ConstAttibuteTorgMsgNoMoney] != null) { TorgMessageNoMoney = xmlReader[ConstAttibuteTorgMsgNoMoney]; } if (xmlReader[ConstAttibuteTorgMsgLess90] != null) { TorgMessageLess90 = xmlReader[ConstAttibuteTorgMsgLess90]; } bool sliv; if (!bool.TryParse(xmlReader[ConstAttibuteTorgSliv], out sliv)) { sliv = ConstTorgSlivDefault; } TorgSliv = sliv; int minlevel; if (!int.TryParse(xmlReader[ConstAttibuteTorgMinLevel], out minlevel)) { minlevel = ConstTorgMinLevelDefault; } TorgMinLevel = minlevel; if (xmlReader[ConstAttributeTorgEx] != null) { TorgEx = xmlReader[ConstAttributeTorgEx]; } if (xmlReader[ConstAttributeTorgDeny] != null) { TorgDeny = xmlReader[ConstAttributeTorgDeny]; } }
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(); }