async void proc_Exited(object sender, EventArgs e) { await main.getData(); await PFStuff.getWBData(main.KongregateId); main.calcStatus.SynchronizedInvoke(() => main.calcStatus.Text = "Calc finished"); nextDQTime = Form1.getTime(PFStuff.DQTime); DQTimer.Interval = (nextDQTime < DateTime.Now && main.DQCalcBox.Checked) ? 4000 : Math.Max(4000, (nextDQTime - DateTime.Now).TotalMilliseconds); main.DQLevelLabel.SynchronizedInvoke(() => main.DQLevelLabel.Text = PFStuff.DQLevel); main.DQTimeLabel.SynchronizedInvoke(() => main.DQTimeLabel.Text = nextDQTime.ToString()); main.currentDungLevelLabel.setText(PFStuff.DungLevel); main.autoLevel.levelTimer.Interval = 1.5 * 60 * 1000; DQTimer.Start(); if (!string.IsNullOrEmpty(calcErrorOut)) { using (StreamWriter sw = new StreamWriter("CQMCErrors.txt")) { sw.WriteLine(DateTime.Now); sw.WriteLine(calcErrorOut); } } List <string> DQl = new List <string>(); string s = ""; for (int i = 0; i < main.WBlineups[2].Count; i++) { main.WBlineups[2][i].SynchronizedInvoke(() => s = main.WBlineups[2][i].Text); DQl.Add(s); } if (DQl.All(x => x == "") && calcOut != "") { JObject solution = JObject.Parse(calcOut); var mon = solution["validSolution"]["solution"]["monsters"]; List <string> DQLineup = new List <string>(); for (int i = 0; i < mon.Count(); i++) { DQLineup.Add(Constants.names[int.Parse(mon[i]["id"].ToString()) + Constants.heroesInGame]); main.WBlineups[2][5 - i].SynchronizedInvoke(() => main.WBlineups[2][5 - i].Text = Constants.names[int.Parse(mon[i]["id"].ToString()) + Constants.heroesInGame]); } main.appSettings = AppSettings.loadSettings(); main.appSettings.defaultDQLineup = DQLineup; main.appSettings.saveSettings(); } }
async void WBTimer_Elapsed(object sender, ElapsedEventArgs e) { getWebsiteData(); { if (main.autoWBCheckbox.Checked) { decimal attacksToDo = 0; decimal requirement = 99; int[] lineup = new int[2]; int r = await PFStuff.getWBData((PFStuff.WB_ID).ToString()); main.userWBInfo.setText("Your current damage: " + PFStuff.wbDamageDealt + " with " + r + " attacks"); if (r == -2) { using (StreamWriter sw = new StreamWriter("ActionLog.txt", true)) { sw.WriteLine(DateTime.Now + "\n\tError when downloading the WB data"); } } else if (r == -1) { MessageBox.Show("You haven't enabled your username on website. Auto-WB won't work without enabled username."); } else { if (PFStuff.WBName.Contains("LORD OF CHAOS") && PFStuff.wbMode == 0) //loc no heroes { if (PFStuff.WBName.Contains("SUPER")) { attacksToDo = main.superLOCNHAtkCount.Value; requirement = main.superLOCNHReqCount.Value; } else { attacksToDo = main.LOCNHAttacksCount.Value; requirement = main.LOCNHRequirementCount.Value; } lineup = main.getLineup(0, uint.Parse(PFStuff.followers)); } else if (PFStuff.WBName.Contains("LORD OF CHAOS") && PFStuff.wbMode == 1) //loc heroes allowed { if (PFStuff.WBName.Contains("SUPER")) { attacksToDo = main.superLOCHAAtkCount.Value; requirement = main.superLOCHAReqCount.Value; } else { attacksToDo = main.LOCHAAttacksCount.Value; requirement = main.LOCHARequirementCount.Value; } lineup = main.getLineup(1, uint.Parse(PFStuff.followers)); } else if (PFStuff.WBName.Contains("MOTHER OF ALL KODAMAS") && PFStuff.wbMode == 0) //moak no heroes { if (PFStuff.WBName.Contains("SUPER")) { attacksToDo = main.superMOAKNHAtkCount.Value; requirement = main.superMOAKNHReqCount.Value; } else { attacksToDo = main.MOAKNHAttacksCount.Value; requirement = main.MOAKNHRequirementCount.Value; } lineup = main.getLineup(2, uint.Parse(PFStuff.followers)); } else if (PFStuff.WBName.Contains("MOTHER OF ALL KODAMAS") && PFStuff.wbMode == 1) //moak heroes allowed { if (PFStuff.WBName.Contains("SUPER")) { attacksToDo = main.superMOAKHAAtkCount.Value; requirement = main.superMOAKHAReqCount.Value; } else { attacksToDo = main.MOAKHAAttacksCount.Value; requirement = main.MOAKHARequirementCount.Value; } lineup = main.getLineup(3, uint.Parse(PFStuff.followers)); } else if (PFStuff.WBName.Contains("KRYTON") && PFStuff.wbMode == 0) //kryton no heroes { if (PFStuff.WBName.Contains("SUPER")) { attacksToDo = main.SuperKrytonNHAttacksCount.Value; requirement = main.SuperKrytonNHReqCount.Value; } else { attacksToDo = main.KrytonNHAttacksCount.Value; requirement = main.KrytonNHReqCount.Value; } lineup = main.getLineup(5, uint.Parse(PFStuff.followers)); } else if (PFStuff.WBName.Contains("KRYTON") && PFStuff.wbMode == 1) //kryton heroes allowed { if (PFStuff.WBName.Contains("SUPER")) { attacksToDo = main.SuperKrytonHAAttacksCount.Value; requirement = main.SuperKrytonHAReqCount.Value; } else { attacksToDo = main.KrytonHAAttacksCount.Value; requirement = main.KrytonHAReqCount.Value; } lineup = main.getLineup(6, uint.Parse(PFStuff.followers)); } else if (PFStuff.WBName.Contains("DOYENNE") && PFStuff.wbMode == 0) //doyenne no heroes { if (PFStuff.WBName.Contains("SUPER")) { attacksToDo = main.SuperDoyNHAttacksCount.Value; requirement = main.SuperDoyNHReqCount.Value; } else { attacksToDo = main.DoyNHAttacksCount.Value; requirement = main.DoyNHReqCount.Value; } lineup = main.getLineup(7, uint.Parse(PFStuff.followers)); } else if (PFStuff.WBName.Contains("DOYENNE") && PFStuff.wbMode == 1) //doyenne heroes allowed { if (PFStuff.WBName.Contains("SUPER")) { attacksToDo = main.SuperDoyHAAttacksCount.Value; requirement = main.SuperDoyHAReqCount.Value; } else { attacksToDo = main.DoyHAAttacksCount.Value; requirement = main.DoyHAReqCount.Value; } lineup = main.getLineup(8, uint.Parse(PFStuff.followers)); } else { return; } if (lineup.Contains(-1)) { MessageBox.Show("You have empty slots in your lineup. You must use all 6 slots in your lineup. Auto-WB disabled."); main.autoWBCheckbox.Checked = false; return; } attacksToDo -= r; if (attacksToDo <= 0) { return; } await main.getData(); if (PFStuff.WBchanged) { notAskedYet = true; main.autoLevel.levelTimer.Interval = 4 * 60 * 1000; main.autoLevel.nextLevelCheck = DateTime.Now.AddMilliseconds(main.autoLevel.levelTimer.Interval); if (main.waitAutoLevelBox.Checked && PFStuff.wbMode == 1) { WBTimer.Interval = 5 * 60 * 1000; return; } } int attacksAvailable = PFStuff.wbAttacksAvailable + ((PFStuff.wbAttacksAvailable == 7 && PFStuff.wbAttackNext < DateTime.Now) ? 1 : 0); if ((attacksAvailable >= requirement - r && attacksToDo < (PFStuff.attacksLeft - 5)) && !(r == 0 && PFStuff.wbDamageDealt != 0) && !(r != 0 && PFStuff.wbDamageDealt == 0)) { DialogResult dr = DialogResult.No; if (main.safeModeWB.Checked) { if (notAskedYet) { string lineupNames = ""; foreach (int id in lineup) { lineupNames += " " + Constants.names[id + Constants.heroesInGame]; } dr = MessageBox.Show("Automater wants to attack " + attacksToDo + " times with: " + lineupNames + ". Continue?", "WB Attack Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); notAskedYet = false; } } else { dr = DialogResult.Yes; } if (dr == DialogResult.Yes && !main.taskQueue.Contains("WB")) //enqueue new attacks only if there are no attacks in queue already { for (int i = 0; i < Math.Min(attacksToDo, attacksAvailable); i++) { main.taskQueue.Enqueue(() => fightWB(lineup), "WB"); } } } } } } async Task <bool> fightWB(int[] lineup) { bool b = await main.pf.sendWBFight(lineup); string s = ""; if (b) { s = DateTime.Now.ToString() + "\n\t" + PFStuff.WBName + (PFStuff.wbMode == 1 ? " Heroes Allowed" : " No Heroes") + " fought with:"; foreach (int i in lineup) { s += " " + Constants.names[i + Constants.heroesInGame]; if (i < 0) { s += ":" + PFStuff.heroLevels[-i - 2]; } } WBLogString += s + "\n"; } else { s = DateTime.Now.ToString() + "\n\tFailed to attack\n"; WBLogString += s; } if (Form1.wbl != null) { Form1.wbl.richTextBox1.setText(WBLogString); } using (StreamWriter sw = new StreamWriter("ActionLog.txt", true)) { sw.WriteLine(s); } return(b); } }