comparison api/Objects/CompositeEquipmentItem.cs @ 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
children a920b1bcb408
comparison
equal deleted inserted replaced
61:3c77722a02b5 62:e8735def0db5
1 // This file (CompositeEquipmentItem.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard
2 //
3 // 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.
4 //
5
6 using System;
7 using System.Collections.Generic;
8
9 namespace IBBoard.WarFoundry.API.Objects
10 {
11 /// <summary>
12 /// A special <see cref=" EquipmentItem"/> that is made up of a number of other <code>EquipmentItem</code>s
13 /// </summary>
14 public class CompositeEquipmentItem : EquipmentItem
15 {
16 private List<EquipmentItem> compositeItems;
17
18 public CompositeEquipmentItem(string id, string name, Race race) : base(id, name, race)
19 {
20 containedItems = new List<EquipmentItem>();
21 }
22
23 public void AddItem(EquipmentItem item)
24 {
25 compositeItems.Add(item);
26 Cost+= item.Cost;
27 }
28
29 public void RemoveItem(EquipmentItem item)
30 {
31 compositeItems.Remove(item);
32 cost-= item.Cost;
33 }
34
35 public EquipmentItem[] Items
36 {
37 get { return compositeItems.ToArray(); }
38 }
39 }
40 }