Пример #1
0
 public void Collect()
 {
     browser.GoTo(String.Format(CultureInfo.InvariantCulture, "{0}berichte.php?t=3", Server));
     Table tableReports = browser.Table(Find.ById("overview"));
     if (tableReports.Exists)
     {
         foreach (TableRow tableRow in tableReports.TableRows)
         {
             if (tableRow.TableCells.Count == 3)
             {
                 Link link = tableRow.TableCells[1].Link(Find.ByUrl(new Regex("berichte.php.id=*")));
                 string reportUrl = link.Url;
                 int reportId = 0;
                 Regex regReportId = new Regex(@"berichte.php.id=([0-9]{0,16})");
                 if (regReportId.IsMatch(reportUrl))
                 {
                     Match mc = regReportId.Matches(reportUrl)[0];
                     reportId = Misc.String2Number(mc.Groups[1].Value.Trim());
                 }
                 string reportText = link.Text;
                 Log.DebugFormat("reportId={0}, reportText={1}, reportUrl={2}", reportId,
                                 reportText, reportUrl);
                 Report report = new Report(reportUrl, reportText)
                     {
                         Id = reportId,
                     };
                 reports.Add(report);
             }
         }
     }
 }
Пример #2
0
 public void NoCarry()
 {
     GetBrowser("berichte.attack.no.carry.html");
     GameData gameData = new GameData();
     gameData.GameSettings("sl-SI");
     ReportAttack reportAttack = new ReportAttack(Browser, gameData);
     Report report = new Report("url", "report text") { Date = DateTime.Now, Id = 123456, };
     reportAttack.ParseAttackerInfo(report);
     Assert.AreEqual("0/0", report.Carry);
 }
Пример #3
0
 public void ParseDefenderUnknown()
 {
     GetBrowser("berichte.unknown.html");
     GameData gameData = new GameData();
     gameData.GameSettings("sl-SI");
     ReportAttack reportAttack = new ReportAttack(Browser, gameData);
     Report report = new Report("1", "asds");
     reportAttack.ParseDefenderInfo(report);
     Assert.AreEqual(9188, report.DefenderId);
     Assert.AreEqual("ROZLE", report.DefenderName);
     Assert.AreEqual(341581, report.DefenderVillageId);
     Assert.AreEqual("ηєω ωιѕ∂σм", report.DefenderVillageName);
     Assert.AreEqual(Tribes.Teutons, report.TribeDefender);
     Assert.AreEqual(0, report.TroopsDefender[1]);
     Assert.AreEqual(0, report.CasualtiesDefender[1]);
 }
Пример #4
0
 public void ParseAttacker()
 {
     GetBrowser("berichte.reinforcement.html");
     GameData gameData = new GameData();
     gameData.GameSettings("sl-SI");
     ReportAttack reportAttack = new ReportAttack(Browser, gameData);
     Report report = new Report("1", "asds");
     reportAttack.ParseAttackerInfo(report);
     Assert.AreEqual(1445, report.AttackerId);
     Assert.AreEqual("Ukrajinec", report.AttackerName);
     Assert.AreEqual(304805, report.AttackerVillageId);
     Assert.AreEqual("U.", report.AttackerVillageName);
     Assert.AreEqual(Tribes.Romans, report.TribeAttacker);
     Assert.AreEqual(4620, report.Troops[2]);
     Assert.AreEqual(4620, report.Casualties[2]);
     Assert.AreEqual(0, report.Goods[2]);
 }
Пример #5
0
 public void ParseDefender()
 {
     GetBrowser("berichte.reinforcement.html");
     GameData gameData = new GameData();
     gameData.GameSettings("sl-SI");
     ReportAttack reportAttack = new ReportAttack(Browser, gameData);
     Report report = new Report("1", "asds");
     reportAttack.ParseDefenderInfo(report);
     Assert.AreEqual(1782, report.DefenderId);
     Assert.AreEqual("Cleaner", report.DefenderName);
     Assert.AreEqual(280730, report.DefenderVillageId);
     Assert.AreEqual("WW Vasica", report.DefenderVillageName);
     Assert.AreEqual(Tribes.Teutons, report.TribeDefender);
     Assert.AreEqual(236057, report.TroopsDefender[1]);
     Assert.AreEqual(472, report.CasualtiesDefender[1]);
     Assert.AreEqual(14552, report.TroopsDefender[4]);
     Assert.AreEqual(29, report.CasualtiesDefender[4]);
     Assert.AreEqual(13, report.TroopsDefender[10]);
     Assert.AreEqual(0, report.CasualtiesDefender[10]);
 }
