comparison api/Objects/UnitEquipmentItem.cs @ 0:520818033bb6

Initial commit of WarFoundry code
author IBBoard <dev@ibboard.co.uk>
date Fri, 19 Dec 2008 15:57:51 +0000
parents
children 306558904c2a
comparison
equal deleted inserted replaced
-1:000000000000 0:520818033bb6
1 using System;
2 using System.Xml;
3
4 namespace IBBoard.WarFoundry.API.Objects
5 {
6 /// <summary>
7 /// Summary description for UnitEquipmentItem.
8 /// </summary>
9 public class UnitEquipmentItem : WarFoundryObject
10 {
11 private bool required, roundUp;
12 private string mutexGroup;
13 private UnitType unitType;
14
15 /*public UnitEquipmentItem(XmlElement node, UnitType equipForType)
16 {
17 EquipmentForUnit = equipForType;
18 ID = node.GetAttribute("id");
19 IsRequired = bool.Parse(node.GetAttribute("required"));
20 RoundNumberUp = "up".Equals(node.GetAttribute("roundDirection").ToLower());
21 MutexGroup = node.GetAttribute("exclusivityGroup");
22 }*/
23 protected UnitEquipmentItem(UnitType equipForType)
24 {
25 EquipmentForUnit = equipForType;
26 }
27
28 public bool IsRequired
29 {
30 get { return required; }
31 set { required = value; }
32 }
33
34 public bool RoundNumberUp
35 {
36 get { return roundUp; }
37 set { roundUp = value; }
38 }
39
40 public string MutexGroup
41 {
42 get { return mutexGroup; }
43 set { mutexGroup = (value == null ? "" : value.Trim()); }
44 }
45
46 public UnitType EquipmentForUnit
47 {
48 get { return unitType; }
49 set
50 {
51 if (value != null)
52 {
53 unitType = value;
54 }
55 }
56 }
57
58 public EquipmentItem EquipmentItem
59 {
60 get { return EquipmentForUnit == null ? null : EquipmentForUnit.Race.GetEquipmentItem(ID); }
61 }
62
63 public override string ToString()
64 {
65 return EquipmentItem.Name+ " ("+EquipmentItem.Cost+"pts each)";
66 }
67
68 public bool HasAlternatives()
69 {
70 if (MutexGroup=="")
71 {
72 return false;
73 }
74 else
75 {
76 //If the number of items in the MutEx group is greater than one then it must be this item plus another
77 return EquipmentForUnit.GetEquipmentItemsByExclusionGroup(MutexGroup).Length > 1;
78 }
79 }
80 }
81 }