예제 #1
0
        public async void getWebsiteData()
        {
            PFStuff.getWebsiteData(main.KongregateId);
            main.currentBossLabel.setText(shortBossName(PFStuff.WBName) + (PFStuff.wbMode == 0 ? " NH" : " HA") + ", Attacks left: " + PFStuff.attacksLeft);
            main.auctionHouse.loadAuctions(false);
            double x = await main.auctionHouse.getAuctionInterval();

            WBTimer.Interval = Math.Min(Math.Max(PFStuff.attacksLeft * 2500, 5000), x);
            nextWBRefresh    = DateTime.Now.AddMilliseconds(WBTimer.Interval);
            main.currentDungLevelLabel.Text = PFStuff.DungLevel;
        }
예제 #2
0
        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();
            }
        }
예제 #3
0
 public void loadAuctions(bool getData)
 {
     if (getData)
     {
         PFStuff.getWebsiteData(main.appSettings.KongregateId);
         main.currentDungLevelLabel.Text = PFStuff.DungLevel;
     }
     auctionList = new List <Auction>();
     foreach (JObject jo in PFStuff.auctionData)
     {
         int      id      = Int32.Parse(jo["hero"].ToString());
         string   bidName = jo["bidname"].ToString();
         int      price   = Int32.Parse(jo["bid"].ToString());
         DateTime dt      = DateTime.Now.AddMilliseconds(double.Parse(jo["timer"].ToString()));
         auctionList.Add(new Auction(id, bidName, dt, price));
     }
 }
예제 #4
0
        private void init()
        {
            if (!File.Exists("Newtonsoft.Json.dll"))
            {
                MessageBox.Show("Newtonsoft file not found. Please download it from this project's github");
            }
            if (File.Exists(SettingsFilename))
            {
                appSettings  = AppSettings.loadSettings();
                token        = appSettings.token;
                KongregateId = appSettings.KongregateId;
            }
            else if (File.Exists("MacroSettings.txt"))
            {
                System.IO.StreamReader sr = new System.IO.StreamReader("MacroSettings.txt");
                appSettings.actionOnStart = int.Parse(getSetting(sr.ReadLine()));
                token        = appSettings.token = getSetting(sr.ReadLine());
                KongregateId = appSettings.KongregateId = getSetting(sr.ReadLine());
                appSettings.defaultLowerLimit = sr.ReadLine();
                appSettings.defaultUpperLimit = sr.ReadLine();
                sr.Close();

                if (token == "1111111111111111111111111111111111111111111111111111111111111111" || KongregateId == "000000")
                {
                    token = KongregateId = null;
                }
                appSettings.saveSettings();
            }
            else
            {
                token        = null;
                KongregateId = null;
                DialogResult dr = MessageBox.Show("Settings file not found. Do you want help with creating one?", "Settings Question",
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                if (dr == DialogResult.Yes)
                {
                    MacroSettingsHelper msh = new MacroSettingsHelper(appSettings);
                    msh.Show();
                    msh.BringToFront();
                }
            }
            if (token != null && KongregateId != null)
            {
                pf = new PFStuff(token, KongregateId);
            }
        }
예제 #5
0
 public void loadAuctions(bool getData)
 {
     if (getData)
     {
         PFStuff.getWebsiteData(main.appSettings.KongregateId);
         main.currentDungLevelLabel.Text = PFStuff.DungLevel;
     }
     auctionList = new List <Auction>();
     try
     {
         foreach (JObject jo in PFStuff.auctionData)
         {
             int      id      = Int32.Parse(jo["hero"].ToString());
             string   bidName = jo["bidname"].ToString();
             int      price   = Int32.Parse(jo["bid"].ToString());
             DateTime dt      = DateTime.Now.AddMilliseconds(double.Parse(jo["timer"].ToString()));
             auctionList.Add(new Auction(id, bidName, dt, price));
         }
     }
     catch (Exception ex)
     {
         // we're probably just missing data because the server is offline
     }
 }
예제 #6
0
        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);
            }
        }