Пример #6
0
 public void ParseDeleted()
 {
     GetBrowser("berichte.deleted.html");
     GameData gameData = new GameData();
     gameData.GameSettings("en-EN");
     ReportAttack reportAttack = new ReportAttack(Browser, gameData);
     Report report = new Report("1", "asds");
     reportAttack.ParseAttackerInfo(report);
     Assert.AreEqual(47554, report.AttackerId);
     Assert.AreEqual("strauss", report.AttackerName);
     Assert.AreEqual(347827, report.AttackerVillageId);
     Assert.AreEqual("01", report.AttackerVillageName);
     Assert.AreEqual(Tribes.Teutons, report.TribeAttacker);
     reportAttack.ParseDefenderInfo(report);
     Assert.AreEqual(0, report.DefenderId);
     Assert.AreEqual("???", report.DefenderName);
     Assert.AreEqual(0, report.DefenderVillageId);
     Assert.AreEqual("???", report.DefenderVillageName);
     Assert.AreEqual(Tribes.Romans, report.TribeDefender);
 }
Пример #7
0
 public void SaveReportYesterday()
 {
     GetBrowser("berichte.yesterday.html");
     GameData gameData = new GameData();
     gameData.GameSettings("sl-SI");
     ReportAttack reportAttack = new ReportAttack(Browser, gameData);
     Report report = new Report("url", "report text") { Date = DateTime.Now, Id = 123456, };
     reportAttack.ParseDate(report);
     string yesterday = DateTime.Now.AddDays(-1).ToShortDateString();
     DateTime dateTime =
         DateTime.Parse(String.Format(CultureInfo.InvariantCulture, "{0} {1}", yesterday, "22:58:44"));
     Assert.AreEqual(report.Date, dateTime);
 }
Пример #8
0
 public void SaveReportPrisoners()
 {
     GetBrowser("berichte.prisoners.html");
     GameData gameData = new GameData();
     gameData.GameSettings("en-EN");
     ReportAttack reportAttack = new ReportAttack(Browser, gameData);
     Report report = new Report("url", "report text") {Date = DateTime.Now, Id = 123456, };
     reportAttack.ParseDate(report);
     reportAttack.ParseAttackerInfo(report);
     reportAttack.ParseDefenderInfo(report);
     reportAttack.AddReport(report);
     reportAttack.Save();
 }
Пример #9
0
 public void ParseReport()
 {
     GetBrowser("berichte.raid.html");
     GameData gameData = new GameData();
     gameData.GameSettings("en-EN");
     ReportAttack reportAttack = new ReportAttack(Browser, gameData);
     Report report = new Report("1", "asds");
     reportAttack.ParseAttackerInfo(report);
     Assert.AreEqual(14837, report.AttackerId);
     Assert.AreEqual("zenix", report.AttackerName);
     Assert.AreEqual(412073, report.AttackerVillageId);
     Assert.AreEqual("[S&D] Cthol mishrak", report.AttackerVillageName);
     Assert.AreEqual(Tribes.Teutons, report.TribeAttacker);
     Assert.AreEqual(3, report.Troops[4]);
     Assert.AreEqual(0, report.Casualties[0]);
     Assert.AreEqual(0, report.Goods[0]);
     Assert.AreEqual(21, report.Goods[1]);
     Assert.AreEqual(0, report.Goods[2]);
     Assert.AreEqual(0, report.Goods[3]);
     Assert.AreEqual("21/330", report.Carry);
     reportAttack.ParseDefenderInfo(report);
     Assert.AreEqual(12465, report.DefenderId);
     Assert.AreEqual("jeza", report.DefenderName);
     Assert.AreEqual(398445, report.DefenderVillageId);
     Assert.AreEqual("00", report.DefenderVillageName);
     Assert.AreEqual(Tribes.Teutons, report.TribeDefender);
     Assert.AreEqual(3, report.TroopsDefender[1]);
     Assert.AreEqual(2, report.CasualtiesDefender[1]);
 }
