changeset 62:e8735def0db5

Re #61 - Complete structure of WarFoundry API objects * Add CompositeEquipmentItem to handle composite items in Army schema
author IBBoard <dev@ibboard.co.uk>
date Thu, 09 Apr 2009 15:04:39 +0000
parents 3c77722a02b5
children a920b1bcb408
files IBBoard.WarFoundry.API.csproj api/Objects/CompositeEquipmentItem.cs
diffstat 2 files changed, 41 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/IBBoard.WarFoundry.API.csproj	Thu Apr 09 14:17:53 2009 +0000
     1.2 +++ b/IBBoard.WarFoundry.API.csproj	Thu Apr 09 15:04:39 2009 +0000
     1.3 @@ -125,6 +125,7 @@
     1.4      <Compile Include="api\Factories\Xml\WarFoundryXmlFactoryUtils.cs" />
     1.5      <Compile Include="api\Factories\Xml\AbstractStagedLoadedSubFactory.cs" />
     1.6      <Compile Include="api\Objects\InvalidContainershipException.cs" />
     1.7 +    <Compile Include="api\Objects\CompositeEquipmentItem.cs" />
     1.8    </ItemGroup>
     1.9    <ItemGroup>
    1.10      <Content Include="libs\ICSharpCode.SharpZipLib.dll" />
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/api/Objects/CompositeEquipmentItem.cs	Thu Apr 09 15:04:39 2009 +0000
     2.3 @@ -0,0 +1,40 @@
     2.4 +//  This file (CompositeEquipmentItem.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard
     2.5 +// 
     2.6 +//  The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license.
     2.7 +// 
     2.8 +
     2.9 +using System;
    2.10 +using System.Collections.Generic;
    2.11 +
    2.12 +namespace IBBoard.WarFoundry.API.Objects
    2.13 +{
    2.14 +	/// <summary>
    2.15 +	/// A special <see cref=" EquipmentItem"/> that is made up of a number of other <code>EquipmentItem</code>s
    2.16 +	/// </summary>
    2.17 +	public class CompositeEquipmentItem : EquipmentItem
    2.18 +	{
    2.19 +		private List<EquipmentItem> compositeItems;
    2.20 +			
    2.21 +		public CompositeEquipmentItem(string id, string name, Race race) : base(id, name, race)
    2.22 +		{
    2.23 +			containedItems = new List<EquipmentItem>();
    2.24 +		}
    2.25 +		
    2.26 +		public void AddItem(EquipmentItem item)
    2.27 +		{
    2.28 +			compositeItems.Add(item);
    2.29 +			Cost+= item.Cost;
    2.30 +		}
    2.31 +		
    2.32 +		public void RemoveItem(EquipmentItem item)
    2.33 +		{
    2.34 +			compositeItems.Remove(item);
    2.35 +			cost-= item.Cost;
    2.36 +		}
    2.37 +		
    2.38 +		public EquipmentItem[] Items
    2.39 +		{
    2.40 +			get { return compositeItems.ToArray(); }
    2.41 +		}
    2.42 +	}
    2.43 +}