# HG changeset patch # User IBBoard # Date 1301253331 0 # Node ID a5b34ca10d8004cce2deb593dfddde5b2b60cf6e # Parent f8471453c3cbd0f75cbbc5b3b2c098edd0889a22 Re #27: Define unit requirements * Update method name for a more "natural language" approach of "if (req.AllowsAdding(...))" diff -r f8471453c3cb -r a5b34ca10d80 api/Objects/UnitRequiresAtLeastNUnitsRequirement.cs --- a/api/Objects/UnitRequiresAtLeastNUnitsRequirement.cs Sun Mar 27 19:09:27 2011 +0000 +++ b/api/Objects/UnitRequiresAtLeastNUnitsRequirement.cs Sun Mar 27 19:15:31 2011 +0000 @@ -19,13 +19,25 @@ requiredTypes = new List(requiredUnitTypes); } - public bool CanAddToArmy(WarFoundryObject unit, Army army) + /// + /// Checks whether the supplied WarFoundryObject can be added to the supplied army. + /// + /// + /// true if the object can be added, else false + /// + /// + /// The object that we want to add. This may be involved in the check, or it may not affect the evaluation of the requirement + /// + /// + /// The army to add the object to. + /// + public bool AllowsAdding(WarFoundryObject wfObject, Army toArmy) { bool canAdd = true; foreach (UnitType type in requiredTypes) { - if (army.GetUnitTypeCount(type) < 1) + if (toArmy.GetUnitTypeCount(type) < 1) { canAdd = false; break;