comparison API/Objects/Requirement/UnitRequiresNoMoreThanNOfUnitTypeRequirement.cs @ 479:f48c49b53738

Re #410: "N units per M models in parent" requirement * Add a "context" object that will hold the parent unit (or possibly other stuff) * Update all method signatures and calls
author IBBoard <dev@ibboard.co.uk>
date Wed, 23 May 2012 20:56:27 +0100
parents f0594621e4a0
children e0641e0eb86c
comparison
equal deleted inserted replaced
478:e4e2a85604b6 479:f48c49b53738
15 public UnitRequiresNoMoreThanNOfUnitTypeRequirement(UnitType allowedObject, params UnitType[] unitTypes) : base(allowedObject, unitTypes) 15 public UnitRequiresNoMoreThanNOfUnitTypeRequirement(UnitType allowedObject, params UnitType[] unitTypes) : base(allowedObject, unitTypes)
16 { 16 {
17 //Do nothing special 17 //Do nothing special
18 } 18 }
19 19
20 protected override bool IsApplicable(IWarFoundryObject toObject, Army toArmy) 20 protected override bool IsApplicable(IWarFoundryObject toObject, Army toArmy, AddingContext context)
21 { 21 {
22 return base.IsApplicable(toObject, toArmy) || IsApplicableForRequiredType(toObject, toArmy); 22 return base.IsApplicable(toObject, toArmy, context) || IsApplicableForRequiredType(toObject, toArmy);
23 } 23 }
24 24
25 protected override bool IsApplicable(IWarFoundryObject toObject) 25 protected override bool IsApplicable(IWarFoundryObject toObject, AddingContext context)
26 { 26 {
27 return AllowedObject.Equals(toObject) || (toObject is Unit && AllowedObject.Equals(((Unit)toObject).UnitType)); 27 return AllowedObject.Equals(toObject) || (toObject is Unit && AllowedObject.Equals(((Unit)toObject).UnitType));
28 } 28 }
29 29
30 private bool IsApplicableForRequiredType(IWarFoundryObject toObject, Army toArmy) 30 private bool IsApplicableForRequiredType(IWarFoundryObject toObject, Army toArmy)