annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
62
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 // This file (CompositeEquipmentItem.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
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.
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 //
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using System;
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using System.Collections.Generic;
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 namespace IBBoard.WarFoundry.API.Objects
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 {
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 /// <summary>
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 /// A special <see cref=" EquipmentItem"/> that is made up of a number of other <code>EquipmentItem</code>s
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 /// </summary>
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 public class CompositeEquipmentItem : EquipmentItem
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 {
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 private List<EquipmentItem> compositeItems;
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 public CompositeEquipmentItem(string id, string name, Race race) : base(id, name, race)
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 {
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 containedItems = new List<EquipmentItem>();
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 }
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 public void AddItem(EquipmentItem item)
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 {
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 compositeItems.Add(item);
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 Cost+= item.Cost;
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 }
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 public void RemoveItem(EquipmentItem item)
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 {
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 compositeItems.Remove(item);
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 cost-= item.Cost;
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 }
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 public EquipmentItem[] Items
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 {
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37 get { return compositeItems.ToArray(); }
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38 }
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39 }
e8735def0db5 Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
40 }