public PowersDictionary <int> GetSupplyCenterToUnitDifferences() { PowersDictionary <int> differences = new PowersDictionary <int>(); // get empty home centers owned by the home power foreach (var kvp in OwnedSupplyCenters) { if (kvp.Key == Powers.None) { continue; } differences.Add(kvp.Key, kvp.Value.Count - UnitCount(kvp.Key)); } return(differences); }
public PowersDictionary <IEnumerable <MapNode> > GetBuildMapNodes() { PowersDictionary <IEnumerable <MapNode> > buildMapNodes = new PowersDictionary <IEnumerable <MapNode> >(); foreach (KeyValuePair <Powers, ISet <Territory> > kvp in OwnedSupplyCenters) { if (kvp.Key == Powers.None) { continue; } // get empty home centers owned by the home power IEnumerable <Territory> buildTerritories = kvp.Value.Where(sc => sc.HomeSupplyPower == kvp.Key && IsUnoccupied(sc)); IEnumerable <MapNode> mapNodes = Maps.BuildMap.Vertices.Where(mn => buildTerritories.Contains(mn.Territory)); buildMapNodes.Add(kvp.Key, mapNodes); } return(buildMapNodes); }
public PowersDictionary <int> GetBuildAndDisbandCounts() { var buildsAndDisbands = new PowersDictionary <int>(); foreach (var kvp in GetSupplyCenterToUnitDifferences()) { if (kvp.Value == 0) { continue; } else if (kvp.Value > 0) { int buildMovesForPower = kvp.Value; int territoryBuildCount = GetUnitMoves().Where(um => um.Unit.Power == kvp.Key && um.IsBuild).GroupBy(um => um.Edge.Target.Territory).Count(); buildsAndDisbands.Add(kvp.Key, Math.Min(buildMovesForPower, territoryBuildCount)); } else { buildsAndDisbands.Add(kvp.Key, kvp.Value); } } return(buildsAndDisbands); }