Mercurial > repos > snowblizz-super-API-ideas
comparison api/Objects/Unit.cs @ 134:57f7b80757ea
Re #68: Export army to another format
* Add styling to table
* Add in text for equipment
* Add method to Unit to get equipment amount strings
* Refactor unit equipment handling to reduce duplication
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 01 Sep 2009 18:56:38 +0000 |
parents | c60fd5664698 |
children | 7f13ffcb8765 |
comparison
equal
deleted
inserted
replaced
133:a6d1cc17ec33 | 134:57f7b80757ea |
---|---|
267 return GetEquipmentAmount(UnitType.GetEquipmentItem(equipID)); | 267 return GetEquipmentAmount(UnitType.GetEquipmentItem(equipID)); |
268 } | 268 } |
269 | 269 |
270 public bool GetEquipmentAmountIsRatio(UnitEquipmentItem item) | 270 public bool GetEquipmentAmountIsRatio(UnitEquipmentItem item) |
271 { | 271 { |
272 return (DictionaryUtils.GetValue(equipment, item) is UnitEquipmentRatioSelection); | 272 return IsEquipmentAmountRatio(GetEquipmentSelection(item)); |
273 } | |
274 | |
275 private AbstractUnitEquipmentItemSelection GetEquipmentSelection(UnitEquipmentItem item) | |
276 { | |
277 return DictionaryUtils.GetValue(equipment, item); | |
278 } | |
279 | |
280 private bool IsEquipmentAmountRatio(AbstractUnitEquipmentItemSelection selection) | |
281 { | |
282 return (selection is UnitEquipmentRatioSelection); | |
273 } | 283 } |
274 | 284 |
275 public bool GetEquipmentAmountIsRatio(string itemID) | 285 public bool GetEquipmentAmountIsRatio(string itemID) |
276 { | 286 { |
277 return GetEquipmentAmountIsRatio(UnitType.GetEquipmentItem(itemID)); | 287 return GetEquipmentAmountIsRatio(UnitType.GetEquipmentItem(itemID)); |
288 } | |
289 | |
290 public string GetEquipmentAmountString(string equipID) | |
291 { | |
292 return GetEquipmentAmountString(UnitType.GetEquipmentItem(equipID)); | |
293 } | |
294 | |
295 public string GetEquipmentAmountString(UnitEquipmentItem item) | |
296 { | |
297 String amountString = ""; | |
298 AbstractUnitEquipmentItemSelection selection = GetEquipmentSelection(item); | |
299 | |
300 if (IsEquipmentAmountRatio(selection)) | |
301 { | |
302 amountString = UnitEquipmentRatioSelection.GetEquipmentAmountString(GetEquipmentAmount(item)); | |
303 } | |
304 else | |
305 { | |
306 amountString = UnitEquipmentNumericSelection.GetEquipmentAmountString(GetEquipmentAmount(item)); | |
307 } | |
308 | |
309 return amountString; | |
278 } | 310 } |
279 | 311 |
280 public void SetEquipmentAmount(UnitEquipmentItem equip, int amount) | 312 public void SetEquipmentAmount(UnitEquipmentItem equip, int amount) |
281 { | 313 { |
282 if (amount <1 && amount != WarFoundryCore.INFINITY) | 314 if (amount <1 && amount != WarFoundryCore.INFINITY) |