Mercurial > repos > IBBoard.WarFoundry.API
comparison API/Objects/Requirement/UnitRequiresNUnitsForMUnitsRequirement.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 |
---|---|
19 public UnitRequiresNUnitsForMUnitsRequirement(UnitType requirementOn, params UnitType[] requiredUnitTypes) : base(requirementOn, requiredUnitTypes) | 19 public UnitRequiresNUnitsForMUnitsRequirement(UnitType requirementOn, params UnitType[] requiredUnitTypes) : base(requirementOn, requiredUnitTypes) |
20 { | 20 { |
21 //Do nothing | 21 //Do nothing |
22 } | 22 } |
23 | 23 |
24 protected override bool IsApplicable(IWarFoundryObject toObject, Army toArmy, AddingContext context) | |
25 { | |
26 return IsApplicable(toObject, context) || IsApplicableForRequiredType(toObject, toArmy); | |
27 } | |
28 | |
29 protected override bool IsApplicable(IWarFoundryObject toObject, AddingContext context) | 24 protected override bool IsApplicable(IWarFoundryObject toObject, AddingContext context) |
30 { | 25 { |
31 return AllowedObject.Equals(toObject) || (toObject is Unit && AllowedObject.Equals(((Unit)toObject).UnitType)); | 26 return AllowedObject.Equals(toObject) || (toObject is Unit && AllowedObject.Equals(((Unit)toObject).UnitType)); |
32 } | 27 } |
33 | 28 |
34 private bool IsApplicableForRequiredType(IWarFoundryObject toObject, Army toArmy) | 29 protected override bool IsApplicableToBoth(IWarFoundryObject toObject, Army toArmy, AddingContext context) |
35 { | 30 { |
36 bool isApplicable = false; | 31 bool isApplicable = false; |
37 UnitType addedType = toObject as UnitType; | 32 UnitType addedType = toObject as UnitType; |
38 | 33 |
39 if (addedType == null) | 34 if (addedType == null) |