Mercurial > repos > snowblizz-super-API-ideas
comparison api/Objects/Unit.cs @ 101:f7b9423c2a5a
Big mess of updates, breaking our rules on "commit little and often" because the code was so ugly.
This revision will be broken for the WinForms UI, but as MonoDevelop/eSVN don't have a way of committing multiple projects in one go it can't be helped (Eclipse's Team Sync view could handle it)
Fixes #122: Make usage of percentage or ratio common
* All usage of ratio amounts for equipment items should now assume percentage
* Properly calculate number taken for ratio selection (divide by 0 now we're using percentages)
Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
* Added extra commands that differentiate between ratio and absolute amounts
Fixes #120: Numeric limit equipment items show large percentages
* Now made formatting treat ratios as percentages (don't multiply by 100)
* Move string formatting to UnitEquipmentItem...Selection classes
* Add method to Unit to say whether an equipment item is a numeric or ratio amount
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Thu, 13 Aug 2009 21:09:20 +0000 |
parents | 4dd1c41c95b4 |
children | 2f3cafb69799 |
comparison
equal
deleted
inserted
replaced
100:38e788859199 | 101:f7b9423c2a5a |
---|---|
266 | 266 |
267 public double GetEquipmentAmount(string equipID) | 267 public double GetEquipmentAmount(string equipID) |
268 { | 268 { |
269 return GetEquipmentAmount(UnitType.GetEquipmentItem(equipID)); | 269 return GetEquipmentAmount(UnitType.GetEquipmentItem(equipID)); |
270 } | 270 } |
271 | |
272 public bool GetEquipmentAmountIsRatio(UnitEquipmentItem item) | |
273 { | |
274 return (DictionaryUtils.GetValue(equipment, item) is UnitEquipmentRatioSelection); | |
275 } | |
276 | |
277 public bool GetEquipmentAmountIsRatio(string itemID) | |
278 { | |
279 return GetEquipmentAmountIsRatio(UnitType.GetEquipmentItem(itemID)); | |
280 } | |
271 | 281 |
272 public void SetEquipmentAmount(UnitEquipmentItem equip, int amount) | 282 public void SetEquipmentAmount(UnitEquipmentItem equip, int amount) |
273 { | 283 { |
274 if (amount <1 && amount != WarFoundryCore.INFINITY) | 284 if (amount <1 && amount != WarFoundryCore.INFINITY) |
275 { | 285 { |
328 if (!equip.IsRatioLimit) | 338 if (!equip.IsRatioLimit) |
329 { | 339 { |
330 throw new InvalidOperationException("Equipment with ID "+equip.ID+" for unit of type "+UnitType.ID+" has an absolute limit, not a ratio limit"); | 340 throw new InvalidOperationException("Equipment with ID "+equip.ID+" for unit of type "+UnitType.ID+" has an absolute limit, not a ratio limit"); |
331 } | 341 } |
332 | 342 |
333 if (ratio > 1) | 343 if (ratio > 100) |
334 { | 344 { |
335 ratio = 1; | 345 ratio = 100; |
336 } | 346 } |
337 else if (ratio < 0) | 347 else if (ratio < 0) |
338 { | 348 { |
339 ratio = 0; | 349 ratio = 0; |
340 } | 350 } |