Mercurial > repos > snowblizz-super-API-ideas
changeset 158:eb9a6d91a6db
Fixes #190: Mutex groups aren't honoured when adding equipment
* Make "get additional equipment" method check mutex groups
Also:
* Line ending cleanup
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 29 Sep 2009 19:50:46 +0000 |
parents | 6ff68daab5dc |
children | 7b98e71b8511 |
files | api/Factories/Xml/WarFoundryXmlRaceFactory.cs api/Objects/Unit.cs |
diffstat | 2 files changed, 36 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/api/Factories/Xml/WarFoundryXmlRaceFactory.cs Tue Sep 29 19:33:03 2009 +0000 +++ b/api/Factories/Xml/WarFoundryXmlRaceFactory.cs Tue Sep 29 19:50:46 2009 +0000 @@ -123,20 +123,20 @@ } private void LoadCoreValuesForUnitType(XmlElement elem, UnitType type) - { - try - { - type.MaxNumber = XmlTools.GetIntValueFromAttribute(elem, "maxNum"); - type.MinNumber = XmlTools.GetIntValueFromAttribute(elem, "minNum"); - type.MaxSize = XmlTools.GetIntValueFromAttribute(elem, "maxSize"); - type.MinSize = XmlTools.GetIntValueFromAttribute(elem, "minSize"); - type.BaseSize = XmlTools.GetIntValueFromAttribute(elem, "baseSize"); - type.CostPerTrooper = XmlTools.GetDoubleValueFromAttribute(elem, "points"); - type.BaseUnitCost = XmlTools.GetDoubleValueFromAttribute(elem, "unitPoints"); - } - catch (FormatException ex) - { - throw new InvalidDataException(ex.Message, ex); + { + try + { + type.MaxNumber = XmlTools.GetIntValueFromAttribute(elem, "maxNum"); + type.MinNumber = XmlTools.GetIntValueFromAttribute(elem, "minNum"); + type.MaxSize = XmlTools.GetIntValueFromAttribute(elem, "maxSize"); + type.MinSize = XmlTools.GetIntValueFromAttribute(elem, "minSize"); + type.BaseSize = XmlTools.GetIntValueFromAttribute(elem, "baseSize"); + type.CostPerTrooper = XmlTools.GetDoubleValueFromAttribute(elem, "points"); + type.BaseUnitCost = XmlTools.GetDoubleValueFromAttribute(elem, "unitPoints"); + } + catch (FormatException ex) + { + throw new InvalidDataException(ex.Message, ex); } string mainCatID = elem.GetAttribute("cat");
--- a/api/Objects/Unit.cs Tue Sep 29 19:33:03 2009 +0000 +++ b/api/Objects/Unit.cs Tue Sep 29 19:50:46 2009 +0000 @@ -220,13 +220,33 @@ } } - public UnitEquipmentItem[] GetAllowedOptionalEquipment() + public UnitEquipmentItem[] GetAllowedAdditionalEquipment() { List<UnitEquipmentItem> list = new List<UnitEquipmentItem>(); + List<string> existingMutexGroups = new List<string>(); + + foreach (UnitEquipmentItem item in GetEquipment()) + { + foreach (string mutex in item.MutexGroups) + { + existingMutexGroups.Add(mutex); + } + } foreach (UnitEquipmentItem item in UnitType.GetEquipmentItems()) { - if (!item.IsRequired) + bool mutexMatch = false; + + foreach (string mutex in item.MutexGroups) + { + if (existingMutexGroups.Contains(mutex)) + { + mutexMatch = true; + break; + } + } + + if (!mutexMatch) { list.Add(item); }