Esempio n. 1
0
 static Core()
 {
     Configurator.Load();
     Config.PropertyChanged += Config_PropertyChanged;
     Events.Events.SyncFailedEvent.SyncFailed.OnSyncFailedEvent += SyncFailed_OnSyncFailedEvent;
     LocalizationController.SetLanguage(Config.language);
     Events.Events.LoginedEvent.Logined.OnLoginedEvent += Logined_OnLoginedEvent;
 }
        /// <summary>
        /// Sets the chosen locale
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LanguageList_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            if (!_handleListChange)
            {
                return;
            }

            LocalizationController.SetLanguage((LocalizationController.Language)LanguageList.SelectedIndex, false);
        }
Esempio n. 3
0
        /// <summary>
        /// Adds menu options under "Server" on the menu
        /// strip for each Language in LocalizationController
        /// </summary>
        private void SetupServerList()
        {
            // Get the current Language to add a check on
            // the option and loop through the Languages enum
            string currentLanguage = LocalizationController.GetLanguageFromCode(LocalizationController.GetLanguage());

            for (int i = 0; i < ((LocalizationController.Language[])Enum.GetValues(typeof(LocalizationController.Language))).Length; ++i)
            {
                // Add the menu option and the click event
                LocalizationController.Language language = (LocalizationController.Language)i;
                ToolStripItem newLanguage = ServerToolStripMenuItem.DropDownItems.Add(language.ToString());
                newLanguage.Click += (s, e) =>
                {
                    // No need to do anything if the current language
                    // is clicked on since that won't change anything
                    if (((ToolStripMenuItem)newLanguage).Checked)
                    {
                        return;
                    }

                    // Make sure the user wants to switch
                    if (MessageBox.Show(Strings.SwitchServer, Strings.Restart, MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Question) != DialogResult.Yes)
                    {
                        return;
                    }
                    LocalizationController.SetLanguage(language);

                    // Restart the program
                    ProcessStartInfo startInfo = Process.GetCurrentProcess().StartInfo;
                    startInfo.FileName  = Application.ExecutablePath;
                    startInfo.Arguments = $"{ProgramController.ParameterPrefix}restart";
                    var exit = typeof(Application).GetMethod("ExitInternal",
                                                             System.Reflection.BindingFlags.NonPublic |
                                                             System.Reflection.BindingFlags.Static);
                    exit?.Invoke(null, null);
                    Process.Start(startInfo);
                };

                // Check the current Language
                if (currentLanguage == language.ToString())
                {
                    ((ToolStripMenuItem)ServerToolStripMenuItem.DropDownItems[i]).Checked = true;
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Adds menu options under "Server" on the menu
        /// strip for each Language in LocalizationController
        /// </summary>
        private void SetupServerList()
        {
            string currentLanguage = LocalizationController.GetLanguageFromCode(LocalizationController.GetLanguage());

            for (int i = 0; i < ((LocalizationController.Language[])Enum.GetValues(typeof(LocalizationController.Language))).Length; ++i)
            {
                LocalizationController.Language language = (LocalizationController.Language)i;

                MenuItem menuItem = new MenuItem
                {
                    Header = language.ToString()
                };

                LanguageToolStripMenuItem.Items.Add(menuItem);
                menuItem.Click += (s, e) =>
                {
                    if (menuItem.IsChecked)
                    {
                        return;
                    }

                    CultureInfo cultureInfo = new CultureInfo(LocalizationController.GetCodeFromLanguage(language));
                    if (MessageBox.Show(Strings.ResourceManager.GetString("SwitchServer", cultureInfo),
                                        Strings.ResourceManager.GetString("Restart", cultureInfo), MessageBoxButton.YesNo,
                                        MessageBoxImage.Question) != MessageBoxResult.Yes)
                    {
                        return;
                    }
                    LocalizationController.SetLanguage(language);

                    isRestarting = true;

                    ProcessStartInfo startInfo = Process.GetCurrentProcess().StartInfo;
                    startInfo.FileName  = AppController.ExecutablePath;
                    startInfo.Arguments = $"{AppController.ParameterPrefix}restart";
                    Process.Start(startInfo);

                    System.Windows.Application.Current.Shutdown();
                };

                if (currentLanguage == language.ToString())
                {
                    menuItem.IsChecked = true;
                }
            }
        }
Esempio n. 5
0
        public Form1()
        {
            // bot = new WTGLib("a");
            LocalizationController.SetLanguage(Core.Config.language);
            this.InitializeComponent();
            this.BuildingGrid   = this.dataGridView1;
            this.ShipGrid       = this.dataGridView2;
            this.CoinsLabel     = this.lbl_coins;
            this.FishLabel      = this.lbl_fish;
            this.StoneLabel     = this.lbl_stone;
            this.TabControl     = this.tabControl1;
            this.GemLabel       = this.lbl_gems;
            this.IronLabel      = this.lbl_iron;
            this.WoodLabel      = this.lbl_wood;
            this.LevelLabel     = this.lbl_lvl;
            this.SailorsLabel   = this.lbl_sailors;
            this.NeededAlgoGrid = this.dataGridView3;
            this.InventoryGrid  = this.dataGridView4;
            instance            = this;
            TeleConfigSer.Load();
            this.MaximizeBox = false;
            this.CheckForUpdates();
            this.UpdateButtons(Core.Config.autoshiptype);
            this.LoadControls();
            Logger.Event.LogMessageChat.OnLogMessage += this.LogMessageChat_OnLogMessage;
            if (!Core.Config.acceptedresponsibility)
            {
                var msg = MessageBox.Show(
                    PrivateLocal.SEABOTGUI_WELCOME,
                    "Root to the SeaBot!",
                    MessageBoxButtons.OKCancel);
                if (msg == DialogResult.OK)
                {
                    Core.Config.acceptedresponsibility = true;
                }
                else
                {
                    Environment.Exit(0);
                }
            }

            // Check for cache
        }
Esempio n. 6
0
        private static void SyncVoid()
        {
            LocalizationController.SetLanguage(Core.Config.language);
            while (true)
            {
                Thread.Sleep(6 * 1000);
                if (_gametasks.Count != 0 && Core.GlobalData.Level != 0)
                {
                    Logger.Logger.Debug(Localization.NETWORKING_SYNCING);
                    Sync();
                }

                if ((DateTime.Now - _lastRaised).TotalSeconds
                    > (Core.GlobalData.HeartbeatInterval == 0 ? 300 : Core.GlobalData.HeartbeatInterval))
                {
                    Logger.Logger.Debug(Localization.NETWORKING_HEARTBEAT);
                    _gametasks.Add(new Task.HeartBeat());

                    Sync();
                }
            }
        }
Esempio n. 7
0
        public static void Login()
        {
            LocalizationController.SetLanguage(Core.Config.language);
            Logger.Logger.Info("Logining ");

            // Get big token
            var tempuid = string.Empty;

            var baseAddress     = new Uri("https://portal.pixelfederation.com/");
            var cookieContainer = new CookieContainer();
            var loc_cookies     = Cookies.ReadCookiesFromDisk();

            //var pxcookie = loc_cookies.GetCookies(new Uri("https://portal.pixelfederation.com"));
            //if (pxcookie.Count != 0)
            //{

            //        if (pxcookie["_pf_login_server_token"].Value == Core.Config.server_token)
            //        {
            //            cookieContainer = loc_cookies;
            //        }

            //}

            using (var handler = new HttpClientHandler {
                CookieContainer = cookieContainer
            })
                using (var client = new HttpClient(handler)
                {
                    BaseAddress = baseAddress
                })
                {
                    cookieContainer.Add(baseAddress, new Cookie("_pf_login_server_token", Core.Config.server_token));
                    Logger.Logger.Info(Localization.NETWORKING_LOGIN_1);
                    client.DefaultRequestHeaders.UserAgent.ParseAdd(
                        "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36");

                    try
                    {
                        var result = client.GetAsync("en/seaport/").Result;

                        result = client.GetAsync("en/seaport/").Result;
                        Logger.Logger.Info(Localization.NETWORKING_LOGIN_2);
                        var stringtext = result.Content.ReadAsStringAsync().Result;
                        var regex      = new Regex(
                            "portal.pixelfederation.com\\/(_sp\\/\\?direct_login=portal&portal_request=(.*))\" allowfullscreen>");
                        var match = regex.Match(stringtext);
                        if (match.Success)
                        {
                            var data = client.GetAsync(match.Groups[1].Value).Result.Content.ReadAsStringAsync().Result;
                            Logger.Logger.Info(Localization.NETWORKING_LOGIN_3);
                            regex = new Regex(@"session_id': '(.*)', 'test");

                            Core.Ssid = regex.Match(data).Groups[1].Value;
                            regex     = new Regex(@"pid': '(.*)', 'platform");
                            tempuid   = regex.Match(data).Groups[1].Value;
                            Logger.Logger.Info(Localization.NETWORKING_LOGIN_SUCCESS + Core.Ssid);
                            regex = new Regex(@"'definition_filelist_url1': 'https:\/\/r4a4v3g4\.ssl\.hwcdn\.net\/definitions\/filelists\/(.+)\.xml', 'definition_filelist_url2'");
                            var mtch = regex.Match(data);
                            if (mtch.Success)
                            {
                                DefenitionCache.Update(mtch.Groups[1].Value);
                            }

                            regex = new Regex(
                                @"loca_filelist_url2': 'https:\/\/static\.seaportgame\.com\/localization\/(.+?)\.xml', '");
                            mtch = regex.Match(data);
                            if (mtch.Success)
                            {
                                LocalizationCache.Update(mtch.Groups[1].Value);
                            }

                            regex = new Regex("clientPath = \"(.+)\";");
                            mtch  = regex.Match(data);
                            if (mtch.Success)
                            {
                                Client.DefaultRequestHeaders.Referrer = new Uri(mtch.Groups[1].Value);
                            }

                            Client.DefaultRequestHeaders.Host = "portal.pixelfederation.com";
                            Client.DefaultRequestHeaders.Add("Origin", "https://r4a4v3g4.ssl.hwcdn.net");
                            Client.DefaultRequestHeaders.AcceptEncoding.TryParseAdd("gzip, deflate, br");
                            Client.DefaultRequestHeaders.Accept.TryParseAdd(@"*/*");
                            Client.DefaultRequestHeaders.AcceptLanguage.TryParseAdd(
                                "en-GB,en-US;q=0.9,en;q=0.8,ru;q=0.7,uk;q=0.6");
                            Client.DefaultRequestHeaders.Add("DNT", "1");
                            Client.DefaultRequestHeaders.Add("X-Requested-With", "ShockwaveFlash/32.0.0.114");
                        }
                        else
                        {
                            Logger.Logger.Fatal(Localization.NETWORKING_LOGIN_CANT_LOGIN);
                            return;
                        }
                    }
                    catch (Exception e)
                    {
                        Logger.Logger.Fatal(Localization.NETWORKING_LOGIN_CANT_LOGIN + e);
                    }
                }

            var values = new Dictionary <string, string> {
                { "pid", tempuid }, { "session_id", Core.Ssid }
            };
            var s = SendRequest(values, "client.login");

            SendRequest(values, "client.update");
            if (s.StartsWith("<xml>"))
            {
                Core.GlobalData = Parser.ParseXmlToGlobalData(s);
                var rand = new Random();

                var loadtime = rand.Next(5000, 13000);
                if (!Core.Debug)
                {
                    Logger.Logger.Info(string.Format(Localization.NETWORKING_LOGIN_FAKE_LOAD, loadtime / 1000D));
                    Thread.Sleep(loadtime);
                    Logger.Logger.Info(
                        string.Format(Localization.NETWORKING_LOGIN_FAKE_LOAD_ELAPSED, loadtime / 1000D));
                }

                values.Add("loading_time", loadtime.ToString());
                SendRequest(values, "tracking.finishedLoading");
                Cookies.WriteCookiesToDisk(cookieContainer);
                Events.Events.LoginedEvent.Logined.Invoke();
                StatisticsWriter.Start();
            }
            else
            {
                Logger.Logger.Fatal("Server responded " + s);
                Core.StopBot();
            }
        }
Esempio n. 8
0
        private static void BotVoid()
        {
            LocalizationController.SetLanguage(Config.language);
            while (true)
            {
                Thread.Sleep(100);
                if (Config.sleepenabled)
                {
                    Sleeping.Sleep();
                }

                if ((DateTime.Now - _lastdefinv).TotalSeconds >= 10)
                {
                    if (Config.autoupgrade)
                    {
                        Buildings.AutoUpgrade(Config.upgradeonlyfactory);
                    }

                    if (Config.autoship)
                    {
                        Outposts.ConfirmOutpost();
                        Upgradable.UpgradeUpgradable();
                        Contractor.UpgradeContractor();
                        Ships.AutoShip();
                    }

                    if (Config.collectfish)
                    {
                        FishPier.CollectFish();
                    }

                    if (Config.collectmuseum)
                    {
                        Museum.CollectMuseum();
                    }

                    if (Config.collectfactory)
                    {
                        Buildings.CollectMaterials();
                    }

                    if (Config.prodfactory)
                    {
                        Factories.ProduceFactories();
                    }

                    if (Config.finishupgrade)
                    {
                        Buildings.FinishUpgrade();
                    }

                    _lastdefinv = DateTime.Now;
                }

                if (Config.barrelhack && (DateTime.Now - _lastbarrel).TotalSeconds >= Config.barrelinterval)
                {
                    Barrels.CollectBarrel();
                    _lastbarrel = DateTime.Now;
                }
            }
        }