Mercurial > repos > IBBoard.WarFoundry.API
changeset 79:284ebe05158c
Re #61 - Complete structure of API objects
* Add methods for new cost multiplier and rounding
* Reduce "train wreck" code by making some EquipmentItem properties visible on the UnitEquipmentItem
no-open-ticket
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 19 May 2009 14:40:10 +0000 |
parents | f70c709dad8b |
children | aa66dd18cdae |
files | api/Objects/UnitEquipmentItem.cs |
diffstat | 1 files changed, 53 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/api/Objects/UnitEquipmentItem.cs Tue May 19 14:27:40 2009 +0000 +++ b/api/Objects/UnitEquipmentItem.cs Tue May 19 14:40:10 2009 +0000 @@ -3,7 +3,8 @@ // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license. using System; -using System.Xml; +using System.Xml; +using IBBoard.Lang; namespace IBBoard.WarFoundry.API.Objects { @@ -18,7 +19,9 @@ private int minNum; private int maxNum; private double minPercentage; - private double maxPercentage; + private double maxPercentage; + private double costMultiplier; + private RoundType roundType; private string mutexGroup; private UnitType unitType; @@ -45,8 +48,29 @@ public double Cost { - get { return item.Cost; } - } + get + { + return IBBMath.Round(EquipmentItem.Cost * CostMultiplier, CostRoundType); + } + } + + public double CostMultiplier + { + get { return costMultiplier; } + set + { + costMultiplier = value; + } + } + + public RoundType CostRoundType + { + get { return roundType; } + set + { + roundType = value; + } + } public bool IsRequired { @@ -157,6 +181,31 @@ return EquipmentForUnit.GetEquipmentItemsByExclusionGroup(MutexGroup).Length > 1; } } + + public ArmourType ItemArmourType + { + get { return EquipmentItem.ItemArmourType; } + } + + public string Description + { + get { return EquipmentItem.Description; } + } + + public Race EquipmentForRace + { + get { return EquipmentItem.EquipmentForRace; } + } + + public bool CanBeUsedWithItem(EquipmentItem item) + { + return EquipmentItem.CanBeUsedWithItem(item); + } + + public bool CanBeUsedWithArmourType(ArmourType otherItemType) + { + return EquipmentItem.CanBeUsedWithArmourType(otherItemType); + } public static string FormatEquipmentAmount(UnitEquipmentItem item, double amount) {