public void SendTroopsExecutorProcess()
        {
            ServerInfo serverInfo = new ServerInfo();
            serverInfo.Villages.Add(new Village(0, "01"));
            serverInfo.Villages.Add(new Village(1, "01"));
            serverInfo.Villages.Add(new Village(3, "01"));
            serverInfo.Villages.Add(new Village(83117, "01"));
            SendTroopsExecutor sendTroopsExecutor = new SendTroopsExecutor(serverInfo);

            sendTroopsExecutor.Parse();
            sendTroopsExecutor.Process();
        }
        public void SendTroopsExecutorParser()
        {
            ServerInfo serverInfo = new ServerInfo();
            SendTroopsExecutor sendTroopsExecutor = new SendTroopsExecutor(serverInfo);

            sendTroopsExecutor.Parse();
            Assert.IsNotNull(sendTroopsExecutor.ActionList);
            Assert.IsNotNull(sendTroopsExecutor.ActionContainer);
            Assert.IsNotNull(sendTroopsExecutor.ActionContainer.ActionsContainer.Count);
            Assert.AreEqual(1, sendTroopsExecutor.ActionContainer.ActionsContainer.Count);
            Assert.AreEqual(4, sendTroopsExecutor.ActionList.ActionsList.Count);
            Assert.AreEqual("asd", sendTroopsExecutor.ActionList.ActionsList["1"].GetActionParameters("1").PlayerName);
        }
示例#3
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);
            }
        }