コード例 #1
0
        public Form1()
        {
            InitializeComponent();

            Start.ToggleActive();
            Stop.ToggleActive();

            mainThreadContext = SynchronizationContext.Current;
            accountFactory    = new AccountFactory();
            itemFactory       = new Factory <Item>();

            images.Add("bonusbox", Image.FromFile(
                           @"C:\Users\DecaPod\Documents\visual studio 2017\Projects\WindowsFormsApp1\WindowsFormsApp1\Resources\box.bmp"));

            //images.Add("jump", Image.FromFile(
            //	@"C:\Users\DecaPod\Documents\visual studio 2017\Projects\WindowsFormsApp1\WindowsFormsApp1\Resources\jump.bmp"));

            images.Add("minimap",
                       Image.FromFile(
                           @"C:\Users\DecaPod\Documents\visual studio 2017\Projects\WindowsFormsApp1\WindowsFormsApp1\Resources\minimap.bmp"));

            cs = new CaptureScreen();

            http = new Http
            {
                Factory = accountFactory
            };
            http.OnHttpResponseErrorEvent += () =>
            {
                Console.WriteLine(@"Logged Of");
            };

            io = new FileIO("Test.json");
            io.Initialize();
            var accounts = io.GetAccounts("account");

            if (accounts != null)
            {
                foreach (var account in accounts)
                {
                    accountFactory.AddData(account);
                }
            }
            io.AddDataGroup("info");
            io.AddDataGroup("account");

            SavedAccountsComboBox.SelectionChangeCommitted += (sender, args) =>
            {
                var selected = (Account)SavedAccountsComboBox.SelectedItem;
                UsernameText.Text = selected.Nick;
                PassText.Text     = selected.Password;
            };

            SavedAccountsComboBox.Items.AddRange(accountFactory.GetAllDataValuesAsArray());

            Closing += (sender, args) =>
            {
                io.WriteAsync();
            };

            itemFactory.AddData(new Ammo("lcb-10", 10, CurrencyTypes.Credits, ItemSubTypes.laser, Category.battery));
            itemFactory.AddData(new Ammo("eco-10", 1500, CurrencyTypes.Credits, ItemSubTypes.rocketlauncher, Category.rocket));

            SetupDataGridView();

            galaxyGates.Add(new GalaxyGate("Alpha", 1, 34, 0));
            galaxyGates.Add(new GalaxyGate("Beta", 2, 48, 0));
            galaxyGates.Add(new GalaxyGate("Gamma", 3, 82, 0));
            galaxyGates.Add(new GalaxyGate("Delta", 4, 128, 0));
            galaxyGates.Add(new GalaxyGate("Epsilon", 5, 99, 0));
            galaxyGates.Add(new GalaxyGate("Zeta", 6, 11, 0));
            galaxyGates.Add(new GalaxyGate("Kappa", 7, 120, 0));
            galaxyGates.Add(new GalaxyGate("Lambda", 8, 45, 0));
            galaxyGates.Add(new GalaxyGate("Hades", 13, 45, 0));
            galaxyGates.Add(new GalaxyGate("Kuiper", 19, 100, 0));

            GatesComboBox.Items.AddRange(items: galaxyGates.ToArray());
            spinAmmountCb.Items.AddRange(new object[] { 1, 5, 10, 100 });

            LabelPremium.ForeColor = Color.Red;
            LabelPremium.Text      = @"Not Logged";

            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            WebBrowserExtensions.ClearCache();
            webBrowser1.Navigate("https://www.darkorbit.bigpoint.com");
        }
コード例 #2
0
        private async void button1_Click(object sender, EventArgs e)
        {
            Logging.ToggleVisible();
            button1.ToggleVisible();
            button2.ToggleVisible();

            var server = comboBox1.SelectedItem == null ?
                         string.Empty : comboBox1?.SelectedItem.ToString();
            string responseAuth;

            if (server == string.Empty)
            {
                responseAuth = await Login("int7");
            }
            else
            {
                responseAuth = await Login(server);
            }

            if (string.IsNullOrEmpty(responseAuth))
            {
                Logging.ToggleVisible();
                button1.ToggleVisible();
                button2.ToggleVisible();
                MessageBox.Show(@"Error during LogIn");
                return;
            }
            Console.WriteLine(@"Setting Cookies");
            var authCookie      = http.GetResponseHeader("Set-Cookie");
            var authBpSecureSid = authCookie.Substring("dosid=", "; path=/");

            Console.WriteLine(@"Parsing new account to memory");
            tempAccount = new Account
            {
                Nick     = UsernameText.Text,
                Password = PassText.Text,
                DOSID    = authBpSecureSid
            };

            accountFactory.AddData(tempAccount);
            var account =
                accountFactory.GetAccountFromMD5HashName(Cryptography.GetStringMD5Hash(MD5.Create(), UsernameText.Text));

            account.Logged  = true;
            account.Premium = premium;
            account.Server  = "int7";
            accountFactory.LoggedAccount = account;
            Console.WriteLine(@"Parsing done");

            Console.WriteLine(@"Initializing data grid view");
            await UpdateDataGridView(true);

            //UpdateWorker.RunWorkerAsync();

            await SetupGates();

            var uri = new UriBuilder(
                $"https://{accountFactory.LoggedAccount.Server}.darkorbit.com/indexInternal.es?action=internalStart&acceptDailyLoginBonus=1")
                      .Uri;

            Console.WriteLine($"{uri.AbsoluteUri}\nCookie");
            foreach (Cookie cookie in http.Cookies.GetCookies(uri))
            {
                Console.WriteLine($"\t{cookie.Name} : {cookie.Value} /*{cookie.Comment}*/");
            }

            if (webBrowser1.Document != null)
            {
                var browserCookie = webBrowser1.Document?.Cookie;
                var cookies       = browserCookie?.Split(' ');
                browserCookie = string.Empty;
                for (var i = 0; i < cookies?.Length; i++)
                {
                    var temp    = cookies[i];
                    var subS    = cookies[i].Trim();
                    var replace = string.Empty;
                    if (subS.StartsWith("dosid"))
                    {
                        var hash = subS.Substring("dosid=", ";");
                        replace = subS.Replace(hash, accountFactory.LoggedAccount.DOSID);
                    }
                    if (!string.IsNullOrEmpty(replace))
                    {
                        browserCookie += $"{replace} ";
                    }
                    else
                    {
                        browserCookie += $"{temp} ";
                    }
                }
                var url = new UriBuilder($"https://{accountFactory.LoggedAccount.Server}.darkorbit.bigpoint.com/" +
                                         $"indexInternal.es?action=internalMapRevolution&dosid={accountFactory.LoggedAccount.DOSID}").Uri;
                if (url.SetCookie(accountFactory.LoggedAccount.DOSID))
                {
                    try
                    {
                        webBrowser1.Navigate(url);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex);
                    }
                }
                else
                {
                    Console.WriteLine(@"Error Setting Cookie");
                }
            }
            Logging.ToggleVisible();
            button1.ToggleVisible();
            button2.ToggleVisible();
            Start.ToggleActive();
            Stop.ToggleActive();
        }