Mercurial > repos > IBDev-IBBoard.WarFoundry.API
diff API/Objects/Requirement/RequiresNUnitsForMObjectsRequirement.cs @ 457:8e01c3174cc3
Re #379: Fix validation of requirements to check for unit
* Rename public accessor for unit types to ConstraintTypes so that "no more than" requirements don't work with "required types"
* Remove class level version of ConstraintTypes to fall back to abstract class version
* Make sure we cascade allowedObject up through RequiresNoMoreThanNOfUnitTypeRequirement
* Rebuild UnitRequiresNoMoreThanNOfUnitTypeRequirement "IsApplicable" so that we don't get applicable for unrelated types, even if the requirement is currently in a failure state
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 26 Feb 2012 15:14:01 +0000 |
parents | 52baffdd2ab9 |
children | 680db2462e34 |
line wrap: on
line diff
--- a/API/Objects/Requirement/RequiresNUnitsForMObjectsRequirement.cs Sat Feb 25 16:35:31 2012 +0000 +++ b/API/Objects/Requirement/RequiresNUnitsForMObjectsRequirement.cs Sun Feb 26 15:14:01 2012 +0000 @@ -18,7 +18,7 @@ { int hash = 0; - foreach (UnitCountRequirementData req in RequiredTypes) + foreach (UnitCountRequirementData req in ConstraintTypes) { hash += req.UnitType.GetHashCode(); } @@ -29,7 +29,7 @@ protected override bool TypeEquals(object obj) { RequiresNUnitsForMObjectsRequirement<OBJECT_TYPE> otherReq = (RequiresNUnitsForMObjectsRequirement<OBJECT_TYPE>)obj; - if (!Collections.Collections.AreEqual(RequiredTypes, otherReq.RequiredTypes)) + if (!Collections.Collections.AreEqual(ConstraintTypes, otherReq.ConstraintTypes)) { return false; } @@ -49,7 +49,7 @@ List<string> failures = new List<string>(); int allowedObjectCount = GetAllowedObjectCount(toArmy, AllowedObject, obj); - foreach (UnitCountRequirementData limit in RequiredTypes) + foreach (UnitCountRequirementData limit in ConstraintTypes) { int limitedTypeCount = GetUnitTypesCount(toArmy, limit.UnitTypes, obj); @@ -96,7 +96,7 @@ bool typeFound = (wfObject == (IWarFoundryObject)AllowedObject || addedUnitType == (IWarFoundryObject)AllowedObject); int allowedTypeCount = GetAllowedObjectCount(toArmy, AllowedObject, wfObject); - foreach (UnitCountRequirementData limit in RequiredTypes) + foreach (UnitCountRequirementData limit in ConstraintTypes) { typeFound |= (addedUnitType == limit.UnitType); @@ -148,7 +148,7 @@ { canAdd = Validation.Passed; - foreach (UnitCountRequirementData limit in RequiredTypes) + foreach (UnitCountRequirementData limit in ConstraintTypes) { int limitedTypeCount = GetUnitTypesCount(army, limit.UnitTypes); @@ -177,7 +177,7 @@ List<string> failures = new List<string>(); int allowedTypeCount = GetAllowedObjectCount(army); - foreach (UnitCountRequirementData limit in RequiredTypes) + foreach (UnitCountRequirementData limit in ConstraintTypes) { int limitedTypeCount = GetUnitTypesCount(army, limit.UnitTypes); @@ -212,7 +212,7 @@ /// </param> public void AddUnitTypeRequirement(UnitType unitType, int minCount, int allowedCount) { - RequiredTypes.Add(new UnitCountRequirementData(unitType, minCount, allowedCount)); + ConstraintTypes.Add(new UnitCountRequirementData(unitType, minCount, allowedCount)); } /// <summary> @@ -258,7 +258,7 @@ /// </param> public void AddUnitTypeRequirement(int allowsAmount, params UnitType[] unitTypes) { - RequiredTypes.Add(new UnitCountRequirementData(unitTypes, 1, allowsAmount)); + ConstraintTypes.Add(new UnitCountRequirementData(unitTypes, 1, allowsAmount)); } /// <summary> @@ -276,7 +276,7 @@ /// </param> public void AddUnitTypeRequirement(int minCount, int allowsAmount, params UnitType[] unitTypes) { - RequiredTypes.Add(new UnitCountRequirementData(unitTypes, minCount, allowsAmount)); + ConstraintTypes.Add(new UnitCountRequirementData(unitTypes, minCount, allowsAmount)); } } }