public LocationArmyCountInfo Build() { var regiments = _mapQueryService.RegimentsAtLocation(CurrentLocation, CurrentTunnel); var strongholds = CurrentTunnel ? new List <IStronghold>().AsReadOnly() : _mapQueryService.StrongholdsAtLocation(CurrentLocation); var lords = _mapQueryService.LordsAtLocation(CurrentLocation, CurrentTunnel); var friendlyStrongholds = _armyQueryService.CountStrongholdArmies(strongholds, IsStrongholdFriendly); var foeStrongholds = strongholds.Count - friendlyStrongholds; var foeRegiments = _armyQueryService.CountRegimentsArmies(regiments, _ => false); var friendlyRegiments = regiments.Count - foeRegiments; var friendlyLords = _armyQueryService.CountLordArmies(lords, IsFriendlyTo); var foeLords = lords.Count - friendlyLords; // TODO: Check this count with Original LoM // ie: does a lord without an army count as an army? // and does a lord with warriors and riders count as 2 return(new LocationArmyCountInfo { Location = CurrentLocation, Tunnel = CurrentTunnel, Foes = (uint)(foeLords + foeRegiments + foeStrongholds), Friends = (uint)(friendlyLords + friendlyRegiments + friendlyStrongholds), Doomdark = 0 }); }
/// <summary> /// Creates a list of all armies at the current location /// </summary> /// <remarks> /// This function ideally needs to use some mechanism of friend or foe /// based on the character requesting the location info /// </remarks> public LocationArmyInfo Build() { var armies = new List <IArmy>(); var mapLoc = _map.GetAt(CurrentLocation); var regiments = _mapQueryService.RegimentsAtLocation(CurrentLocation, CurrentTunnel); var strongholds = CurrentTunnel ? new List <IStronghold>().AsReadOnly() : _mapQueryService.StrongholdsAtLocation(CurrentLocation); var lords = _mapQueryService.LordsAtLocation(CurrentLocation, CurrentTunnel); // TODO all these need to be governed by proper "friend or foe" var strongholdAdjustment = 0u; var isStrongholdFriendly = false; var strongholdArmies = _armyQueryService.GetStrongholdArmy(strongholds, IsStrongholdFriendly).ToList(); if (strongholdArmies.Any()) { strongholdAdjustment = GetTerrainInfo(mapLoc.Terrain).Success; var army = strongholdArmies.First(); isStrongholdFriendly = army.Friendly; armies.AddRange(strongholdArmies); } var foeTotals = new ArmyTotals { Adjustment = !isStrongholdFriendly ? strongholdAdjustment : 0, Lord = Doomdark, }; var doomdarkTotals = new ArmyTotals { Lord = Doomdark, }; var friendTotal = new ArmyTotals { Adjustment = isStrongholdFriendly ? strongholdAdjustment : 0, Lord = Luxor, }; var regimentArmies = _armyQueryService.GetRegimentsAsArmies(regiments, _ => false).ToList(); armies.AddRange(regimentArmies); foreach (var army in regimentArmies) { doomdarkTotals.Armies++; doomdarkTotals.Units[army.UnitType] += army.Total; } armies.AddRange(_armyQueryService.GetLordWarriorsAsArmies(lords, IsFriendlyTo)); armies.AddRange(_armyQueryService.GetLordRidersAsArmies(lords, IsFriendlyTo)); foreach (var army in armies) { UpdateFriendFoeArmy(army, friendTotal, foeTotals); } return(new LocationArmyInfo { Location = CurrentLocation, Tunnel = CurrentTunnel, Foe = foeTotals, Friends = friendTotal, Doomdark = doomdarkTotals, Armies = armies, Strongholds = strongholds, Regiments = regiments }); }