private void ParseRaidTarget(int VillageID, string data, List <RaidTargetInfo> info_lst, int popu_limit, bool bInclOss, bool bInclTribe) { Match m = Regex.Match(data, "\"error\":false,\"errorMsg\":null,\"data\":{\"tiles\":" + "\\[(.*?\\])}}"); if (!m.Success) { return; } MatchCollection mc_cell; mc_cell = Regex.Matches(m.Groups[1].Value, "{(.*?)}[,\\]]"); if (mc_cell.Count != 99) { RaidTargetFoundLog("本次搜索只返回" + mc_cell.Count + "组数据。"); return; } int axis_x, axis_y, popul; string cell, resource_info; MatchCollection mc_res; Match m1, m2; foreach (Match pm_cell in mc_cell) { cell = pm_cell.Groups[1].Value; m1 = Regex.Match(cell, "\"x\":\"(\\-?\\d+)\",\"y\":\"(\\-?\\d+)\"," + "\"d\":\\-?\\d+,\"c\":\"{([^}]*?)}\",\"t\":\"[^\\)]*?\\)<\\\\/span><\\\\/span>([^\"]*?)\""); m2 = Regex.Match(cell, "\"x\":\"(\\-?\\d+)\",\"y\":\"(\\-?\\d+)\"," + ".*?\"c\":\"{([^}]*?)}.*?{k\\.einwohner}\\s(\\d+)" + ".*?{k\\.allianz}\\s([^<]*?)<br\\s\\\\/>" + "{k.volk}\\s{([^}]*?)}\"", RegexOptions.Singleline); if (bInclOss && m1.Success) { axis_x = Convert.ToInt32(m1.Groups[1].Value); axis_y = Convert.ToInt32(m1.Groups[2].Value); if (m1.Groups[3].Value != "k.fo") { continue; } resource_info = m1.Groups[4].Value; mc_res = Regex.Matches(resource_info, "<.*?>{[^}]*?}\\s{([^}]*?)}\\s(\\d+)%"); if (mc_res.Count == 2 || mc_res.Count == 1 && Convert.ToInt32(mc_res[0].Groups[2].Value) == 50) { if (!NoAnimals(VillageID, axis_x, axis_y)) { continue; } RaidTargetInfo info = new RaidTargetInfo() { loc_pt = new TPoint(axis_x, axis_y), type = 1, population = 0, race = "" }; info_lst.Add(info); } } else if (m2.Success && bInclTribe) { axis_x = Convert.ToInt32(m2.Groups[1].Value); axis_y = Convert.ToInt32(m2.Groups[2].Value); if (m2.Groups[3].Value != "k.dt") { continue; } popul = Convert.ToInt32(m2.Groups[4].Value); // 不攻击人口高于预设的 if (popul > popu_limit) { continue; } // 不攻击有联盟的 if (m2.Groups[5].Value.Length > 0) { continue; } RaidTargetInfo info = new RaidTargetInfo() { loc_pt = new TPoint(axis_x, axis_y), type = 2, population = popul }; if (m2.Groups[6].Value == "a.v1") { info.race = "罗马"; } else if (m2.Groups[6].Value == "a.v2") { info.race = "日族"; } else if (m2.Groups[6].Value == "a.v3") { info.race = "高卢"; } else { info.race = "纳塔"; } info_lst.Add(info); } } }
private void ParseRaidTarget(int VillageID, string data, List<RaidTargetInfo> info_lst, int popu_limit, bool bInclOss, bool bInclTribe) { Match m = Regex.Match(data, "\"error\":false,\"errorMsg\":null,\"data\":{\"tiles\":" + "\\[(.*?\\])}}"); if (!m.Success) return; MatchCollection mc_cell; mc_cell = Regex.Matches(m.Groups[1].Value, "{(.*?)}[,\\]]"); if(mc_cell.Count != 99) { RaidTargetFoundLog("本次搜索只返回" + mc_cell.Count + "组数据。"); return; } int axis_x, axis_y, popul; string cell, resource_info; MatchCollection mc_res; Match m1, m2; foreach (Match pm_cell in mc_cell) { cell = pm_cell.Groups[1].Value; m1 = Regex.Match(cell, "\"x\":\"(\\-?\\d+)\",\"y\":\"(\\-?\\d+)\"," + "\"d\":\\-?\\d+,\"c\":\"{([^}]*?)}\",\"t\":\"[^\\)]*?\\)<\\\\/span><\\\\/span>([^\"]*?)\""); m2 = Regex.Match(cell, "\"x\":\"(\\-?\\d+)\",\"y\":\"(\\-?\\d+)\"," + ".*?\"c\":\"{([^}]*?)}.*?{k\\.einwohner}\\s(\\d+)" + ".*?{k\\.allianz}\\s([^<]*?)<br\\s\\\\/>" + "{k.volk}\\s{([^}]*?)}\"", RegexOptions.Singleline); if(bInclOss && m1.Success) { axis_x = Convert.ToInt32(m1.Groups[1].Value); axis_y = Convert.ToInt32(m1.Groups[2].Value); if (m1.Groups[3].Value != "k.fo") continue; resource_info = m1.Groups[4].Value; mc_res = Regex.Matches(resource_info, "<.*?>{[^}]*?}\\s{([^}]*?)}\\s(\\d+)%"); if (mc_res.Count == 2 || mc_res.Count == 1 && Convert.ToInt32(mc_res[0].Groups[2].Value) == 50) { if (!NoAnimals(VillageID, axis_x, axis_y)) continue; RaidTargetInfo info = new RaidTargetInfo() { loc_pt = new TPoint(axis_x, axis_y), type = 1, population = 0, race = "" }; info_lst.Add(info); } } else if (m2.Success && bInclTribe) { axis_x = Convert.ToInt32(m2.Groups[1].Value); axis_y = Convert.ToInt32(m2.Groups[2].Value); if (m2.Groups[3].Value != "k.dt") continue; popul = Convert.ToInt32(m2.Groups[4].Value); // 不攻击人口高于预设的 if (popul > popu_limit) continue; // 不攻击有联盟的 if (m2.Groups[5].Value.Length > 0) continue; RaidTargetInfo info = new RaidTargetInfo() { loc_pt = new TPoint(axis_x, axis_y), type = 2, population = popul }; if (m2.Groups[6].Value == "a.v1") info.race = "罗马"; else if (m2.Groups[6].Value == "a.v2") info.race = "日族"; else if (m2.Groups[6].Value == "a.v3") info.race = "高卢"; else info.race = "纳塔"; info_lst.Add(info); } } }