예제 #7
0
        public Form1()
        {
            InitializeComponent();
            AppDomain currentDomain = AppDomain.CurrentDomain;

            currentDomain.UnhandledException += currentDomain_UnhandledException;

            timeLabels  = new Label[] { claimtime1, claimtime2, claimtime3, claimtime4, claimtime5, claimtime6, claimtime7, claimtime8, claimtime9 };
            enableBoxes = new List <CheckBox> {
                DQCalcBox, freeChestBox, autoPvPCheckbox, autoWBCheckbox
            };
            wbSettingsCounts = new List <NumericUpDown> {
                LOCHARequirementCount, LOCHAAttacksCount, superLOCHAReqCount, superLOCHAAtkCount,
                LOCNHRequirementCount, LOCNHAttacksCount, superLOCNHReqCount, superLOCNHAtkCount,
                MOAKHARequirementCount, MOAKHAAttacksCount, superMOAKHAReqCount, superMOAKHAAtkCount,
                MOAKNHRequirementCount, MOAKNHAttacksCount, superMOAKNHReqCount, superMOAKNHAtkCount,
                KrytonHAReqCount, KrytonHAAttacksCount, SuperKrytonHAReqCount, SuperKrytonHAAttacksCount,
                KrytonNHReqCount, KrytonNHAttacksCount, SuperKrytonNHReqCount, SuperKrytonNHAttacksCount,
                DoyHAReqCount, DoyHAAttacksCount, SuperDoyHAReqCount, SuperDoyHAAttacksCount,
                DoyNHReqCount, DoyNHAttacksCount, SuperDoyNHReqCount, SuperDoyNHAttacksCount
            };
            auctionCountdowns = new List <Label> {
                ahCountdown1, ahCountdown2, ahCountdown3
            };
            toolTip1.SetToolTip(safeModeWB, "Asks for confirmation before attacking. Won't ask again for the same boss");
            safeModeWB.Enabled = false;
            WBlineups          = new List <List <ComboBox> > {
                new List <ComboBox> {
                    LOCHA1, LOCHA2, LOCHA3, LOCHA4, LOCHA5, LOCHA6
                },
                new List <ComboBox> {
                    MOAKHA1, MOAKHA2, MOAKHA3, MOAKHA4, MOAKHA5, MOAKHA6
                },
                new List <ComboBox> {
                    DQLineup1, DQLineup2, DQLineup3, DQLineup4, DQLineup5, DQLineup6
                },
                new List <ComboBox> {
                    KrytonHA1, KrytonHA2, KrytonHA3, KrytonHA4, KrytonHA5, KrytonHA6
                },
                new List <ComboBox> {
                    DOYHA1, DOYHA2, DOYHA3, DOYHA4, DOYHA5, DOYHA6
                }
            };
            auctionComboBoxes = new List <ComboBox> {
                auctionHero1Combo, auctionHero2Combo, auctionHero3Combo,
            };
            AutoCompleteStringCollection acsc = new AutoCompleteStringCollection();

            foreach (List <ComboBox> l in WBlineups)
            {
                foreach (ComboBox c in l)
                {
                    foreach (string n in Constants.names.ToList().OrderBy(s => s))
                    {
                        c.Items.Add(n);
                    }
                }
            }

            init();

            if (pf != null)
            {
                auctionHouse = new AuctionHouse(this);
                autoLevel    = new AutoLevel(this);
                autoChests   = new AutoChests(this);
                autoDQ       = new AutoDQ(this);
                autopvp      = new AutoPvP(this);
                autoWB       = new AutoWB(this);
                PFStuff.getUsername(KongregateId);
                startTimers();
                countdownsTimer.Interval = 1000;
                countdownsTimer.Elapsed += countdownsTimer_Elapsed;
                countdownsTimer.Start();
                logoutTimer.Interval = 24 * 3600 * 1000;
                logoutTimer.Elapsed += logoutTimer_Elapsed;
                logoutTimer.Start();
            }
        }