private void GetUnitInfo(IElementContainer table, TableInfo tableInfo, bool isAttacker) { TableBody tableBodyUnits = table.TableBody(Find.ByClass("units")); const int total = 11; int[] troops = new int[total]; int[] casualties = new int[total]; int[] prisoners = new int[total]; if (tableBodyUnits.Exists) { if (tableBodyUnits.TableRows.Count == 2) { GetTribe(true, table, tableInfo, 0); } else { GetTribe(true, table, tableInfo, 1); } foreach (TableRow tableRow in tableBodyUnits.TableRows) { string header = tableRow.Text; if (!(header.Length > 1)) { continue; } if (isAttacker) { if (header.StartsWith(gameData.Settings.Reports.RowAttackerTroops)) { troops = GetTroops(tableRow); } if (header.StartsWith(gameData.Settings.Reports.RowAttackerPrisoners)) { prisoners = GetTroops(tableRow); } if (header.StartsWith(gameData.Settings.Reports.RowAttackerCasualties)) { casualties = GetTroops(tableRow); } } else { if (header.StartsWith(gameData.Settings.Reports.RowDefenderTroops)) { troops = GetTroops(tableRow); } if (header.StartsWith(gameData.Settings.Reports.RowDefenderCasualties)) { casualties = GetTroops(tableRow); } } } tableInfo.Troops = troops; tableInfo.Casualties = casualties; tableInfo.Prisoners = prisoners; } }
private static void GetBounty(IElementContainer table, TableInfo tableInfo) { TableBody tableBodyGoods = table.TableBody(Find.ByClass("goods")); int[] goods = new int[4]; tableInfo.Carry = "0/0"; if (tableBodyGoods.Exists) { string[] resources = tableBodyGoods.TableRows[0].TableCells[0].Divs[0].Text.Split('|'); for (int i = 0; i < 4; i++) { goods[i] = Misc.String2Number(resources[i].Trim()); } Div div = tableBodyGoods.TableRows[0].TableCells[0].Divs[1]; tableInfo.Carry = div.Exists ? div.Text : "0/0"; } tableInfo.Goods = goods; }