changeset 347:44a6539fadf9

Re #27: Unit requirements * Add base interface for all requirements and extend it in existing requirements * Add stub method for getting requirements of race (UnitTypes need to be able to add them first before testing goes further)
author IBBoard <dev@ibboard.co.uk>
date Sat, 09 Apr 2011 15:51:39 +0000
parents b0ba1d25f51e
children d34ae0057a39
files API/Objects/Race.cs API/Objects/Requirement/IRequirement.cs API/Objects/Requirement/RequiresAtLeastNUnitsRequirement.cs API/Objects/Requirement/RequiresNoMoreThanNOfUnitTypeRequirement.cs IBBoard.WarFoundry.API.csproj
diffstat 5 files changed, 49 insertions(+), 2 deletions(-) [+]
line diff
     1.1 --- a/API/Objects/Race.cs	Sat Apr 09 15:14:16 2011 +0000
     1.2 +++ b/API/Objects/Race.cs	Sat Apr 09 15:51:39 2011 +0000
     1.3 @@ -8,6 +8,7 @@
     1.4  using System.Xml;
     1.5  using IBBoard.IO;
     1.6  using IBBoard.WarFoundry.API.Factories;
     1.7 +using IBBoard.WarFoundry.API.Objects.Requirement;
     1.8  
     1.9  namespace IBBoard.WarFoundry.API.Objects
    1.10  {
    1.11 @@ -304,5 +305,11 @@
    1.12  				return DictionaryUtils.ToArray(memberTypes);
    1.13  			}
    1.14  		}
    1.15 +
    1.16 +		public ICollection<IRequirement> GetRequirements ()
    1.17 +		{
    1.18 +			ICollection<IRequirement> reqs = new List<IRequirement>();
    1.19 +			return reqs;
    1.20 +		}
    1.21  	}
    1.22  }
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/API/Objects/Requirement/IRequirement.cs	Sat Apr 09 15:51:39 2011 +0000
     2.3 @@ -0,0 +1,39 @@
     2.4 +// This file (Requirement.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2011 IBBoard
     2.5 +// 
     2.6 +// 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.
     2.7 +using System;
     2.8 +
     2.9 +namespace IBBoard.WarFoundry.API.Objects.Requirement
    2.10 +{
    2.11 +	/// <summary>
    2.12 +	/// Base interface for a Requirement that constrains the units/equipment that can be taken in an army
    2.13 +	/// </summary>
    2.14 +	public interface IRequirement
    2.15 +	{
    2.16 +		/// <summary>
    2.17 +		/// Checks whether the supplied WarFoundryObject can be added to the supplied army.
    2.18 +		/// </summary>
    2.19 +		/// <returns>
    2.20 +		/// A <code>Validation</code> enum to show the result of the validation
    2.21 +		/// </returns>
    2.22 +		/// <param name='wfObject'>
    2.23 +		/// The object that we want to add. This may be involved in the check, or it may not affect the evaluation of the requirement
    2.24 +		/// </param>
    2.25 +		/// <param name='toArmy'>
    2.26 +		/// The army to add the object to.
    2.27 +		/// </param>
    2.28 +		Validation AllowsAdding(WarFoundryObject wfObject, Army toArmy);
    2.29 +
    2.30 +		/// <summary>
    2.31 +		/// Checks whether the supplied army is currently valid according to this requirement.
    2.32 +		/// </summary>
    2.33 +		/// <returns>
    2.34 +		/// A <code>Validation</code> enum to show the result of the validation
    2.35 +		/// </returns>
    2.36 +		/// <param name='toValidate'>
    2.37 +		/// The army to validate
    2.38 +		/// </param>
    2.39 +		Validation ValidatesArmy(Army army);
    2.40 +	}
    2.41 +}
    2.42 +
     3.1 --- a/API/Objects/Requirement/RequiresAtLeastNUnitsRequirement.cs	Sat Apr 09 15:14:16 2011 +0000
     3.2 +++ b/API/Objects/Requirement/RequiresAtLeastNUnitsRequirement.cs	Sat Apr 09 15:51:39 2011 +0000
     3.3 @@ -10,7 +10,7 @@
     3.4  	/// <summary>
     3.5  	/// A requirement where a WarFoundryObject requires at least N units of one or more unit types before any number of that object can be taken in an army.
     3.6  	/// </summary>
     3.7 -	public class RequiresAtLeastNUnitsRequirement
     3.8 +	public class RequiresAtLeastNUnitsRequirement : IRequirement
     3.9  	{
    3.10  		private List<UnitCountRequirementData> requiredTypes;
    3.11  
     4.1 --- a/API/Objects/Requirement/RequiresNoMoreThanNOfUnitTypeRequirement.cs	Sat Apr 09 15:14:16 2011 +0000
     4.2 +++ b/API/Objects/Requirement/RequiresNoMoreThanNOfUnitTypeRequirement.cs	Sat Apr 09 15:51:39 2011 +0000
     4.3 @@ -10,7 +10,7 @@
     4.4  	/// <summary>
     4.5  	/// A requirement where a WarFoundryObject cannot be taken in an army if more than N of a UnitType will be in the army.
     4.6  	/// </summary>
     4.7 -	public class RequiresNoMoreThanNOfUnitTypeRequirement
     4.8 +	public class RequiresNoMoreThanNOfUnitTypeRequirement : IRequirement
     4.9  	{
    4.10  		private List<UnitCountRequirementData> limitedTypes;
    4.11  
     5.1 --- a/IBBoard.WarFoundry.API.csproj	Sat Apr 09 15:14:16 2011 +0000
     5.2 +++ b/IBBoard.WarFoundry.API.csproj	Sat Apr 09 15:51:39 2011 +0000
     5.3 @@ -191,6 +191,7 @@
     5.4      <Compile Include="API\Objects\Requirement\UnitRequiresAtLeastNUnitsRequirement.cs" />
     5.5      <Compile Include="API\Objects\Requirement\Validation.cs" />
     5.6      <Compile Include="API\Objects\Requirement\UnitRequiresNoMoreThanNOfUnitTypeRequirement.cs" />
     5.7 +    <Compile Include="API\Objects\Requirement\IRequirement.cs" />
     5.8    </ItemGroup>
     5.9    <ItemGroup>
    5.10      <Reference Include="System.Xml" />