Mercurial > repos > IBDev-IBBoard.WarFoundry.API
diff API/Objects/Requirement/UnitRequiresNoMoreThanNOfUnitTypeRequirement.cs @ 455:afc6410e4efc
Re #379: Fix validation of requirements to check for unit
* Move to "Unit" requirements, since we assume things depend on units
* Rename some classes to more meaningful names from unit-based change
* Rename "requires N for M" requirement as we can make it more flexible
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 22 Feb 2012 20:45:39 +0000 |
parents | def5d333c5e8 |
children | 8e01c3174cc3 |
line wrap: on
line diff
--- a/API/Objects/Requirement/UnitRequiresNoMoreThanNOfUnitTypeRequirement.cs Tue Jan 31 20:58:09 2012 +0000 +++ b/API/Objects/Requirement/UnitRequiresNoMoreThanNOfUnitTypeRequirement.cs Wed Feb 22 20:45:39 2012 +0000 @@ -10,7 +10,7 @@ /// <summary> /// A requirement where a UnitType can only be taken if there are no more than N units of one or more unit in an army. /// </summary> - public class UnitRequiresNoMoreThanNOfUnitTypeRequirement : RequiresNoMoreThanNOfUnitTypeRequirement + public class UnitRequiresNoMoreThanNOfUnitTypeRequirement : RequiresNoMoreThanNOfUnitTypeRequirement<UnitType> { private UnitType requirementOnType; @@ -31,12 +31,12 @@ /// <param name='toArmy'> /// The army to add the object to. /// </param> - public override Validation AllowsAdding(WarFoundryObject wfObject, Army toArmy) + public override Validation AllowsAdding(IWarFoundryObject wfObject, Army toArmy) { return IsApplicable(wfObject, toArmy) ? base.AllowsAdding(wfObject, toArmy) : Validation.NotApplicable; } - protected override bool IsApplicable(WarFoundryObject toObject, Army toArmy) + protected override bool IsApplicable(IWarFoundryObject toObject, Army toArmy) { return IsApplicable(toArmy) || IsApplicable(toObject); } @@ -46,7 +46,7 @@ return toArmy.GetUnitTypeCount(requirementOnType) > 0; } - protected override bool IsApplicable(WarFoundryObject toObject) + protected override bool IsApplicable(IWarFoundryObject toObject) { return requirementOnType.Equals(toObject) || (toObject is Unit && requirementOnType.Equals(((Unit)toObject).UnitType)); }