Mercurial > repos > IBDev-IBBoard.WarFoundry.API
comparison api/Objects/UnitType.cs @ 46:a5855fcd75ab
Re #11 - Document classes and methods
* Document methods in UnitType and Category classes
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 23 Mar 2009 20:57:07 +0000 |
parents | 548cfc776f54 |
children | 9561ef46c6fb |
comparison
equal
deleted
inserted
replaced
45:75a44b7753d4 | 46:a5855fcd75ab |
---|---|
10 using IBBoard.WarFoundry.API.Requirements; | 10 using IBBoard.WarFoundry.API.Requirements; |
11 | 11 |
12 namespace IBBoard.WarFoundry.API.Objects | 12 namespace IBBoard.WarFoundry.API.Objects |
13 { | 13 { |
14 /// <summary> | 14 /// <summary> |
15 /// Summary description for Unit. | 15 /// A UnitType is a type for a <see cref=" Unit"/>, normally relating to an entry in an army list. The UnitType defines the name, cost, minimum and maximum limits of a unit, and the equipment units of the type can take. |
16 /// </summary> | 16 /// </summary> |
17 public class UnitType : WarFoundryObject | 17 public class UnitType : WarFoundryObject |
18 { | 18 { |
19 protected Category mainCat; | 19 protected Category mainCat; |
20 protected Race race; | 20 protected Race race; |
51 { | 51 { |
52 AddRequirement(requirement); | 52 AddRequirement(requirement); |
53 } | 53 } |
54 } | 54 } |
55 | 55 |
56 /// <value> | |
57 /// Gets the <see cref=" Race"/> that this unit belongs to. | |
58 /// </value> | |
56 public Race Race | 59 public Race Race |
57 { | 60 { |
58 get { return race; } | 61 get { return race; } |
59 } | 62 } |
60 | 63 |
64 /// <value> | |
65 /// Gets or sets the <see cref=" Category"/> that this unit type is a member of. | |
66 /// </value> | |
61 public virtual Category MainCategory | 67 public virtual Category MainCategory |
62 { | 68 { |
63 get | 69 get |
64 { | 70 { |
65 return mainCat; | 71 return mainCat; |
68 { | 74 { |
69 mainCat = value; | 75 mainCat = value; |
70 } | 76 } |
71 } | 77 } |
72 | 78 |
79 /// <value> | |
80 /// Gets or sets the minimum size of each unit of this type. Note: This should be set AFTER MaxSize, otherwise an unintended default value may be set for the minimum | |
81 /// </value> | |
73 public int MinSize | 82 public int MinSize |
74 { | 83 { |
75 get { return minSize; } | 84 get { return minSize; } |
76 set | 85 set |
77 { | 86 { |
78 minSize = (value >= 0 ? value : 0); | 87 minSize = (value >= 0 ? value : 0); |
79 CheckMinimumSize(); | 88 CheckMinimumSize(); |
80 } | 89 } |
81 } | 90 } |
82 | 91 |
92 /// <value> | |
93 /// Gets or sets the maximum size of each unit of this type. Note: This should be set BEFORE MinSize, otherwise an unintended default value may be set for the minimum | |
94 /// </value> | |
83 public int MaxSize | 95 public int MaxSize |
84 { | 96 { |
85 get { return maxSize; } | 97 get { return maxSize; } |
86 set | 98 set |
87 { | 99 { |
88 maxSize = (value >= 0 ? value : WarFoundryCore.INFINITY); | 100 maxSize = (value >= 0 ? value : WarFoundryCore.INFINITY); |
89 CheckMinimumSize(); | 101 CheckMinimumSize(); |
90 } | 102 } |
91 } | 103 } |
92 | 104 |
93 public int BaseSize | 105 /// <value> |
94 { | 106 /// Gets or sets the minimum number of units of this type that must be taken in an army. Note: This should be set AFTER MaxNumber, otherwise an unintended default value may be set for the minimum |
95 get { return baseSize; } | 107 /// </value> |
96 } | |
97 | |
98 public int MinNumber | 108 public int MinNumber |
99 { | 109 { |
100 get { return min; } | 110 get { return min; } |
101 set | 111 set |
102 { | 112 { |
103 min = (value >= 0 ? value : 0); | 113 min = (value >= 0 ? value : 0); |
104 CheckMinimumNumber(); | 114 CheckMinimumNumber(); |
105 } | 115 } |
106 } | 116 } |
107 | 117 |
118 /// <value> | |
119 /// Gets or sets the maximum number of units of this type that can be taken in an army. Note: This should be set BEFORE MinNumber, otherwise an unintended default value may be set for the minimum | |
120 /// </value> | |
108 public int MaxNumber | 121 public int MaxNumber |
109 { | 122 { |
110 get { return max; } | 123 get { return max; } |
111 set | 124 set |
112 { | 125 { |
113 max = (value >= 0 ? value : WarFoundryCore.INFINITY); | 126 max = (value >= 0 ? value : WarFoundryCore.INFINITY); |
114 CheckMinimumNumber(); | 127 CheckMinimumNumber(); |
115 } | 128 } |
116 } | 129 } |
117 | 130 |
131 /// <summary> | |
132 /// Makes sure that the minimum number isn't more than the maximum number, hence the warning on the properties | |
133 /// </summary> | |
118 private void CheckMinimumNumber() | 134 private void CheckMinimumNumber() |
119 { | 135 { |
120 if (MinNumber > MaxNumber && MaxNumber!=WarFoundryCore.INFINITY) | 136 if (MinNumber > MaxNumber && MaxNumber!=WarFoundryCore.INFINITY) |
121 { | 137 { |
122 MinNumber = MaxNumber; | 138 MinNumber = MaxNumber; |
123 LogNotifier.WarnFormat(GetType(), "Unit type {0} ({1}) had a minimum number greater than their maximum number.", Name, ID); | 139 LogNotifier.WarnFormat(GetType(), "Unit type {0} ({1}) had a minimum number greater than their maximum number.", Name, ID); |
124 } | 140 } |
125 } | 141 } |
126 | 142 |
143 /// <summary> | |
144 /// Makes sure that the minimum unit size isn't more than the maximum unit size, hence the warning on the properties | |
145 /// </summary> | |
127 private void CheckMinimumSize() | 146 private void CheckMinimumSize() |
128 { | 147 { |
129 if (MinSize > MaxSize && MaxSize!=WarFoundryCore.INFINITY) | 148 if (MinSize > MaxSize && MaxSize!=WarFoundryCore.INFINITY) |
130 { | 149 { |
131 MinSize = MaxSize; | 150 MinSize = MaxSize; |
132 LogNotifier.WarnFormat(GetType(), "Unit type {0} ({1}) had a minimum size greater than their maximum size.", Name, ID); | 151 LogNotifier.WarnFormat(GetType(), "Unit type {0} ({1}) had a minimum size greater than their maximum size.", Name, ID); |
133 } | 152 } |
134 } | 153 } |
135 | 154 |
155 //// <value> | |
156 /// Gets or sets the "base size" of a unit, which is the number of troopers the unit has in it for its "base cost". For a lot of units this value will be 0 as the cost is worked out based on the total number of members. | |
157 /// </value> | |
158 public int BaseSize | |
159 { | |
160 get { return baseSize; } | |
161 set { baseSize = (value >= 0 ? value : 0); } | |
162 } | |
163 | |
164 /// <value> | |
165 /// The number of points that a "base unit" of <code>BaseSize</code> models costs. Additional models are charged at <code>CostPerTrooper</code> each. | |
166 /// </value> | |
136 public double BaseUnitCost | 167 public double BaseUnitCost |
137 { | 168 { |
138 get { return baseUnitCost; } | 169 get { return baseUnitCost; } |
139 set { baseUnitCost = (value >= 0 ? value : 0); } | 170 set { baseUnitCost = (value >= 0 ? value : 0); } |
140 } | 171 } |
141 | 172 |
173 //// <value> | |
174 /// The cost of an individual trooper. This value is the cost for a basic trooper without weapons, which are added on top of the cost before calculating a unit cost. | |
175 /// </value> | |
142 public double CostPerTrooper | 176 public double CostPerTrooper |
143 { | 177 { |
144 get { return costPerTrooper; } | 178 get { return costPerTrooper; } |
145 set { costPerTrooper = (value >= 0 ? value : 0); } | 179 set { costPerTrooper = (value >= 0 ? value : 0); } |
146 } | 180 } |
148 protected override string DefaultName() | 182 protected override string DefaultName() |
149 { | 183 { |
150 throw new InvalidOperationException("Unit type with id "+id+" did not have a name specified"); | 184 throw new InvalidOperationException("Unit type with id "+id+" did not have a name specified"); |
151 } | 185 } |
152 | 186 |
187 /// <value> | |
188 /// The <see cref=" Stats"/> for the unit in a format that is valid for the game system. | |
189 /// </value> | |
153 public Stats UnitStats | 190 public Stats UnitStats |
154 { | 191 { |
155 get | 192 get |
156 { | 193 { |
157 return stats; | 194 return stats; |
163 stats = value; | 200 stats = value; |
164 } | 201 } |
165 } | 202 } |
166 } | 203 } |
167 | 204 |
205 /// <summary> | |
206 /// Gets a <see cref="UnitEquipmentItem"/> for the given ID string, or <code>null</code> if nothing exists for that ID | |
207 /// </summary> | |
208 /// <param name="id"> | |
209 /// The ID of the UnitEquipmentItem to get | |
210 /// </param> | |
211 /// <returns> | |
212 /// The <see cref="UnitEquipmentItem"/> for the given ID string, or <code>null</code> if nothing exists for that ID | |
213 /// </returns> | |
168 public UnitEquipmentItem GetEquipmentItem(string id) | 214 public UnitEquipmentItem GetEquipmentItem(string id) |
169 { | 215 { |
170 return (UnitEquipmentItem)equipment[id]; | 216 return (UnitEquipmentItem)equipment[id]; |
171 } | 217 } |
172 | 218 |
219 /// <summary> | |
220 /// Gets an array of all available <see cref="UnitEquipmentItem"/>s for this UnitType | |
221 /// </summary> | |
222 /// <returns> | |
223 /// An array of all available <see cref="UnitEquipmentItem"/>s for this UnitType | |
224 /// </returns> | |
173 public UnitEquipmentItem[] GetEquipmentItems() | 225 public UnitEquipmentItem[] GetEquipmentItems() |
174 { | 226 { |
175 UnitEquipmentItem[] items = new UnitEquipmentItem[equipment.Count]; | 227 UnitEquipmentItem[] items = new UnitEquipmentItem[equipment.Count]; |
176 int i = 0; | 228 int i = 0; |
177 | 229 |