# HG changeset patch # User IBBoard # Date 1255291054 0 # Node ID 3045a168714ac06fef31e0ae2a9f8a02fae3c5d2 # Parent ae7915c9474720d262efc329e52993612db1f629 * Line ending clean-up no-open-ticket diff -r ae7915c94747 -r 3045a168714a api/Factories/Xml/WarFoundryXmlRaceFactory.cs --- a/api/Factories/Xml/WarFoundryXmlRaceFactory.cs Tue Oct 06 18:29:07 2009 +0000 +++ b/api/Factories/Xml/WarFoundryXmlRaceFactory.cs Sun Oct 11 19:57:34 2009 +0000 @@ -111,7 +111,7 @@ { string name = elem.GetAttribute("typeName"); UnitType type = new UnitType(id, name, parentRace); - LoadCoreValuesForUnitType(elem, type); + LoadCoreValuesForUnitType(elem, type); LoadEquipmentSlotsForUnitType(elem, type); LoadEquipmentForUnitType(elem, type); LoadAbilitiesForUnitType(elem, type); @@ -151,17 +151,17 @@ type.MainCategory = cat; XmlElement statsElement = WarFoundryXmlFactoryUtils.SelectSingleElement(elem, "race:stats"); Stats unitStats = ParseUnitStats(statsElement, type.GameSystem); - type.SetUnitStats(unitStats); - } - - private void LoadEquipmentSlotsForUnitType(XmlElement elem, UnitType type) - { - foreach (XmlElement equip in WarFoundryXmlFactoryUtils.SelectNodes(elem, "race:equipmentSlots/race:equipmentSlot")) - { - string slotName = equip.GetAttribute("name"); - int slotLimit = XmlTools.GetIntValueFromAttribute(equip, "limit"); - type.AddEquipmentSlot(slotName, slotLimit); - } + type.SetUnitStats(unitStats); + } + + private void LoadEquipmentSlotsForUnitType(XmlElement elem, UnitType type) + { + foreach (XmlElement equip in WarFoundryXmlFactoryUtils.SelectNodes(elem, "race:equipmentSlots/race:equipmentSlot")) + { + string slotName = equip.GetAttribute("name"); + int slotLimit = XmlTools.GetIntValueFromAttribute(equip, "limit"); + type.AddEquipmentSlot(slotName, slotLimit); + } } private void LoadEquipmentForUnitType(XmlElement elem, UnitType type) @@ -198,20 +198,20 @@ mutexGroups = new string[0]; } - UnitEquipmentItem unitEquipItem = new UnitEquipmentItem(equipItem, type, mutexGroups); - - string equipSlot = equip.GetAttribute("equipmentSlot"); - - if (equipSlot != "") - { - if (type.HasEquipmentSlot(equipSlot)) - { - unitEquipItem.SlotName = equipSlot; - } - else - { - throw new InvalidFileException("Attribute 'equipmentSlot' of unit equipment item " + id + " for " + type.Name + " was not a valid slot name"); - } + UnitEquipmentItem unitEquipItem = new UnitEquipmentItem(equipItem, type, mutexGroups); + + string equipSlot = equip.GetAttribute("equipmentSlot"); + + if (equipSlot != "") + { + if (type.HasEquipmentSlot(equipSlot)) + { + unitEquipItem.SlotName = equipSlot; + } + else + { + throw new InvalidFileException("Attribute 'equipmentSlot' of unit equipment item " + id + " for " + type.Name + " was not a valid slot name"); + } } unitEquipItem.RoundNumberUp = equip.GetAttribute("roundDirection").Equals("up"); diff -r ae7915c94747 -r 3045a168714a api/Objects/UnitEquipmentItem.cs --- a/api/Objects/UnitEquipmentItem.cs Tue Oct 06 18:29:07 2009 +0000 +++ b/api/Objects/UnitEquipmentItem.cs Sun Oct 11 19:57:34 2009 +0000 @@ -10,245 +10,245 @@ { /// /// Summary description for UnitEquipmentItem. - /// - public class UnitEquipmentItem : WarFoundryObject - { - private EquipmentItem item; - private bool required; - private bool roundUp; - private int minNum; - private int maxNum; - private double minPercentage; - private double maxPercentage; - private double costMultiplier; - private RoundType roundType; - private string[] mutexGroups; - private UnitType unitType; - private string slotName = ""; - - public UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipmentFor) - : this(equipmentItem, equipmentFor, new string[0]) - { - //Do nothing extra - } - - public UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipmentFor, params string[] mutexGroups) - { - item = equipmentItem; - unitType = equipmentFor; - this.mutexGroups = mutexGroups; - unitType.AddEquipmentItem(this); - } - - public override string Name - { - get - { - return item.Name; - } - set - { - base.Name = value; - } - } - - public override string ID - { - get - { - return (EquipmentForUnit == null ? base.ID : EquipmentForUnit.ID) + EquipmentItemID; - } - set - { - base.ID = value; - } - } - - - public string EquipmentItemID - { - get { return item.ID; } - } - - public double 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 - { - get { return required; } - set { required = value; } - } - - public bool RoundNumberUp - { - get { return roundUp; } - set { roundUp = value; } - } - - [Obsolete("Use MutexGroups instead for greater flexibility")] - public string MutexGroup - { - get { return (mutexGroups.Length == 0 ? "" : mutexGroups[0]); } - } - - public String[] MutexGroups - { - get { return (string[]) mutexGroups.Clone(); } - } - - public UnitType EquipmentForUnit - { - get { return unitType; } - } - - public bool IsRatioLimit - { - get { return minPercentage != 100 || maxPercentage != 100; } - } - - public int MinNumber - { - get { return minNum; } - set - { - if (value >= 0 || value == WarFoundryCore.INFINITY) - { - minNum = value; - } - //TODO: Check Min= 0 || value == WarFoundryCore.INFINITY) - { - maxNum = value; - } - //TODO: Check Min= 0 && value <= 100) - { - minPercentage = value; - } - //TODO: Check Min= 0 && value <= 100) - { - maxPercentage = value; - } - //TODO: Check Min 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); - } - - [Obsolete("Use UnitEquipmentUtil method instead")] - public bool IsMutuallyExclusive(UnitEquipmentItem item) - { - return UnitEquipmentUtil.ItemsAreMutuallyExclusive(this, item); - } - - public string SlotName - { - get { return slotName; } - set - { - if (value != null && value != "") - { - slotName = value; - } - } - } + /// + public class UnitEquipmentItem : WarFoundryObject + { + private EquipmentItem item; + private bool required; + private bool roundUp; + private int minNum; + private int maxNum; + private double minPercentage; + private double maxPercentage; + private double costMultiplier; + private RoundType roundType; + private string[] mutexGroups; + private UnitType unitType; + private string slotName = ""; + + public UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipmentFor) + : this(equipmentItem, equipmentFor, new string[0]) + { + //Do nothing extra + } + + public UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipmentFor, params string[] mutexGroups) + { + item = equipmentItem; + unitType = equipmentFor; + this.mutexGroups = mutexGroups; + unitType.AddEquipmentItem(this); + } + + public override string Name + { + get + { + return item.Name; + } + set + { + base.Name = value; + } + } + + public override string ID + { + get + { + return (EquipmentForUnit == null ? base.ID : EquipmentForUnit.ID) + EquipmentItemID; + } + set + { + base.ID = value; + } + } + + + public string EquipmentItemID + { + get { return item.ID; } + } + + public double 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 + { + get { return required; } + set { required = value; } + } + + public bool RoundNumberUp + { + get { return roundUp; } + set { roundUp = value; } + } + + [Obsolete("Use MutexGroups instead for greater flexibility")] + public string MutexGroup + { + get { return (mutexGroups.Length == 0 ? "" : mutexGroups[0]); } + } + + public String[] MutexGroups + { + get { return (string[]) mutexGroups.Clone(); } + } + + public UnitType EquipmentForUnit + { + get { return unitType; } + } + + public bool IsRatioLimit + { + get { return minPercentage != 100 || maxPercentage != 100; } + } + + public int MinNumber + { + get { return minNum; } + set + { + if (value >= 0 || value == WarFoundryCore.INFINITY) + { + minNum = value; + } + //TODO: Check Min= 0 || value == WarFoundryCore.INFINITY) + { + maxNum = value; + } + //TODO: Check Min= 0 && value <= 100) + { + minPercentage = value; + } + //TODO: Check Min= 0 && value <= 100) + { + maxPercentage = value; + } + //TODO: Check Min 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); + } + + [Obsolete("Use UnitEquipmentUtil method instead")] + public bool IsMutuallyExclusive(UnitEquipmentItem item) + { + return UnitEquipmentUtil.ItemsAreMutuallyExclusive(this, item); + } + + public string SlotName + { + get { return slotName; } + set + { + if (value != null && value != "") + { + slotName = value; + } + } + } } } diff -r ae7915c94747 -r 3045a168714a api/Objects/UnitType.cs --- a/api/Objects/UnitType.cs Tue Oct 06 18:29:07 2009 +0000 +++ b/api/Objects/UnitType.cs Sun Oct 11 19:57:34 2009 +0000 @@ -29,8 +29,8 @@ private Dictionary requiredAbilities = new Dictionary(); private Dictionary optionalAbilities = new Dictionary(); private String notes = ""; - private List containedTypes = new List(); - private Dictionary extraData = new Dictionary(); + private List containedTypes = new List(); + private Dictionary extraData = new Dictionary(); private Dictionary slotLimits = new Dictionary(); @@ -447,34 +447,34 @@ get { return stats.StatsID; - } - } - - public void AddEquipmentSlot(string slotName, int slotLimit) - { - slotLimits.Add(slotName, slotLimit); - } - - public bool HasEquipmentSlot(string slotName) - { - return slotLimits.ContainsKey(slotName); - } - - /// - /// Gets the maximum number of items allowed in a single slot - /// - /// The name of the equipment slot to get the limit for the named slot - /// The maximum number of items allowed in a slot, or -1 if the slot is the default one or has not been specified - public int GetEquipmentSlotLimit(string slotName) - { - int slotLimit = -1; - - if (HasEquipmentSlot(slotName)) - { - slotLimit = DictionaryUtils.GetValue(slotLimits, slotName); - } - - return slotLimit; + } + } + + public void AddEquipmentSlot(string slotName, int slotLimit) + { + slotLimits.Add(slotName, slotLimit); + } + + public bool HasEquipmentSlot(string slotName) + { + return slotLimits.ContainsKey(slotName); + } + + /// + /// Gets the maximum number of items allowed in a single slot + /// + /// The name of the equipment slot to get the limit for the named slot + /// The maximum number of items allowed in a slot, or -1 if the slot is the default one or has not been specified + public int GetEquipmentSlotLimit(string slotName) + { + int slotLimit = -1; + + if (HasEquipmentSlot(slotName)) + { + slotLimit = DictionaryUtils.GetValue(slotLimits, slotName); + } + + return slotLimit; } } } \ No newline at end of file