Mercurial > repos > IBDev-IBBoard.WarFoundry.API
comparison api/Factories/Xml/WarFoundryXmlRaceFactory.cs @ 175:996816199b72
Re #195: Min and max limits on equipment
* Set max before min in race loading to avoid problems when the minimum is zero
no-open-ticket
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 21 Oct 2009 19:01:13 +0000 |
parents | 85dc413279a4 |
children | 22429737cd77 |
comparison
equal
deleted
inserted
replaced
174:33433862467f | 175:996816199b72 |
---|---|
226 throw new InvalidFileException("Attribute 'required' of unit equipment item " + id + " for " + type.Name + " was not a valid boolean", e); | 226 throw new InvalidFileException("Attribute 'required' of unit equipment item " + id + " for " + type.Name + " was not a valid boolean", e); |
227 } | 227 } |
228 | 228 |
229 try | 229 try |
230 { | 230 { |
231 unitEquipItem.MaxNumber = int.Parse(equip.GetAttribute("maxNum")); | |
232 } | |
233 catch (FormatException e) | |
234 { | |
235 throw new InvalidFileException("Attribute 'maxNum' of unit equipment item " + id + " for " + type.Name + " was not a valid integer", e); | |
236 } | |
237 | |
238 try | |
239 { | |
231 unitEquipItem.MinNumber = int.Parse(equip.GetAttribute("minNum")); | 240 unitEquipItem.MinNumber = int.Parse(equip.GetAttribute("minNum")); |
232 } | 241 } |
233 catch (FormatException e) | 242 catch (FormatException e) |
234 { | 243 { |
235 throw new InvalidFileException("Attribute 'minNum' of unit equipment item " + id + " for " + type.Name + " was not a valid integer", e); | 244 throw new InvalidFileException("Attribute 'minNum' of unit equipment item " + id + " for " + type.Name + " was not a valid integer", e); |
236 } | 245 } |
237 | 246 |
238 try | 247 try |
239 { | 248 { |
240 unitEquipItem.MaxNumber = int.Parse(equip.GetAttribute("maxNum")); | 249 unitEquipItem.MaxPercentage = double.Parse(equip.GetAttribute("maxPercentage")); |
241 } | 250 } |
242 catch (FormatException e) | 251 catch (FormatException e) |
243 { | 252 { |
244 throw new InvalidFileException("Attribute 'maxNum' of unit equipment item " + id + " for " + type.Name + " was not a valid integer", e); | 253 throw new InvalidFileException("Attribute 'maxPercentage' of unit equipment item " + id + " for " + type.Name + " was not a valid decimal number", e); |
245 } | 254 } |
246 | 255 |
247 try | 256 try |
248 { | 257 { |
249 unitEquipItem.MinPercentage = double.Parse(equip.GetAttribute("minPercentage")); | 258 unitEquipItem.MinPercentage = double.Parse(equip.GetAttribute("minPercentage")); |
250 } | 259 } |
251 catch (FormatException e) | 260 catch (FormatException e) |
252 { | 261 { |
253 throw new InvalidFileException("Attribute 'minPercentage' of unit equipment item " + id + " for " + type.Name + " was not a valid decimal number", e); | 262 throw new InvalidFileException("Attribute 'minPercentage' of unit equipment item " + id + " for " + type.Name + " was not a valid decimal number", e); |
254 } | |
255 | |
256 try | |
257 { | |
258 unitEquipItem.MaxPercentage = double.Parse(equip.GetAttribute("maxPercentage")); | |
259 } | |
260 catch (FormatException e) | |
261 { | |
262 throw new InvalidFileException("Attribute 'maxPercentage' of unit equipment item " + id + " for " + type.Name + " was not a valid decimal number", e); | |
263 } | 263 } |
264 | 264 |
265 try | 265 try |
266 { | 266 { |
267 unitEquipItem.CostMultiplier = double.Parse(equip.GetAttribute("costMultiplier")); | 267 unitEquipItem.CostMultiplier = double.Parse(equip.GetAttribute("costMultiplier")); |