Mercurial > repos > IBBoard.WarFoundry.API
diff API/Objects/Requirement/UnitRequiresNoMoreThanNOfUnitTypeRequirement.cs @ 453:dace3b7779ca
Re #379: Fix validation of requirements to check for unit
* Restructure all validation messages to a common base system that will translate better
* Update "No More Than" texts to differentiate two contexts (adding and validating)
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 29 Jan 2012 20:05:25 +0000 |
parents | 71fceea2725b |
children | def5d333c5e8 |
line wrap: on
line diff
--- a/API/Objects/Requirement/UnitRequiresNoMoreThanNOfUnitTypeRequirement.cs Sun Jan 29 19:39:25 2012 +0000 +++ b/API/Objects/Requirement/UnitRequiresNoMoreThanNOfUnitTypeRequirement.cs Sun Jan 29 20:05:25 2012 +0000 @@ -17,7 +17,6 @@ public UnitRequiresNoMoreThanNOfUnitTypeRequirement(UnitType requirementOn) : base() { requirementOnType = requirementOn; - FailureStringPrefix = "Army contains " + requirementOn.Name + " and so cannot contain more than: "; } /// <summary> @@ -37,23 +36,36 @@ return IsApplicable(wfObject, toArmy) ? base.AllowsAdding(wfObject, toArmy) : Validation.NotApplicable; } - protected override bool IsApplicable(WarFoundryObject toObject, Army toArmy) { return IsApplicable(toArmy) || IsApplicable(toObject); } - protected override bool IsApplicable(Army toArmy) { return toArmy.GetUnitTypeCount(requirementOnType) > 0; } - protected override bool IsApplicable(WarFoundryObject toObject) { return requirementOnType.Equals(toObject) || (toObject is Unit && requirementOnType.Equals(((Unit)toObject).UnitType)); } + + protected override string ValidationFailedMessage + { + get + { + return "Army contains " + requirementOnType.Name + " and so cannot contain more than: {0}."; + } + } + + protected override string AllowsAddingFailedMessage + { + get + { + return "Army would contain " + requirementOnType.Name + " and so cannot contain more than: {0}."; + } + } } }