Mercurial > repos > IBBoard.WarFoundry.API
changeset 446:ca1e8f7c8b73
Re: #350: Add requirement to allow N of unit for specific other units
* Update army validation to support required amounts other than 1
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 20 Dec 2011 20:26:54 +0000 |
parents | 2d1bdd679f82 |
children | 4fbb7f205f7e |
files | API/Objects/Requirement/RequiresNUnitsForMUnitsRequirement.cs |
diffstat | 1 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/API/Objects/Requirement/RequiresNUnitsForMUnitsRequirement.cs Thu Dec 15 20:59:21 2011 +0000 +++ b/API/Objects/Requirement/RequiresNUnitsForMUnitsRequirement.cs Tue Dec 20 20:26:54 2011 +0000 @@ -162,7 +162,7 @@ foreach (UnitCountRequirementData limit in requiredTypes) { - int limitedTypeCount = army.GetUnitTypeCount(limit.UnitType); + int limitedTypeCount = GetUnitTypesCount(army, limit.UnitTypes); typeFound |= (limitedTypeCount > 0); if (!IsValidByRequirement(limit, allowedTypeCount, limitedTypeCount)) @@ -196,17 +196,23 @@ foreach (UnitCountRequirementData limit in requiredTypes) { - int limitedTypeCount = army.GetUnitTypeCount(limit.UnitType); + int limitedTypeCount = GetUnitTypesCount(army, limit.UnitTypes); if (!IsValidByRequirement(limit, allowedTypeCount, limitedTypeCount)) { - failures.Add(String.Format("{0} {1} for every {2} {3} (have {4} for {5})", limit.Count, limit.UnitType.Name, limit.AllowsCount, allowedType.Name, limitedTypeCount, allowedTypeCount)); + string unitTypeList = GetUnitTypeList(limit); + failures.Add(String.Format("{0} {1} for every {2} {3} (have {4} for {5})", limit.Count, unitTypeList, limit.AllowsCount, allowedType.Name, limitedTypeCount, allowedTypeCount)); } } return failures; } + private int GetUnitTypesCount(Army army, UnitType[] unitTypes) + { + return GetUnitTypesCount(army, unitTypes, null); + } + public override string RequirementID { get