Mercurial > repos > IBDev-IBBoard.WarFoundry.API
view api/Objects/EquipmentItem.cs @ 14:0770e5cbba7c
Closes #21 - File loading in order
* Reworked LoadFiles to smaller methods for readability (also re #10) and structure
* Now determine expected load return before loading then load all "expected GameSystem" before "expected Race"
* Make "can load as race/game system/army" methods public in interface
Re #22 - Get errored file loading
* Created FileLoadFailure class and made LoadFiles return a list of them
Also
* Some code cleanup
* Change to DictionaryUtils calls
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 25 Jan 2009 14:03:20 +0000 |
parents | 520818033bb6 |
children | 306558904c2a |
line wrap: on
line source
using System; using System.Xml; namespace IBBoard.WarFoundry.API.Objects { /// <summary> /// Summary description for EquipmentItem. /// </summary> public class EquipmentItem : WarFoundryObject { private float cost, min, max; private ArmourType armourType; private Race equipForRace; public EquipmentItem(string id, string name, float itemCost, float minimum, float 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 float MinNumber { get { return min; } set { min = (value >= 0 || value == -1) ? value : 0; if (MaxNumber != -1 && min > MaxNumber) { MaxNumber = min; } } } public float MaxNumber { get { return max; } set { max = (value > 0 || value == -1) ? value : -1; if (max != -1 && MinNumber > max) { MinNumber = max; } } } public ArmourType ItemArmourType { get { return armourType; } set { armourType = value; } } public float 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; } } }