comparison API/Objects/Requirement/UnitRequiresNoMoreThanNOfUnitTypeRequirement.cs @ 487:248df19652f9

Re #410: Create "N units per M models in parent unit" requirement * Add null adding context * Add initial skeleton of "N units per M models in parent unit" requirement * Update use of context * Standardise some of "is applicable" testing
author IBBoard <dev@ibboard.co.uk>
date Fri, 27 Jul 2012 20:31:12 +0100
parents e0641e0eb86c
children
comparison
equal deleted inserted replaced
486:6e5b39caeb4e 487:248df19652f9
16 public UnitRequiresNoMoreThanNOfUnitTypeRequirement(UnitType allowedObject, params UnitType[] unitTypes) : base(allowedObject, unitTypes) 16 public UnitRequiresNoMoreThanNOfUnitTypeRequirement(UnitType allowedObject, params UnitType[] unitTypes) : base(allowedObject, unitTypes)
17 { 17 {
18 //Do nothing special 18 //Do nothing special
19 } 19 }
20 20
21 protected override bool IsApplicable(IWarFoundryObject toObject, Army toArmy, AddingContext context)
22 {
23 return base.IsApplicable(toObject, toArmy, context) || IsApplicableForRequiredType(toObject, toArmy);
24 }
25
26 protected override bool IsApplicable(IWarFoundryObject toObject, AddingContext context) 21 protected override bool IsApplicable(IWarFoundryObject toObject, AddingContext context)
27 { 22 {
28 return AllowedObject.Equals(toObject) || (toObject is Unit && AllowedObject.Equals(((Unit)toObject).UnitType)); 23 return AllowedObject.Equals(toObject) || (toObject is Unit && AllowedObject.Equals(((Unit)toObject).UnitType));
29 } 24 }
30 25
31 private bool IsApplicableForRequiredType(IWarFoundryObject toObject, Army toArmy) 26 protected override bool IsApplicableToBoth(IWarFoundryObject toObject, Army toArmy, AddingContext context)
32 { 27 {
33 bool isApplicable = false; 28 bool isApplicable = false;
34 UnitType addedType = toObject as UnitType; 29 UnitType addedType = toObject as UnitType;
35 30
36 if (addedType == null) 31 if (addedType == null)