示例#1
0
        private void buttonGetInfoAliance_Click(object sender,
            EventArgs e)
        {
            string alianceId = textBoxAlianceId.Text.Length > 1 ? textBoxAlianceId.Text : "1";
            string[] allyIds = alianceId.IndexOf(',') > -1 ? alianceId.Split(',') : new[] {alianceId};
            ServerInfo serverInfo = new ServerInfo();
            alianceData = new AlianceData();
            LoginPageData loginPageData = new LoginPageData(serverInfo);

            bool logedIn = Misc.Login(serverInfo, loginPageData);

            if (logedIn)
            {
                textBoxStatus.Text += "Loged in...\r\n";
                foreach (string allyId in allyIds)
                {
                    string pageSource = Http.SendData(serverInfo.AlianceUrl + allyId, null, serverInfo.CookieContainer,
                                                      serverInfo.CookieCollection);
                    ParseMembersStats(serverInfo, pageSource, alianceData);
                    FillData(alianceData);
                }
            }
            else
            {
                textBoxStatus.Text += "Not loged in...\r\n";
            }
        }
示例#2
0
        private void buttonGetInfoUid_Click(object sender,
            EventArgs e)
        {
            string username = textBoxUid.Text.Length > 1 ? textBoxUid.Text : "kmet";

            ServerInfo serverInfo = new ServerInfo();
            LoginPageData loginPageData = new LoginPageData(serverInfo);

            bool logedIn = Misc.Login(serverInfo, loginPageData);

            if (logedIn)
            {
                textBoxStatus.Text += "Loged in...\r\n";
                alianceData = new AlianceData();
                GetStats(serverInfo, 1, username, alianceData);
                FillData(alianceData);
            }
            else
            {
                textBoxStatus.Text += "Not loged in...\r\n";
            }
        }
示例#3
0
 public bool ConnectToserver()
 {
     try
     {
         ShowBanner();
         LoginPageData loginPageData = new LoginPageData(serverInfo);
         bool logedIn = Misc.Login(serverInfo, loginPageData);
         if (logedIn)
         {
             logedIn = Misc.IsLogedIn(serverInfo, null);
             if (logedIn)
             {
                 Misc.UpdateVillages(serverInfo);
                 return true;
             }
         }
         Console.WriteLine("Not loged in ...");
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
     return false;
 }
示例#4
0
        public void Process()
        {
            try
            {
                ShowBanner();
                //Misc.CreateDB();

                ServerInfo serverInfo = new ServerInfo();
                LoginPageData loginPageData = new LoginPageData(serverInfo);

                bool logedIn = Misc.Login(serverInfo, loginPageData);

                if (logedIn)
                {
                    Misc.UpdateVillages(serverInfo);
                    int repeatCount = 0;
                    do
                    {
                        logedIn = Misc.IsLogedIn(serverInfo, null);

                        if (logedIn)
                        {
                            //DateTime now = new DateTime(DateTime.Now.Ticks);
                            //Console.WriteLine(now.ToLocalTime());

                            if (repeatCount % 600 == 0)
                            {
                                #region update village names and ids

                                Misc.UpdateVillages(serverInfo);

                                #endregion
                            }

                            if (repeatCount % 1 == 0)
                            {
                                #region attacks

                                SendTroopsExecutor sendTroopsExecutor = new SendTroopsExecutor(serverInfo);
                                sendTroopsExecutor.Parse();
                                sendTroopsExecutor.Process();

                                #endregion

                                #region read reports

                                ReportReader reportReader = new ReportReader(serverInfo);
                                string pageSource = Http.SendData(serverInfo.ReportsUrl, null,
                                                                  serverInfo.CookieContainer,
                                                                  serverInfo.CookieCollection);
                                reportReader.Parse(pageSource);
                                reportReader.Process();

                                #endregion
                            }

                            if (repeatCount % 15 == 0)
                            {
                                //Console.WriteLine("resources");
                                SendResourcesExecutor sendResourcesExecutor = new SendResourcesExecutor(serverInfo);
                                sendResourcesExecutor.Parse();
                                sendResourcesExecutor.Process();
                            }

                            repeatCount++;
                            if (repeatCount > 100)
                            {
                                repeatCount = 0;
                            }
                        }
                        else
                        {
                            Misc.Login(serverInfo, loginPageData);
                        }
                        Thread.Sleep(60000);
                    } while (repeatCount < 1000);
                }
                else
                {
                    Console.WriteLine("Not loged in ...");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
示例#5
0
 public static bool Login(ServerInfo serverInfo,
     LoginPageData loginPageData)
 {
     string postData = String.Format("login={0}&{1}={2}&{3}={4}&{5}={6}&{5}={6}&s1.x=83&s1.y=7&s1=login",
                                     loginPageData.HiddenLoginValue,
                                     "name",
                                     serverInfo.Username,
                                     "password",
                                     serverInfo.Password,
                                     loginPageData.HiddenName,
                                     loginPageData.HiddenValue);
     Console.WriteLine(postData);
     return IsLogedIn(serverInfo, postData);
 }
示例#6
0
        public void Process()
        {
            try
            {
                ShowBanner();

                ServerInfo serverInfo = new ServerInfo();
                LoginPageData loginPageData = new LoginPageData(serverInfo);
                Thread[] thread = new Thread[actionList.TroopSenderList.Count];

                bool logedIn = Misc.Login(serverInfo, loginPageData);

                if (logedIn)
                {
                    int actionCount = 0;
                    int executedActions = 0;
                    Misc.UpdateVillages(serverInfo);
                    foreach (Action action in actionList.TroopSenderList)
                    {
                        string id = action.Id;
                        TroopSenderParamaters parameters = action.GetTroopSenderParameters(id);
                        actionCount = actionList.TroopSenderList.Count;
                        Console.WriteLine("Action with id '{1,2}' will be executed at {0}", parameters.Time, parameters.Id);
                    }
                    int repeatCount = 0;
                    do
                    {
                        if (repeatCount % 60 == 0)
                        {
                            logedIn = Misc.IsLogedIn(serverInfo, null);
                        }

                        if (logedIn)
                        {
                            DateTime now = new DateTime(DateTime.Now.Ticks);
                            string timeNow = now.ToString("yyyy-MM-dd HH:mm:ss");

                            foreach (Action action in actionList.TroopSenderList)
                            {
                                string id = action.Id;
                                TroopSenderParamaters parameters = action.GetTroopSenderParameters(id);
                                if (parameters.Time == timeNow)
                                {
                                    //Send.SendTroops(serverInfo, parameters);
                                    Send send = new Send(serverInfo, parameters);
                                    executedActions++;
                                    Console.WriteLine("{0} Executing action with id '{1}'. {2} more action(s) pending for execution.", timeNow, parameters.Id, (actionCount - executedActions));
                                }
                            }

                            repeatCount++;
                            if (repeatCount > 100)
                            {
                                repeatCount = 0;
                            }
                            if (actionCount == executedActions)
                            {
                                repeatCount = 9999999;
                                Console.WriteLine("{0} All Actions executed...", timeNow);
                            }
                        }
                        else
                        {
                            Misc.Login(serverInfo, loginPageData);
                        }
                        Thread.Sleep(1000);
                    } while (repeatCount < 1000);
                }
                else
                {
                    Console.WriteLine("Not loged in ...");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }