Mercurial > repos > IBBoard.WarFoundry.API
view api/Objects/EquipmentItem.cs @ 43:d0812d7de39d
Re #49 - Resolve namespace issues
* Fix up some XPath queries
* Remove one unnecessary namespace
* Check local name of elements, not name (which is qualified)
* Add method to get double value from an attribute including handling INF
* Remove min/max for equipment item as it is now moved to the UnitType's reference to the equipment item
*
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 22 Mar 2009 17:05:01 +0000 |
parents | 548cfc776f54 |
children | 3a90f70dac73 |
line wrap: on
line source
// This file (EquipmentItem.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard. // // 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; namespace IBBoard.WarFoundry.API.Objects { /// <summary> /// Summary description for EquipmentItem. /// </summary> public class EquipmentItem : WarFoundryObject { private double cost, min, max; 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) { cost = itemCost; min = minimum; max = maximum; armourType = itemArmourType; equipForRace = race; } public bool IsRatioLimit { get { return ((MaxNumber < 1 && MaxNumber > 0) || (MaxNumber == 1 && MinNumber > 0)); } } 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; } } } public ArmourType ItemArmourType { get { return armourType; } set { armourType = value; } } public double Cost { get { return cost; } set { cost = value; } } public Race EquipmentForRace { get { return equipForRace; } } public bool CanBeUsedWithItem(EquipmentItem item) { return CanBeUsedWithArmourType(item.ItemArmourType); } public bool CanBeUsedWithArmourType(ArmourType otherItemType) { return (this.ItemArmourType & otherItemType) == 0; } } }