/// <summary> /// Parses the details from the village match /// </summary> private void HandleMatch(Dictionary <int, Village> ownVillages, Match match, DateTime serverTime) { int villageId; if (CommonParsers.ParseInt(match.Groups["id"].Value, out villageId)) { Village vil = null; if (ownVillages.ContainsKey(villageId)) { vil = ownVillages[villageId]; } else { // newly conquered village: change owner foreach (Village village in World.Default.Villages.Values) { if (village.Id == villageId) { vil = village; vil.Player = World.Default.You; } } } if (vil != null) { CurrentSituation situation = vil.Reports.CurrentSituation; int tempInt; if (CommonParsers.ParseInt(match.Groups["points"].Value, out tempInt)) { vil.Points = tempInt; } string pattern = string.Format(@"(\<img src="".*\.png(\?1)?"" title=""({0}|{1}|{2})"" alt="""" /\>(\<span class=""warn""\>)?(?<res>(\d*<span class=""grey""\>\.\</span\>)?\d*)(\</span\>)?\s*)", TWWords.Wood, TWWords.Clay, TWWords.Iron); var res = new Regex(pattern); MatchCollection resMatches = res.Matches(match.Groups["res"].Value); if (resMatches.Count == 3) { if (CommonParsers.ParseInt(resMatches[0].Groups["res"].Value, out tempInt)) { situation.Resources.Wood = tempInt; } if (CommonParsers.ParseInt(resMatches[1].Groups["res"].Value, out tempInt)) { situation.Resources.Clay = tempInt; } if (CommonParsers.ParseInt(resMatches[2].Groups["res"].Value, out tempInt)) { situation.Resources.Iron = tempInt; } situation.ResourcesDate = serverTime; } vil.Reports.Save(); } } }
/// <summary> /// Parses the details from the village match /// </summary> private void HandleMatch(Dictionary <int, Village> ownVillages, Match match, DateTime serverTime) { int villageId; if (CommonParsers.ParseInt(match.Groups["id"].Value, out villageId)) { Village vil = ownVillages[villageId]; CurrentSituation situation = vil.Reports.CurrentSituation; int tempInt; if (CommonParsers.ParseInt(match.Groups["points"].Value, out tempInt)) { vil.Points = tempInt; } // groups: warehouse, population / farm //System.Diagnostics.Debug.Print(vil.ToString()); string pattern = string.Format(@"\<img src="".*\.png(\?1)?"" title=""({0}|{1}|{2})"" alt="""" /\>(?<res>(\d*<span class=""grey""\>\.\</span\>)?\d*)\s*", TWWords.Wood, TWWords.Clay, TWWords.Iron); var res = new Regex(pattern); MatchCollection resMatches = res.Matches(match.Groups["res"].Value); if (resMatches.Count == 3) { if (CommonParsers.ParseInt(resMatches[0].Groups["res"].Value, out tempInt)) { situation.Resources.Wood = tempInt; } if (CommonParsers.ParseInt(resMatches[1].Groups["res"].Value, out tempInt)) { situation.Resources.Clay = tempInt; } if (CommonParsers.ParseInt(resMatches[2].Groups["res"].Value, out tempInt)) { situation.Resources.Iron = tempInt; } situation.ResourcesDate = serverTime; } vil.Reports.Save(); } }
public void DisplaySituation() { CurrentSituation.Clear(); List <int> temp = new List <int>(); if (QueryResult != null && QueryResult.Count != 0) { counterLabel.Text = DisplayIndex.ToString() + "/" + QueryResult.Count.ToString(); foreach (var list in QueryResult[DisplayIndex]) { temp.AddRange(list); } //temp.Add(); //temp.Add(temp.Min() - 2); //temp.Add(temp.Max() + 1); //temp.Add(temp.Max() + 2); ////bleh temp.Sort(); Hits = temp; CurrentSituation.Add(LuceneService.RetrieveMessageById(temp.Min() - 2)); CurrentSituation.Add(LuceneService.RetrieveMessageById(temp.Min() - 1)); for (int i = temp[0]; i <= temp[temp.Count - 1]; i++) { CurrentSituation.Add(LuceneService.RetrieveMessageById(i)); } CurrentSituation.Add(LuceneService.RetrieveMessageById(temp.Max() + 1)); CurrentSituation.Add(LuceneService.RetrieveMessageById(temp.Max() + 2)); suggesterView.SetObjects(CurrentSituation); SetUpChatView(); suggesterView.Sort(suggesterView.AllColumns.Find(x => x.Text.Equals(ProjectInfo.DateFieldKey)), SortOrder.Ascending); } if (QueryResult == null) { MessageBox.Show("Incorrect query"); } if (QueryResult != null && QueryResult.Count == 0) { MessageBox.Show("Nothing found"); } }
/// <summary> /// Parses the details from the village match /// </summary> private void HandleMatch(Dictionary <int, Village> ownVillages, Match match, DateTime serverTime) { Village vil = World.Default.GetVillage(match.Groups["village"].Value); if (vil != null) { /*if (vil.Player == World.Default.You.Player && vil.PreviousVillageDetails != null && vil.PreviousVillageDetails.Player != World.Default.You.Player) * { * vil.Nobled(World.Default.You.Player); * }*/ CurrentSituation current = vil.Reports.CurrentSituation; /*int tempInt; * if (CommonParsers.ParseInt(match.Groups["points"].Value, out tempInt)) * vil.Points = tempInt;*/ /*string pattern = string.Format(@"(\<img src=""/graphic/(holz|lehm|eisen)\.png(\?1)?"" title=""({0}|{1}|{2})"" alt="""" /\>(\<span class=""warn""\>)?(?<res>(\d*<span class=""grey""\>\.\</span\>)?\d*)(\</span\>)?\s*)", TWWords.Wood, TWWords.Clay, TWWords.Iron); * Regex res = new Regex(pattern); * MatchCollection resMatches = res.Matches(match.Groups["res"].Value); * if (resMatches.Count == 3) * { * if (CommonParsers.ParseInt(resMatches[0].Groups["res"].Value, out tempInt)) * situation.Resources.Wood = tempInt; * if (CommonParsers.ParseInt(resMatches[1].Groups["res"].Value, out tempInt)) * situation.Resources.Clay = tempInt; * if (CommonParsers.ParseInt(resMatches[2].Groups["res"].Value, out tempInt)) * situation.Resources.Iron = tempInt; * * situation._resourcesDate = serverTime; * } */ Dictionary <UnitTypes, int> ownForce = GetTroops(match.Groups["ownforce"]); Dictionary <UnitTypes, int> thereForce = GetTroops(match.Groups["thereforce"]); Dictionary <UnitTypes, int> awayForce = GetTroops(match.Groups["awayforce"]); Dictionary <UnitTypes, int> movingForce = GetTroops(match.Groups["movingforce"]); current.UpdateTroops(ownForce, thereForce, awayForce, movingForce); vil.Reports.Save(); } }
public void SetReport(CurrentSituation current) { _report = null; _currentSituation = current; ReportCanvas.Invalidate(); }
public void SetReport(Report report) { _report = report; _currentSituation = null; ReportCanvas.Invalidate(); }