async void DQTimer_Elapsed(object sender, ElapsedEventArgs e) { if (main.DQSoundBox.Checked) { using (var soundPlayer = new SoundPlayer(@"c:\Windows\Media\Windows Notify.wav")) { soundPlayer.Play(); } } if (main.DQCalcBox.Checked || main.DQBestBox.Checked) { fightWithPresetLineup(CalcMode.DQ); } else { await main.getData(); } }
public async Task <double> getAuctionInterval() { List <Auction> b = new List <Auction>(); List <double> times = new List <double>(); if (main.auctionHero1Combo.getText() != "") { int index = Array.IndexOf(Constants.heroNames, main.auctionHero1Combo.getText()); Auction a = auctionList.Find(x => x.heroID == index - 2); main.auctionHero1CostLabel.setText(a.currentPrice.ToString()); main.auctionHero1BidderLabel.setText(a.bidderName); auctionDates[0] = a.endTime; if (main.auctionHero1Box.getCheckState()) { a.setRequirements(main.auctionHero1PriceCount.Value, main.auctionHero1LevelCount.Value); times.Add((a.endTime - DateTime.Now).TotalMilliseconds - 15000); b.Add(a); } } if (main.auctionHero2Combo.getText() != "") { int index = Array.IndexOf(Constants.heroNames, main.auctionHero2Combo.getText()); Auction a = auctionList.Find(x => x.heroID == index - 2); main.auctionHero2CostLabel.setText(a.currentPrice.ToString()); main.auctionHero2BidderLabel.setText(a.bidderName); auctionDates[1] = a.endTime; if (main.auctionHero2Box.getCheckState()) { a.setRequirements(main.auctionHero2PriceCount.Value, main.auctionHero2LevelCount.Value); times.Add((a.endTime - DateTime.Now).TotalMilliseconds - 15000); b.Add(a); } } if (main.auctionHero3Combo.getText() != "") { int index = Array.IndexOf(Constants.heroNames, main.auctionHero3Combo.getText()); Auction a = auctionList.Find(x => x.heroID == index - 2); main.auctionHero3CostLabel.setText(a.currentPrice.ToString()); main.auctionHero3BidderLabel.setText(a.bidderName); auctionDates[2] = a.endTime; if (main.auctionHero3Box.getCheckState()) { a.setRequirements(main.auctionHero3PriceCount.Value, main.auctionHero3LevelCount.Value); times.Add((a.endTime - DateTime.Now).TotalMilliseconds - 15000); b.Add(a); } } IEnumerable <Auction> temp; if (main.instaBidCBox.Checked) { temp = from c in b where c.endTime < DateTime.Now.AddSeconds(40) || (c.currentPrice * 1.1 < c.maxPrice && c.currentPrice * 1.21 > c.maxPrice) select c; } else { temp = from c in b where c.endTime < DateTime.Now.AddSeconds(40) select c; } if (temp.ToList().Count > 0) { await main.getData(); foreach (Auction au in temp.ToList()) { if (au.bidderName != PFStuff.username && (int)Math.Ceiling(au.currentPrice * 1.1) <= au.maxPrice && (au.maxLevel - 1) >= PFStuff.heroLevels[au.heroID]) { placeBid(au.heroID, (int)Math.Ceiling(au.currentPrice * 1.1)); } } } if (times.Count > 0) { return(Math.Max(8000, Math.Min(times.Min(), 5 * 60 * 1000))); } return(5 * 60 * 1000); }
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); } }