Пример #10
0
 public void ParsePrisoners()
 {
     GetBrowser("berichte.prisoners.html");
     GameData gameData = new GameData();
     gameData.GameSettings("en-EN");
     ReportAttack reportAttack = new ReportAttack(Browser, gameData);
     Report report = new Report("1", "asds");
     reportAttack.ParseAttackerInfo(report);
     Assert.AreEqual(12465, report.AttackerId);
     Assert.AreEqual("jeza", report.AttackerName);
     Assert.AreEqual(398445, report.AttackerVillageId);
     Assert.AreEqual("00", report.AttackerVillageName);
     Assert.AreEqual(Tribes.Teutons, report.TribeAttacker);
     Assert.AreEqual(10, report.Troops[0]);
     Assert.AreEqual(0, report.Casualties[0]);
     Assert.AreEqual(3, report.Prisoners[0]);
     Assert.AreEqual(0, report.Goods[0]);
 }
Пример #11
0
 public void AddReport(Report report)
 {
     reports.Add(report);
 }
Пример #12
0
 public void ParseDefenderInfo(Report report)
 {
     List<Table> defender = GetDefender();
     foreach (Table table in defender)
     {
         TableInfo tableInfo = GetInfo(table, false);
         if (tableInfo.Reinforcements)
         {
             Log.Debug("Reinforcement");
         }
         report.DefenderId = tableInfo.Id;
         report.DefenderName = tableInfo.Name;
         report.DefenderVillageId = tableInfo.VillageId;
         report.DefenderVillageName = tableInfo.VillageName;
         report.TribeDefender = tableInfo.OwnTribe;
         report.TribeReinforcements = tableInfo.Tribe;
         report.TroopsDefender = tableInfo.Troops;
         report.CasualtiesDefender = tableInfo.Casualties;
         report.TribeReinforcements = tableInfo.Tribe;
     }
 }
Пример #13
0
 public void ParseDate(Report report)
 {
     Table reportsurround = browser.Table(Find.ById("report_surround"));
     if (reportsurround.Exists)
     {
         //on 22.11.09 at 09:35:37
         string date = reportsurround.TableRows[1].TableCells[1].Text.Trim();
         Log.DebugFormat("date={0}", date);
         string[] reportDate = date.Split(' ');
         string currentDay = gameData.Settings.Reports.NameOfCurrentDay;
         string previousDay = gameData.Settings.Reports.NameOfPreviousDay;
         Log.DebugFormat("currentDay={0}", currentDay);
         Log.DebugFormat("previousDay={0}", previousDay);
         Log.DebugFormat("report={0}", reportDate[1]);
         string day = reportDate[1].Equals(currentDay)
                          ? DateTime.Now.ToShortDateString()
                          : reportDate[1].Equals(previousDay)
                                ? DateTime.Now.AddDays(-1).ToShortDateString()
                                : reportDate[1];
         DateTime dateTime =
             DateTime.Parse(String.Format(CultureInfo.InvariantCulture, "{0} {1}", day, reportDate[3]));
         report.Date = dateTime;
     }
     else
     {
         report.Date = DateTime.Now;
     }
 }
Пример #14
0
 public void ParseAttackerInfo(Report report)
 {
     Table attacker = browser.Table(Find.ById("attacker"));
     if (attacker.Exists)
     {
         TableInfo tableInfo = GetInfo(attacker, true);
         report.AttackerId = tableInfo.Id;
         report.AttackerName = tableInfo.Name;
         report.AttackerVillageId = tableInfo.VillageId;
         report.AttackerVillageName = tableInfo.VillageName;
         report.TribeAttacker = tableInfo.OwnTribe;
         report.TribeReinforcements = tableInfo.Tribe;
         report.Troops = tableInfo.Troops;
         report.Casualties = tableInfo.Casualties;
         report.Goods = tableInfo.Goods;
         report.Prisoners = tableInfo.Prisoners;
         report.Carry = tableInfo.Carry;
     }
 }