Mercurial > repos > IBBoard.WarFoundry.API
diff api/Objects/EquipmentItem.cs @ 54:3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
* Remove min/max from EquipmentItem and add description
* Add min/max numbers and percentages to UnitEquipmentItem
* Make Race schema define min/max number without the ratio (which is the percentage)
* Replace use of EquipmentItem with UnitEquipmentItem because of increased use of UnitEquipmentItem for unit-specific data
* Use doubles instead of floats for equipment amounts
* Distinguish between ratio and absolute limits
* Delete UnitEquipmentItemObj helper class that was purely used for UI
Re #9 - Use smaller methods
* Deprecate long Race and EquipmentItem constructors and ensure all getters/setters exist
Also:
* Migrate Unit to using genericed collections
* Always use GameSystem object for Race, not ID string
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 05 Apr 2009 13:45:23 +0000 |
parents | d0812d7de39d |
children | 3ea0ab04352b |
line wrap: on
line diff
--- a/api/Objects/EquipmentItem.cs Wed Apr 01 19:20:27 2009 +0000 +++ b/api/Objects/EquipmentItem.cs Sun Apr 05 13:45:23 2009 +0000 @@ -12,50 +12,22 @@ /// </summary> public class EquipmentItem : WarFoundryObject { - private double cost, min, max; + private double cost; + private string description; private ArmourType armourType; - private Race equipForRace; - - public EquipmentItem(string id, string name, double itemCost, double minimum, double maximum, ArmourType itemArmourType, Race race) : base(id, name) + private Race equipForRace; + + public EquipmentItem(string id, string name, Race race) : base(id, name) { - cost = itemCost; - min = minimum; - max = maximum; - armourType = itemArmourType; equipForRace = race; - } - - public bool IsRatioLimit - { - get { return ((MaxNumber < 1 && MaxNumber > 0) || (MaxNumber == 1 && MinNumber > 0)); } + description = ""; + armourType = ArmourType.None; } - - public double MinNumber - { - get { return min; } - set - { - min = (value >= 0 || value == WarFoundryCore.INFINITY) ? value : 0; - - if (MaxNumber != WarFoundryCore.INFINITY && min > MaxNumber) - { - MaxNumber = min; - } - } - } - - public double MaxNumber - { - get { return max; } - set - { - max = (value > 0 || value == WarFoundryCore.INFINITY) ? value : WarFoundryCore.INFINITY; - - if (max != WarFoundryCore.INFINITY && MinNumber > max) - { - MinNumber = max; - } - } + + [Obsolete("Use the three argument constructor and the appropriate 'set' methods")] + public EquipmentItem(string id, string name, double itemCost, double minimum, double maximum, ArmourType itemArmourType, Race race) : this(id, name, race) + { + ItemArmourType = itemArmourType; } public ArmourType ItemArmourType @@ -67,7 +39,19 @@ public double Cost { get { return cost; } - set { cost = value; } + set + { + if (value >= 0) + { + cost = value; + } + } + } + + public string Description + { + get { return description; } + set { description = (value == null ? "" : value); } } public Race EquipmentForRace