# HG changeset patch # User IBBoard # Date 1329943539 0 # Node ID afc6410e4efc75696abcb1f4e755712443bda60b # Parent def5d333c5e82daaf27406a4ef363c9d2f59d400 Re #379: Fix validation of requirements to check for unit * Move to "Unit" requirements, since we assume things depend on units * Rename some classes to more meaningful names from unit-based change * Rename "requires N for M" requirement as we can make it more flexible diff -r def5d333c5e8 -r afc6410e4efc API/Factories/Requirement/UnitRequiresNUnitsForMUnitsRequirementFactory.cs --- a/API/Factories/Requirement/UnitRequiresNUnitsForMUnitsRequirementFactory.cs Tue Jan 31 20:58:09 2012 +0000 +++ b/API/Factories/Requirement/UnitRequiresNUnitsForMUnitsRequirementFactory.cs Wed Feb 22 20:45:39 2012 +0000 @@ -19,19 +19,19 @@ { get { - return RequiresNUnitsForMUnitsRequirement.REQUIREMENT_ID; + return UnitRequiresNUnitsForMUnitsRequirement.REQUIREMENT_ID; } } public IRequirement CreateRequirement(UnitType type, string data, IRaceFactory raceFactory) { - RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(type); + UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(type); Race race = type.Race; AddRequirements(req, race, data, raceFactory); return req; } - private void AddRequirements(RequiresNUnitsForMUnitsRequirement req, Race race, string data, IRaceFactory raceFactory) + private void AddRequirements(UnitRequiresNUnitsForMUnitsRequirement req, Race race, string data, IRaceFactory raceFactory) { foreach (string requirement in data.Split('|')) { diff -r def5d333c5e8 -r afc6410e4efc API/Objects/Requirement/AbstractRequirement.cs --- a/API/Objects/Requirement/AbstractRequirement.cs Tue Jan 31 20:58:09 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,105 +0,0 @@ -// This file (AbstractRequirement.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2011 IBBoard -// -// The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. -using System; - -namespace IBBoard.WarFoundry.API.Objects.Requirement -{ - public abstract class AbstractRequirement : IRequirement - { - public abstract string RequirementID { get; } - - public override bool Equals(object obj) - { - if (obj == null) - { - return false; - } - else if (obj.GetType().Equals(this.GetType())) - { - return TypeEquals(obj); - } - else - { - return false; - } - } - - public override abstract int GetHashCode(); - - /// - /// Type-specific equality checking - must be implemented by each class - /// - /// - /// true if this object is equal to obj, else false - /// - /// - /// The object to compare to - /// - protected abstract bool TypeEquals(object obj); - - protected virtual bool IsApplicable(WarFoundryObject toObjectAdded, Army toArmy) - { - return IsApplicable(toArmy) || IsApplicable(toObjectAdded); - } - - protected virtual bool IsApplicable(Army toArmy) - { - return true; - } - - protected virtual bool IsApplicable(WarFoundryObject toObject) - { - return true; - } - - public string GetValidationMessage(Army army) - { - string message = ""; - - Validation result = ValidatesArmy(army); - if (!Validates.AsOkay(result)) - { - message = GetValidationFailedMessage(army); - } - - return message; - } - - protected virtual string ValidationFailedMessage { get { return "Army must contain: {0}."; } } - - private string GetValidationFailedMessage(Army army) - { - return String.Format(ValidationFailedMessage, GetFailedRequirementsString(army)); - } - - protected abstract string GetFailedRequirementsString(Army army); - - public string GetAllowsAddingMessage(UnitType toAdd, Army toArmy) - { - string message = ""; - - Validation result = AllowsAdding(toAdd, toArmy); - if (!Validates.AsOkay(result)) - { - message = GetAllowsAddingFailedMessage(toAdd, toArmy); - } - - return message; - } - - protected virtual string AllowsAddingFailedMessage { get { return ValidationFailedMessage; } } - - protected string GetAllowsAddingFailedMessage(UnitType toAdd, Army toArmy) - { - return String.Format(AllowsAddingFailedMessage, GetFailedAddingRequirementsString(toAdd, toArmy)); - } - - protected abstract string GetFailedAddingRequirementsString(UnitType toAdd, Army toArmy); - - public abstract Validation AllowsAdding(WarFoundryObject wfObject, Army toArmy); - - public abstract Validation ValidatesArmy(Army army); - } -} - diff -r def5d333c5e8 -r afc6410e4efc API/Objects/Requirement/AbstractUnitRequirement.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/API/Objects/Requirement/AbstractUnitRequirement.cs Wed Feb 22 20:45:39 2012 +0000 @@ -0,0 +1,164 @@ +// This file (AbstractRequirement.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2011 IBBoard +// +// The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. +using System; +using System.Collections.Generic; + +namespace IBBoard.WarFoundry.API.Objects.Requirement +{ + public abstract class AbstractUnitRequirement : IRequirement where OBJECT_TYPE : IWarFoundryObject + { + private List requiredTypes; + private OBJECT_TYPE allowedObject; + + public AbstractUnitRequirement(OBJECT_TYPE allowedObject, params UnitType[] requiredUnitTypes) + { + this.allowedObject = allowedObject; + requiredTypes = new List(); + + foreach (UnitType unitType in requiredUnitTypes) + { + AddUnitTypeRequirement(unitType); + } + } + + public abstract string RequirementID { get; } + + protected List RequiredTypes { get { return requiredTypes; } } + + public abstract void AddUnitTypeRequirement(UnitType unitType); + + public override bool Equals(object obj) + { + if (obj == null) + { + return false; + } + else if (obj.GetType().Equals(this.GetType())) + { + return TypeEquals(obj); + } + else + { + return false; + } + } + + public override abstract int GetHashCode(); + + /// + /// Type-specific equality checking - must be implemented by each class + /// + /// + /// true if this object is equal to obj, else false + /// + /// + /// The object to compare to + /// + protected abstract bool TypeEquals(object obj); + + protected virtual bool IsApplicable(IWarFoundryObject toObjectAdded, Army toArmy) + { + return IsApplicable(toArmy) || IsApplicable(toObjectAdded); + } + + protected virtual bool IsApplicable(Army toArmy) + { + return true; + } + + protected virtual bool IsApplicable(IWarFoundryObject toObject) + { + return true; + } + + public string GetValidationMessage(Army army) + { + string message = ""; + + Validation result = ValidatesArmy(army); + if (!Validates.AsOkay(result)) + { + message = GetValidationFailedMessage(army); + } + + return message; + } + + protected virtual string ValidationFailedMessage { get { return "Army must contain: {0}."; } } + + private string GetValidationFailedMessage(Army army) + { + return String.Format(ValidationFailedMessage, GetFailedRequirementsString(army)); + } + + protected abstract string GetFailedRequirementsString(Army army); + + public string GetAllowsAddingMessage(IWarFoundryObject toAdd, Army toArmy) + { + string message = ""; + + Validation result = AllowsAdding(toAdd, toArmy); + if (!Validates.AsOkay(result)) + { + message = GetAllowsAddingFailedMessage(toAdd, toArmy); + } + + return message; + } + + protected virtual string AllowsAddingFailedMessage { get { return ValidationFailedMessage; } } + + protected string GetAllowsAddingFailedMessage(IWarFoundryObject toAdd, Army toArmy) + { + return String.Format(AllowsAddingFailedMessage, GetFailedAddingRequirementsString(toAdd, toArmy)); + } + + protected abstract string GetFailedAddingRequirementsString(IWarFoundryObject toAdd, Army toArmy); + + public abstract Validation AllowsAdding(IWarFoundryObject wfObject, Army toArmy); + + public abstract Validation ValidatesArmy(Army army); + + protected UnitType GetUnitTypeFromObject(IWarFoundryObject toObject) + { + UnitType unitType = null; + + if (toObject is UnitType) + { + unitType = (UnitType)toObject; + } + else if (toObject is Unit) + { + unitType = ((Unit)toObject).UnitType; + } + + return unitType; + } + + protected int GetUnitTypeCount(Army toArmy, UnitType unitType, IWarFoundryObject wfObject) + { + return toArmy.GetUnitTypeCount(unitType) + GetCountFromObject(wfObject, unitType); + } + + protected int GetCountFromObject(IWarFoundryObject wfObject, UnitType limitedType) + { + return (limitedType.Equals(wfObject) || (wfObject is Unit && ((Unit)wfObject).UnitType.Equals(limitedType))) ? 1 : 0; + } + + protected int GetObjectCount(Army toArmy, IWarFoundryObject wfObject) + { + return GetObjectCountFromArmy(toArmy) + GetObjectCountFromObject(wfObject); + } + + protected abstract int GetObjectCountFromArmy(Army toArmy); + + protected virtual int GetObjectCountFromObject(IWarFoundryObject wfObject) + { + return allowedObject.Equals(wfObject) ? 1 : 0; + } + + public OBJECT_TYPE AllowedObject { get { return allowedObject; } } + } +} + diff -r def5d333c5e8 -r afc6410e4efc API/Objects/Requirement/IRequirement.cs --- a/API/Objects/Requirement/IRequirement.cs Tue Jan 31 20:58:09 2012 +0000 +++ b/API/Objects/Requirement/IRequirement.cs Wed Feb 22 20:45:39 2012 +0000 @@ -6,7 +6,7 @@ namespace IBBoard.WarFoundry.API.Objects.Requirement { /// - /// Base interface for a Requirement that constrains the units/equipment that can be taken in an army + /// Base interface for a Requirement that constrains the IWarFoundryObjects that can be taken in an army /// public interface IRequirement { @@ -20,7 +20,7 @@ string RequirementID { get; } /// - /// Checks whether the supplied WarFoundryObject can be added to the supplied army. + /// Checks whether the supplied IWarFoundryObject can be added to the supplied army. /// /// /// A Validation enum to show the result of the validation @@ -31,7 +31,7 @@ /// /// The army to add the object to. /// - Validation AllowsAdding(WarFoundryObject wfObject, Army toArmy); + Validation AllowsAdding(IWarFoundryObject wfObject, Army toArmy); /// /// Checks whether the supplied army is currently valid according to this requirement. @@ -56,18 +56,18 @@ string GetValidationMessage(Army army); /// - /// Gets the validation message for adding a unit to the army + /// Gets the validation message for adding an IWarFoundryObject to the army /// /// - /// A validation message, if the type cannot be added, else an empty string. + /// A validation message, if the object cannot be added, else an empty string. /// /// - /// The unit type to try to add + /// The IWarFoundryObject to try to add /// /// - /// The army the unit will be added to + /// The army the object will be added to /// - string GetAllowsAddingMessage(UnitType toAdd, Army toArmy); + string GetAllowsAddingMessage(IWarFoundryObject toAdd, Army toArmy); } } diff -r def5d333c5e8 -r afc6410e4efc API/Objects/Requirement/RequiresAtLeastNUnitsRequirement.cs --- a/API/Objects/Requirement/RequiresAtLeastNUnitsRequirement.cs Tue Jan 31 20:58:09 2012 +0000 +++ b/API/Objects/Requirement/RequiresAtLeastNUnitsRequirement.cs Wed Feb 22 20:45:39 2012 +0000 @@ -13,19 +13,13 @@ /// /// The definition for how this requirement is built from a data file is defined in the class. /// - public class RequiresAtLeastNUnitsRequirement : AbstractRequirement + public class RequiresAtLeastNUnitsRequirement : AbstractUnitRequirement where OBJECT_TYPE : IWarFoundryObject { public static readonly string REQUIREMENT_ID = "RequiresAtLeastNUnits"; - private List requiredTypes; - public RequiresAtLeastNUnitsRequirement(params UnitType[] requiredUnitTypes) + public RequiresAtLeastNUnitsRequirement(OBJECT_TYPE requirementOn, params UnitType[] requiredUnitTypes) : base(requirementOn, requiredUnitTypes) { - requiredTypes = new List(); - - foreach (UnitType unitType in requiredUnitTypes) - { - AddUnitTypeRequirement(unitType); - } + //Do nothing } public override string RequirementID @@ -38,8 +32,8 @@ protected override bool TypeEquals(object obj) { - RequiresAtLeastNUnitsRequirement otherReq = (RequiresAtLeastNUnitsRequirement)obj; - if (!Collections.Collections.AreEqual(requiredTypes, otherReq.requiredTypes)) + RequiresAtLeastNUnitsRequirement otherReq = (RequiresAtLeastNUnitsRequirement)obj; + if (!Collections.Collections.AreEqual(RequiredTypes, otherReq.RequiredTypes)) { return false; } @@ -53,7 +47,7 @@ { int hash = 0; - foreach (UnitCountRequirementData req in requiredTypes) + foreach (UnitCountRequirementData req in RequiredTypes) { hash += req.UnitType.GetHashCode(); } @@ -73,7 +67,7 @@ /// /// The army to add the object to. /// - public override Validation AllowsAdding(WarFoundryObject wfObject, Army toArmy) + public override Validation AllowsAdding(IWarFoundryObject wfObject, Army toArmy) { return IsApplicable(wfObject, toArmy) ? CheckAllowsAdding(wfObject, toArmy) : Validation.NotApplicable; } @@ -83,7 +77,7 @@ return false; } - protected override bool IsApplicable(WarFoundryObject toObject) + protected override bool IsApplicable(IWarFoundryObject toObject) { bool isApplicable = false; UnitType unitType = GetUnitTypeFromObject(toObject); @@ -96,26 +90,10 @@ return isApplicable; } - protected UnitType GetUnitTypeFromObject(WarFoundryObject toObject) - { - UnitType unitType = null; - - if (toObject is UnitType) - { - unitType = (UnitType)toObject; - } - else if (toObject is Unit) - { - unitType = ((Unit)toObject).UnitType; - } - - return unitType; - } - private bool IsApplicable(UnitType unitType) { bool isApplicable = false; - foreach (UnitCountRequirementData requirement in requiredTypes) + foreach (UnitCountRequirementData requirement in RequiredTypes) { if (requirement.UnitType.Equals(unitType)) { @@ -126,11 +104,11 @@ return isApplicable; } - private Validation CheckAllowsAdding(WarFoundryObject wfObject, Army toArmy) + private Validation CheckAllowsAdding(IWarFoundryObject wfObject, Army toArmy) { Validation isValid = Validation.Passed; - foreach (UnitCountRequirementData requirement in requiredTypes) + foreach (UnitCountRequirementData requirement in RequiredTypes) { if (GetUnitTypeCount(toArmy, requirement.UnitType, wfObject) < requirement.Count) { @@ -142,16 +120,6 @@ return isValid; } - private int GetUnitTypeCount(Army toArmy, UnitType unitType, WarFoundryObject wfObject) - { - return toArmy.GetUnitTypeCount(unitType) + GetCountFromObject(wfObject, unitType); - } - - private int GetCountFromObject(WarFoundryObject wfObject, UnitType limitedType) - { - return (limitedType.Equals(wfObject) || (wfObject is Unit && ((Unit)wfObject).UnitType.Equals(limitedType))) ? 1 : 0; - } - /// /// Adds a requirement for there to be at least minCount of a given UnitType /// @@ -163,7 +131,7 @@ /// public void AddUnitTypeRequirement(UnitType unitType, int minCount) { - requiredTypes.Add(new UnitCountRequirementData(unitType, minCount)); + RequiredTypes.Add(new UnitCountRequirementData(unitType, minCount)); } /// @@ -172,7 +140,7 @@ /// /// The unit type to require. /// - public void AddUnitTypeRequirement(UnitType unitType) + public override void AddUnitTypeRequirement(UnitType unitType) { AddUnitTypeRequirement(unitType, 1); } @@ -190,7 +158,7 @@ { Validation isValid = Validation.Passed; - foreach (UnitCountRequirementData requirement in requiredTypes) + foreach (UnitCountRequirementData requirement in RequiredTypes) { if (toValidate.GetUnitTypeCount(requirement.UnitType) < requirement.Count) { @@ -211,7 +179,7 @@ { List failures = new List(); - foreach (UnitCountRequirementData requirement in requiredTypes) + foreach (UnitCountRequirementData requirement in RequiredTypes) { int unitCount = army.GetUnitTypeCount(requirement.UnitType); @@ -224,18 +192,18 @@ return failures; } - protected override string GetFailedAddingRequirementsString(UnitType toAdd, Army toArmy) + protected override string GetFailedAddingRequirementsString(IWarFoundryObject toAdd, Army toArmy) { return String.Join("; ", GetFailedAddingRequirements(toAdd, toArmy).ToArray()); } - private List GetFailedAddingRequirements(UnitType unitType, Army army) + private List GetFailedAddingRequirements(IWarFoundryObject toAdd, Army army) { List failures = new List(); - foreach (UnitCountRequirementData requirement in requiredTypes) + foreach (UnitCountRequirementData requirement in RequiredTypes) { - int unitCount = GetUnitTypeCount(army, requirement.UnitType, unitType); + int unitCount = GetUnitTypeCount(army, requirement.UnitType, toAdd); if (unitCount < requirement.Count) { @@ -245,6 +213,11 @@ return failures; } + + protected override int GetObjectCountFromArmy(Army toArmy) + { + return 0; + } } } diff -r def5d333c5e8 -r afc6410e4efc API/Objects/Requirement/RequiresNUnitsForMObjectsRequirement.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/API/Objects/Requirement/RequiresNUnitsForMObjectsRequirement.cs Wed Feb 22 20:45:39 2012 +0000 @@ -0,0 +1,281 @@ +// This file(RequiresNUnitsForMUnitsRequirement.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2011 IBBoard +// +// The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or(at your option) any later version. Please see COPYING for more information and the full license. +using System; +using System.Collections.Generic; +using System.Text; + +namespace IBBoard.WarFoundry.API.Objects.Requirement +{ + public abstract class RequiresNUnitsForMObjectsRequirement : AbstractUnitRequirement where OBJECT_TYPE : IWarFoundryObject + { + public RequiresNUnitsForMObjectsRequirement(OBJECT_TYPE allowedObject, params UnitType[] requiredUnitTypes) : base(allowedObject, requiredUnitTypes) + { + //Do nothing + } + + public override int GetHashCode() + { + int hash = 0; + + foreach (UnitCountRequirementData req in RequiredTypes) + { + hash += req.UnitType.GetHashCode(); + } + + return hash; + } + + protected override bool TypeEquals(object obj) + { + RequiresNUnitsForMObjectsRequirement otherReq = (RequiresNUnitsForMObjectsRequirement)obj; + if (!Collections.Collections.AreEqual(RequiredTypes, otherReq.RequiredTypes)) + { + return false; + } + else + { + return true; + } + } + + protected override string GetFailedAddingRequirementsString(IWarFoundryObject toAdd, Army toArmy) + { + return String.Join("; ", GetFailedAddingRequirements(toAdd, toArmy).ToArray()); + } + + private List GetFailedAddingRequirements(IWarFoundryObject obj, Army toArmy) + { + List failures = new List(); + int allowedObjectCount = GetAllowedObjectCount(toArmy, AllowedObject, obj); + + foreach (UnitCountRequirementData limit in RequiredTypes) + { + int limitedTypeCount = GetUnitTypesCount(toArmy, limit.UnitTypes, obj); + + if (!IsValidByRequirement(obj, toArmy, limit, allowedObjectCount)) + { + string unitTypeList = GetUnitTypeList(limit); + failures.Add(String.Format("{0} × {1} for every {2} × {3} (would have {4} for {5})", limit.Count, unitTypeList, limit.AllowsCount, AllowedObject.Name, limitedTypeCount, allowedObjectCount)); + } + } + + return failures; + } + + private string GetUnitTypeList(UnitCountRequirementData limit) + { + List namesList = new List(); + + foreach (UnitType unitType in limit.UnitTypes) + { + namesList.Add(unitType.Name); + } + + string[] names = namesList.ToArray(); + return String.Join(" or ", names); + } + + private bool IsValidByRequirement(IWarFoundryObject wfObject, Army toArmy, UnitCountRequirementData limit, int allowedTypeCount) + { + int limitedTypeCount = GetUnitTypesCount(toArmy, limit.UnitTypes, wfObject); + return IsValidByRequirement(limit, allowedTypeCount, limitedTypeCount); + } + + private bool IsValidByRequirement(UnitCountRequirementData limit, int allowedTypeCount, int limitedTypeCount) + { + int wholeNumLimited = (limitedTypeCount / limit.Count); + double allowedRatio = (limit.AllowsCount / (limit.Count * 1.0)); + return allowedRatio * wholeNumLimited >= allowedTypeCount; + } + + public override Validation AllowsAdding(IWarFoundryObject wfObject, Army toArmy) + { + Validation canAdd = Validation.NotApplicable; + UnitType addedUnitType = (wfObject is Unit) ? ((Unit)wfObject).UnitType : wfObject as UnitType; + bool typeFound = (wfObject == (IWarFoundryObject)AllowedObject); + int allowedTypeCount = GetAllowedObjectCount(toArmy, AllowedObject, wfObject); + + foreach (UnitCountRequirementData limit in RequiredTypes) + { + typeFound |= (addedUnitType == limit.UnitType); + + if (!IsValidByRequirement(wfObject, toArmy, limit, allowedTypeCount)) + { + canAdd = Validation.Failed; + break; + } + } + + if (typeFound && canAdd == Validation.NotApplicable) + { + canAdd = Validation.Passed; + } + + return canAdd; + } + + private int GetUnitTypesCount(Army toArmy, UnitType[] unitTypes, IWarFoundryObject wfObject) + { + int count = 0; + + foreach (UnitType unitType in unitTypes) + { + count += GetUnitTypeCount(toArmy, unitType, wfObject); + } + + return count; + } + + private int GetAllowedObjectCount(Army toArmy, OBJECT_TYPE obj, IWarFoundryObject wfObject) + { + return GetObjectCountFromArmy(toArmy, obj) + GetCountFromObject(wfObject, obj); + } + + protected abstract int GetObjectCountFromArmy(Army toArmy, OBJECT_TYPE obj); + + private int GetCountFromObject(IWarFoundryObject wfObject, OBJECT_TYPE limitedType) + { + return (limitedType.Equals(wfObject) || (wfObject is Unit && ((Unit)wfObject).UnitType.Equals(limitedType))) ? 1 : 0; + } + + public override Validation ValidatesArmy(Army army) + { + Validation canAdd = Validation.NotApplicable; + int allowedTypeCount = GetObjectCountFromArmy(army, AllowedObject); + bool typeFound = (allowedTypeCount > 0); + + foreach (UnitCountRequirementData limit in RequiredTypes) + { + int limitedTypeCount = GetUnitTypesCount(army, limit.UnitTypes); + typeFound |= (limitedTypeCount > 0); + + if (!IsValidByRequirement(limit, allowedTypeCount, limitedTypeCount)) + { + canAdd = Validation.Failed; + break; + } + } + + if (typeFound && canAdd == Validation.NotApplicable) + { + canAdd = Validation.Passed; + } + + return canAdd; + } + + protected override string GetFailedRequirementsString(Army army) + { + return String.Join("; ", GetFailedValidationRequirements(army).ToArray()); + } + + private List GetFailedValidationRequirements(Army army) + { + List failures = new List(); + int allowedTypeCount = GetAllowedObjectCount(army); + + foreach (UnitCountRequirementData limit in RequiredTypes) + { + int limitedTypeCount = GetUnitTypesCount(army, limit.UnitTypes); + + if (!IsValidByRequirement(limit, allowedTypeCount, limitedTypeCount)) + { + string unitTypeList = GetUnitTypeList(limit); + failures.Add(String.Format("{0} × {1} for every {2} × {3} (have {4} for {5})", limit.Count, unitTypeList, limit.AllowsCount, AllowedObject.Name, limitedTypeCount, allowedTypeCount)); + } + } + + return failures; + } + + protected abstract int GetAllowedObjectCount(Army army); + + private int GetUnitTypesCount(Army army, UnitType[] unitTypes) + { + return GetUnitTypesCount(army, unitTypes, null); + } + + /// + /// Adds a requirement for there to be at least minCount of a given UnitType, allowing allowedCount of this UnitType + /// + /// + /// The unit type to require. + /// + /// + /// The minimum number of that type that must exist. + /// + /// + /// The number of units allowed for every minCount units of the supplied unit type. + /// + public void AddUnitTypeRequirement(UnitType unitType, int minCount, int allowedCount) + { + RequiredTypes.Add(new UnitCountRequirementData(unitType, minCount, allowedCount)); + } + + /// + /// Adds a requirement for there to be at least one of a given UnitType, allowing allowedCount of this UnitType + /// + /// + /// The unit type to require. + /// + /// + /// The number of units allowed for each unit of the supplied unit type. + /// + public void AddUnitTypeRequirement(UnitType unitType, int allowedCount) + { + AddUnitTypeRequirement(allowedCount, unitType); + } + + public override void AddUnitTypeRequirement(UnitType unitType) + { + AddUnitTypeRequirement(1, unitType); + } + + /// + /// Adds a requirement for there to be one or more of the given UnitTypes, allowing one of this UnitType. If multiple unit types + /// are supplied here then the number is additive (so 1 x unitType1 and 1 x unitType2 allows two of this UnitType). + /// + /// + /// The unit type or types to require. + /// + public void AddUnitTypeRequirement(params UnitType[] unitTypes) + { + AddUnitTypeRequirement(1, unitTypes); + } + + /// + /// Adds a requirement for there to be one or more of the given UnitTypes, allowing allowsAmount of this UnitType. If multiple unit types + /// are supplied here then the number is additive (so 1 x unitType1 and 1 x unitType2 allows two of this UnitType). + /// + /// + /// The number of units to be allowed for each 1 of unitType + /// + /// + /// The unit type or types to require. + /// + public void AddUnitTypeRequirement(int allowsAmount, params UnitType[] unitTypes) + { + RequiredTypes.Add(new UnitCountRequirementData(unitTypes, 1, allowsAmount)); + } + + /// + /// Adds a requirement for there to be minCount or more of the given UnitTypes, allowing allowsAmount of this UnitType. If multiple unit types + /// are supplied here then the number is additive (so 1 x unitType1 and 1 x unitType2 allows two of this UnitType). + /// + /// + /// The minimum number of that type that must exist. + /// + /// + /// The number of units to be allowed for each 1 of unitType + /// + /// + /// The unit type or types to require. + /// + public void AddUnitTypeRequirement(int minCount, int allowsAmount, params UnitType[] unitTypes) + { + RequiredTypes.Add(new UnitCountRequirementData(unitTypes, minCount, allowsAmount)); + } + } +} + diff -r def5d333c5e8 -r afc6410e4efc API/Objects/Requirement/RequiresNUnitsForMUnitsRequirement.cs --- a/API/Objects/Requirement/RequiresNUnitsForMUnitsRequirement.cs Tue Jan 31 20:58:09 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,290 +0,0 @@ -// This file(RequiresNUnitsForMUnitsRequirement.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2011 IBBoard -// -// The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or(at your option) any later version. Please see COPYING for more information and the full license. -using System; -using System.Collections.Generic; -using System.Text; - -namespace IBBoard.WarFoundry.API.Objects.Requirement -{ - public class RequiresNUnitsForMUnitsRequirement : AbstractRequirement - { - public static readonly string REQUIREMENT_ID = "RequiresNUnitsForMUnits"; - private List requiredTypes; - private UnitType allowedType; - - public RequiresNUnitsForMUnitsRequirement(UnitType allowedType, params UnitType[] requiredUnitTypes) - { - this.allowedType = allowedType; - requiredTypes = new List(); - - foreach (UnitType unitType in requiredUnitTypes) - { - AddUnitTypeRequirement(unitType); - } - } - - public override int GetHashCode() - { - int hash = 0; - - foreach (UnitCountRequirementData req in requiredTypes) - { - hash += req.UnitType.GetHashCode(); - } - - return hash; - } - - protected override bool TypeEquals(object obj) - { - RequiresNUnitsForMUnitsRequirement otherReq = (RequiresNUnitsForMUnitsRequirement)obj; - if (!Collections.Collections.AreEqual(requiredTypes, otherReq.requiredTypes)) - { - return false; - } - else - { - return true; - } - } - - protected override string GetFailedAddingRequirementsString(UnitType toAdd, Army toArmy) - { - return String.Join("; ", GetFailedAddingRequirements(toAdd, toArmy).ToArray()); - } - - private List GetFailedAddingRequirements(UnitType unitType, Army toArmy) - { - List failures = new List(); - int allowedTypeCount = GetUnitTypeCount(toArmy, allowedType, unitType); - - foreach (UnitCountRequirementData limit in requiredTypes) - { - int limitedTypeCount = GetUnitTypesCount(toArmy, limit.UnitTypes, unitType); - - if (!IsValidByRequirement(unitType, toArmy, limit, allowedTypeCount)) - { - string unitTypeList = GetUnitTypeList(limit); - failures.Add(String.Format("{0} × {1} for every {2} × {3} (would have {4} for {5})", limit.Count, unitTypeList, limit.AllowsCount, allowedType.Name, limitedTypeCount, allowedTypeCount)); - } - } - - return failures; - } - - private string GetUnitTypeList(UnitCountRequirementData limit) - { - List namesList = new List(); - - foreach (UnitType unitType in limit.UnitTypes) - { - namesList.Add(unitType.Name); - } - - string[] names = namesList.ToArray(); - return String.Join(" or ", names); - } - - private bool IsValidByRequirement(WarFoundryObject wfObject, Army toArmy, UnitCountRequirementData limit, int allowedTypeCount) - { - int limitedTypeCount = GetUnitTypesCount(toArmy, limit.UnitTypes, wfObject); - return IsValidByRequirement(limit, allowedTypeCount, limitedTypeCount); - } - - private bool IsValidByRequirement(UnitCountRequirementData limit, int allowedTypeCount, int limitedTypeCount) - { - int wholeNumLimited = (limitedTypeCount / limit.Count); - double allowedRatio = (limit.AllowsCount / (limit.Count * 1.0)); - return allowedRatio * wholeNumLimited >= allowedTypeCount; - } - - public override Validation AllowsAdding(WarFoundryObject wfObject, Army toArmy) - { - Validation canAdd = Validation.NotApplicable; - UnitType addedUnitType = (wfObject is Unit) ? ((Unit)wfObject).UnitType : wfObject as UnitType; - bool typeFound = (addedUnitType == allowedType); - int allowedTypeCount = GetUnitTypeCount(toArmy, allowedType, wfObject); - - foreach (UnitCountRequirementData limit in requiredTypes) - { - typeFound |= (addedUnitType == limit.UnitType); - - if (!IsValidByRequirement(wfObject, toArmy, limit, allowedTypeCount)) - { - canAdd = Validation.Failed; - break; - } - } - - if (typeFound && canAdd == Validation.NotApplicable) - { - canAdd = Validation.Passed; - } - - return canAdd; - } - - private int GetUnitTypesCount(Army toArmy, UnitType[] unitTypes, WarFoundryObject wfObject) - { - int count = 0; - - foreach (UnitType unitType in unitTypes) - { - count += GetUnitTypeCount(toArmy, unitType, wfObject); - } - - return count; - } - - private int GetUnitTypeCount(Army toArmy, UnitType unitType, WarFoundryObject wfObject) - { - return toArmy.GetUnitTypeCount(unitType) + GetCountFromObject(wfObject, unitType); - } - - private int GetCountFromObject(WarFoundryObject wfObject, UnitType limitedType) - { - return (limitedType.Equals(wfObject) || (wfObject is Unit && ((Unit)wfObject).UnitType.Equals(limitedType))) ? 1 : 0; - } - - public override Validation ValidatesArmy(Army army) - { - Validation canAdd = Validation.NotApplicable; - int allowedTypeCount = army.GetUnitTypeCount(allowedType); - bool typeFound = (allowedTypeCount > 0); - - foreach (UnitCountRequirementData limit in requiredTypes) - { - int limitedTypeCount = GetUnitTypesCount(army, limit.UnitTypes); - typeFound |= (limitedTypeCount > 0); - - if (!IsValidByRequirement(limit, allowedTypeCount, limitedTypeCount)) - { - canAdd = Validation.Failed; - break; - } - } - - if (typeFound && canAdd == Validation.NotApplicable) - { - canAdd = Validation.Passed; - } - - return canAdd; - } - - protected override string GetFailedRequirementsString(Army army) - { - return String.Join("; ", GetFailedValidationRequirements(army).ToArray()); - } - - private List GetFailedValidationRequirements(Army army) - { - List failures = new List(); - int allowedTypeCount = army.GetUnitTypeCount(allowedType); - - foreach (UnitCountRequirementData limit in requiredTypes) - { - int limitedTypeCount = GetUnitTypesCount(army, limit.UnitTypes); - - if (!IsValidByRequirement(limit, allowedTypeCount, limitedTypeCount)) - { - string unitTypeList = GetUnitTypeList(limit); - failures.Add(String.Format("{0} × {1} for every {2} × {3} (have {4} for {5})", limit.Count, unitTypeList, limit.AllowsCount, allowedType.Name, limitedTypeCount, allowedTypeCount)); - } - } - - return failures; - } - - private int GetUnitTypesCount(Army army, UnitType[] unitTypes) - { - return GetUnitTypesCount(army, unitTypes, null); - } - - public override string RequirementID - { - get - { - return REQUIREMENT_ID; - } - } - - /// - /// Adds a requirement for there to be at least minCount of a given UnitType, allowing allowedCount of this UnitType - /// - /// - /// The unit type to require. - /// - /// - /// The minimum number of that type that must exist. - /// - /// - /// The number of units allowed for every minCount units of the supplied unit type. - /// - public void AddUnitTypeRequirement(UnitType unitType, int minCount, int allowedCount) - { - requiredTypes.Add(new UnitCountRequirementData(unitType, minCount, allowedCount)); - } - - /// - /// Adds a requirement for there to be at least one of a given UnitType, allowing allowedCount of this UnitType - /// - /// - /// The unit type to require. - /// - /// - /// The number of units allowed for each unit of the supplied unit type. - /// - public void AddUnitTypeRequirement(UnitType unitType, int allowedCount) - { - AddUnitTypeRequirement(allowedCount, unitType); - } - - /// - /// Adds a requirement for there to be one or more of the given UnitTypes, allowing one of this UnitType. If multiple unit types - /// are supplied here then the number is additive (so 1 x unitType1 and 1 x unitType2 allows two of this UnitType). - /// - /// - /// The unit type or types to require. - /// - public void AddUnitTypeRequirement(params UnitType[] unitTypes) - { - AddUnitTypeRequirement(1, unitTypes); - } - - /// - /// Adds a requirement for there to be one or more of the given UnitTypes, allowing allowsAmount of this UnitType. If multiple unit types - /// are supplied here then the number is additive (so 1 x unitType1 and 1 x unitType2 allows two of this UnitType). - /// - /// - /// The number of units to be allowed for each 1 of unitType - /// - /// - /// The unit type or types to require. - /// - public void AddUnitTypeRequirement(int allowsAmount, params UnitType[] unitTypes) - { - requiredTypes.Add(new UnitCountRequirementData(unitTypes, 1, allowsAmount)); - } - - /// - /// Adds a requirement for there to be minCount or more of the given UnitTypes, allowing allowsAmount of this UnitType. If multiple unit types - /// are supplied here then the number is additive (so 1 x unitType1 and 1 x unitType2 allows two of this UnitType). - /// - /// - /// The minimum number of that type that must exist. - /// - /// - /// The number of units to be allowed for each 1 of unitType - /// - /// - /// The unit type or types to require. - /// - public void AddUnitTypeRequirement(int minCount, int allowsAmount, params UnitType[] unitTypes) - { - requiredTypes.Add(new UnitCountRequirementData(unitTypes, minCount, allowsAmount)); - } - } -} - diff -r def5d333c5e8 -r afc6410e4efc API/Objects/Requirement/RequiresNoMoreThanNOfUnitTypeRequirement.cs --- a/API/Objects/Requirement/RequiresNoMoreThanNOfUnitTypeRequirement.cs Tue Jan 31 20:58:09 2012 +0000 +++ b/API/Objects/Requirement/RequiresNoMoreThanNOfUnitTypeRequirement.cs Wed Feb 22 20:45:39 2012 +0000 @@ -11,19 +11,14 @@ /// /// A requirement where a WarFoundryObject cannot be taken in an army if more than N of a UnitType will be in the army. /// - public class RequiresNoMoreThanNOfUnitTypeRequirement : AbstractRequirement + public class RequiresNoMoreThanNOfUnitTypeRequirement : AbstractUnitRequirement where OBJECT_TYPE : IWarFoundryObject { public static readonly string REQUIREMENT_ID = "RequiresNoMoreThanNUnits"; private List limitedTypes; - public RequiresNoMoreThanNOfUnitTypeRequirement(params UnitType[] limitedUnitTypes) + public RequiresNoMoreThanNOfUnitTypeRequirement(params UnitType[] limitedUnitTypes) : base(default(OBJECT_TYPE), limitedUnitTypes) { limitedTypes = new List(); - - foreach (UnitType unitType in limitedUnitTypes) - { - AddUnitTypeRequirement(unitType); - } } public override string RequirementID @@ -46,7 +41,7 @@ /// /// The army to add the object to. /// - public override Validation AllowsAdding(WarFoundryObject wfObject, Army toArmy) + public override Validation AllowsAdding(IWarFoundryObject wfObject, Army toArmy) { Validation canAdd = Validation.Passed; @@ -92,7 +87,7 @@ /// /// The unit type to limit. /// - public void AddUnitTypeRequirement(UnitType unitType) + public override void AddUnitTypeRequirement(UnitType unitType) { AddUnitTypeRequirement(unitType, 0); } @@ -124,7 +119,7 @@ protected override bool TypeEquals(object obj) { - RequiresNoMoreThanNOfUnitTypeRequirement other = (RequiresNoMoreThanNOfUnitTypeRequirement)obj; + RequiresNoMoreThanNOfUnitTypeRequirement other = (RequiresNoMoreThanNOfUnitTypeRequirement)obj; return Collections.Collections.AreEqual(limitedTypes, other.limitedTypes); } @@ -170,18 +165,18 @@ return failures; } - protected override string GetFailedAddingRequirementsString(UnitType toAdd, Army toArmy) + protected override string GetFailedAddingRequirementsString(IWarFoundryObject toAdd, Army toArmy) { return String.Join("; ", GetFailedAddingRequirements(toAdd, toArmy).ToArray()); } - private List GetFailedAddingRequirements(UnitType unitType, Army army) + private List GetFailedAddingRequirements(IWarFoundryObject toAdd, Army army) { List failures = new List(); foreach (UnitCountRequirementData requirement in limitedTypes) { - int unitCount = GetUnitTypeCount(army, requirement.UnitType, unitType); + int unitCount = GetUnitTypeCount(army, requirement.UnitType, toAdd); if (unitCount > requirement.Count) { @@ -191,6 +186,11 @@ return failures; } + + protected override int GetObjectCountFromArmy(Army toArmy) + { + return 0; + } } } diff -r def5d333c5e8 -r afc6410e4efc API/Objects/Requirement/UnitRequiresAtLeastNUnitsRequirement.cs --- a/API/Objects/Requirement/UnitRequiresAtLeastNUnitsRequirement.cs Tue Jan 31 20:58:09 2012 +0000 +++ b/API/Objects/Requirement/UnitRequiresAtLeastNUnitsRequirement.cs Wed Feb 22 20:45:39 2012 +0000 @@ -10,28 +10,25 @@ /// /// A requirement where a UnitType requires at least N units of one or more unit types before any number of that object can be taken in an army. /// - public class UnitRequiresAtLeastNUnitsRequirement : RequiresAtLeastNUnitsRequirement + public class UnitRequiresAtLeastNUnitsRequirement : RequiresAtLeastNUnitsRequirement { - private UnitType requirementOnType; - - public UnitRequiresAtLeastNUnitsRequirement(UnitType requirementOn) : base() + public UnitRequiresAtLeastNUnitsRequirement(UnitType requirementOn) : base(requirementOn) { - requirementOnType = requirementOn; } - protected override bool IsApplicable(WarFoundryObject toObjectAdded) + protected override bool IsApplicable(IWarFoundryObject toObjectAdded) { return base.IsApplicable(toObjectAdded) || IsRequirementOnType(toObjectAdded); } - private bool IsRequirementOnType(WarFoundryObject toObjectAdded) + private bool IsRequirementOnType(IWarFoundryObject toObjectAdded) { - return requirementOnType.Equals(toObjectAdded) || (toObjectAdded is Unit && requirementOnType.Equals(((Unit)toObjectAdded).UnitType)); + return AllowedObject.Equals(toObjectAdded) || (toObjectAdded is Unit && AllowedObject.Equals(((Unit)toObjectAdded).UnitType)); } protected override bool IsApplicable(Army toArmy) { - return toArmy.GetUnitTypeCount(requirementOnType) > 0; + return toArmy.GetUnitTypeCount(AllowedObject) > 0; } public override Validation ValidatesArmy(Army toArmy) diff -r def5d333c5e8 -r afc6410e4efc API/Objects/Requirement/UnitRequiresNUnitsForMUnitsRequirement.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/API/Objects/Requirement/UnitRequiresNUnitsForMUnitsRequirement.cs Wed Feb 22 20:45:39 2012 +0000 @@ -0,0 +1,79 @@ +// This file (UnitRequiresAtLeastNUnitsRequirement.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2011 IBBoard +// +// The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. +using System; +using System.Collections.Generic; +using IBBoard.WarFoundry.API.Objects; + +namespace IBBoard.WarFoundry.API.Objects.Requirement +{ + /// + /// A requirement where N of a UnitType can only be taken if there are M of a unit type in the army. + /// + public class UnitRequiresNUnitsForMUnitsRequirement : RequiresNUnitsForMObjectsRequirement + { + //Note: We're sticking with the old requirement name to prevent breakage + public static readonly string REQUIREMENT_ID = "RequiresNUnitsForMUnits"; + + public UnitRequiresNUnitsForMUnitsRequirement(UnitType requirementOn, params UnitType[] requiredUnitTypes) : base(requirementOn, requiredUnitTypes) + { + //Do nothing + } + + /// + /// Checks whether the supplied WarFoundryObject can be added to the supplied army. + /// + /// + /// A Validation enum to show the result of the validation + /// + /// + /// 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 override Validation AllowsAdding(IWarFoundryObject wfObject, Army toArmy) + { + return IsApplicable(wfObject, toArmy) ? base.AllowsAdding(wfObject, toArmy) : Validation.NotApplicable; + } + + protected override bool IsApplicable(IWarFoundryObject toObject, Army toArmy) + { + return IsApplicable(toArmy) || IsApplicable(toObject); + } + + protected override bool IsApplicable(Army toArmy) + { + return toArmy.GetUnitTypeCount(AllowedObject) > 0; + } + + protected override bool IsApplicable(IWarFoundryObject toObject) + { + return AllowedObject.Equals(toObject) || (toObject is Unit && AllowedObject.Equals(((Unit)toObject).UnitType)); + } + + public override string RequirementID + { + get + { + return REQUIREMENT_ID; + } + } + + protected override int GetObjectCountFromArmy(Army toArmy) + { + return GetObjectCountFromArmy(toArmy, AllowedObject); + } + + protected override int GetObjectCountFromArmy(Army toArmy, UnitType unitType) + { + return toArmy.GetUnitTypeCount(unitType); + } + + protected override int GetAllowedObjectCount(Army army) + { + return army.GetUnitTypeCount(AllowedObject); + } + } +} + diff -r def5d333c5e8 -r afc6410e4efc API/Objects/Requirement/UnitRequiresNoMoreThanNOfUnitTypeRequirement.cs --- a/API/Objects/Requirement/UnitRequiresNoMoreThanNOfUnitTypeRequirement.cs Tue Jan 31 20:58:09 2012 +0000 +++ b/API/Objects/Requirement/UnitRequiresNoMoreThanNOfUnitTypeRequirement.cs Wed Feb 22 20:45:39 2012 +0000 @@ -10,7 +10,7 @@ /// /// A requirement where a UnitType can only be taken if there are no more than N units of one or more unit in an army. /// - public class UnitRequiresNoMoreThanNOfUnitTypeRequirement : RequiresNoMoreThanNOfUnitTypeRequirement + public class UnitRequiresNoMoreThanNOfUnitTypeRequirement : RequiresNoMoreThanNOfUnitTypeRequirement { private UnitType requirementOnType; @@ -31,12 +31,12 @@ /// /// The army to add the object to. /// - public override Validation AllowsAdding(WarFoundryObject wfObject, Army toArmy) + public override Validation AllowsAdding(IWarFoundryObject wfObject, Army toArmy) { return IsApplicable(wfObject, toArmy) ? base.AllowsAdding(wfObject, toArmy) : Validation.NotApplicable; } - protected override bool IsApplicable(WarFoundryObject toObject, Army toArmy) + protected override bool IsApplicable(IWarFoundryObject toObject, Army toArmy) { return IsApplicable(toArmy) || IsApplicable(toObject); } @@ -46,7 +46,7 @@ return toArmy.GetUnitTypeCount(requirementOnType) > 0; } - protected override bool IsApplicable(WarFoundryObject toObject) + protected override bool IsApplicable(IWarFoundryObject toObject) { return requirementOnType.Equals(toObject) || (toObject is Unit && requirementOnType.Equals(((Unit)toObject).UnitType)); } diff -r def5d333c5e8 -r afc6410e4efc API/Objects/UnitType.cs --- a/API/Objects/UnitType.cs Tue Jan 31 20:58:09 2012 +0000 +++ b/API/Objects/UnitType.cs Wed Feb 22 20:45:39 2012 +0000 @@ -1,7 +1,6 @@ // This file (UnitType.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2007, 2008, 2009 IBBoard. // // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. - using System; using System.Collections.Generic; using System.Xml; @@ -37,14 +36,13 @@ private Dictionary slotLimits = new Dictionary(); private Dictionary unitMemberTypes = new Dictionary(); private List cats = new List(); - public UnitType(string id, string typeName, Race parentRace) : base(id, typeName) { race = parentRace; } - public override bool Equals (object obj) + public override bool Equals(object obj) { if (obj == null) { @@ -190,7 +188,7 @@ /// private void CheckMinimumNumber() { - if (MinNumber > MaxNumber && MaxNumber!=WarFoundryCore.INFINITY) + if (MinNumber > MaxNumber && MaxNumber != WarFoundryCore.INFINITY) { MinNumber = MaxNumber; LogNotifier.WarnFormat(GetType(), "Unit type {0} ({1}) had a minimum number greater than their maximum number.", Name, ID); @@ -202,7 +200,7 @@ /// private void CheckMinimumSize() { - if (MinSize > MaxSize && MaxSize!=WarFoundryCore.INFINITY) + if (MinSize > MaxSize && MaxSize != WarFoundryCore.INFINITY) { MinSize = MaxSize; LogNotifier.WarnFormat(GetType(), "Unit type {0} ({1}) had a minimum size greater than their maximum size.", Name, ID); @@ -238,7 +236,7 @@ protected override string DefaultName() { - throw new InvalidOperationException("Unit type with id "+id+" did not have a name specified"); + throw new InvalidOperationException("Unit type with id " + id + " did not have a name specified"); } /// @@ -279,7 +277,7 @@ public string[] UnitStatsArrayIDs { - get + get { string[] ids; @@ -345,7 +343,7 @@ public Stat[] ExtendStatsArrayWithName(Stat[] statsArray) { - Stat[] extendedStats = new Stat[statsArray.Length+1]; + Stat[] extendedStats = new Stat[statsArray.Length + 1]; extendedStats[0] = new Stat(new StatSlot("name"), Name); statsArray.CopyTo(extendedStats, 1); return extendedStats; @@ -500,16 +498,16 @@ if (MinNumber != 0) { - RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(); - req.AddUnitTypeRequirement(this, MinNumber); - reqs.Add(req); + //RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(); + //req.AddUnitTypeRequirement(this, MinNumber); + //reqs.Add(req); } if (MaxNumber != WarFoundryCore.INFINITY) { - RequiresNoMoreThanNOfUnitTypeRequirement req = new RequiresNoMoreThanNOfUnitTypeRequirement(); - req.AddUnitTypeRequirement(this, MaxNumber); - reqs.Add(req); + //RequiresNoMoreThanNOfUnitTypeRequirement req = new RequiresNoMoreThanNOfUnitTypeRequirement(); + //req.AddUnitTypeRequirement(this, MaxNumber); + //reqs.Add(req); } return reqs.ToArray(); diff -r def5d333c5e8 -r afc6410e4efc IBBoard.WarFoundry.API.csproj --- a/IBBoard.WarFoundry.API.csproj Tue Jan 31 20:58:09 2012 +0000 +++ b/IBBoard.WarFoundry.API.csproj Wed Feb 22 20:45:39 2012 +0000 @@ -176,7 +176,6 @@ - @@ -191,8 +190,10 @@ PreserveNewest - + + +