Mercurial > repos > snowblizz-super-API-ideas
changeset 92:729d9e54162c
Re #111: "Replace" button doesn't always enable
* Implement better fix:
* Make UnitEquipmentItem ID based on unit type ID and equipment item ID
* Make UnitEquipmentItem require UnitType at construction again
* Remove setter from EquipmentItemForUnit
* Make AddEquipmentItem method internal so that the UnitEquipmentItem and not the factory is responsible for setting up the reverse link
no-open-ticket
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Fri, 07 Aug 2009 19:49:21 +0000 |
parents | 571d8ddc7d9a |
children | 789dfab13449 |
files | api/Factories/Xml/WarFoundryXmlRaceFactory.cs api/Objects/UnitEquipmentItem.cs api/Objects/UnitType.cs |
diffstat | 3 files changed, 24 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/api/Factories/Xml/WarFoundryXmlRaceFactory.cs Fri Aug 07 19:22:08 2009 +0000 +++ b/api/Factories/Xml/WarFoundryXmlRaceFactory.cs Fri Aug 07 19:49:21 2009 +0000 @@ -156,7 +156,7 @@ if (equipItem!=null) { - UnitEquipmentItem unitEquipItem = new UnitEquipmentItem(equipItem); + UnitEquipmentItem unitEquipItem = new UnitEquipmentItem(equipItem, type); unitEquipItem.MutexGroup = equip.GetAttribute("exclusivityGroup"); unitEquipItem.RoundNumberUp = equip.GetAttribute("roundDirection").Equals("up"); @@ -223,8 +223,6 @@ { throw new InvalidFileException("Attribute 'costRounding' of unit equipment item " + id + " for " + type.Name + " was not a valid rounding type", e); } - - type.AddEquipmentItem(unitEquipItem); } else {
--- a/api/Objects/UnitEquipmentItem.cs Fri Aug 07 19:22:08 2009 +0000 +++ b/api/Objects/UnitEquipmentItem.cs Fri Aug 07 19:49:21 2009 +0000 @@ -25,20 +25,36 @@ private string mutexGroup; private UnitType unitType; - public UnitEquipmentItem(EquipmentItem equipmentItem) + public UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipmentFor) { item = equipmentItem; + unitType = equipmentFor; + unitType.AddEquipmentItem(this); } public override string Name { - get { + get + { return item.Name; } - set { + set + { base.Name = value; } } + + public override string ID { + get + { + return (EquipmentForUnit == null ? base.ID : EquipmentForUnit.ID) + EquipmentItemID; + } + set + { + base.ID = value; + } + } + public string EquipmentItemID { @@ -92,14 +108,6 @@ public UnitType EquipmentForUnit { get { return unitType; } - set - { - if (value != null) - { - unitType = value; - unitType.AddEquipmentItem(this); - } - } } public bool IsRatioLimit @@ -221,7 +229,7 @@ { if (amount == WarFoundryCore.INFINITY) { - return "all"; + return "all"; //TODO: Translate } else {
--- a/api/Objects/UnitType.cs Fri Aug 07 19:22:08 2009 +0000 +++ b/api/Objects/UnitType.cs Fri Aug 07 19:49:21 2009 +0000 @@ -227,14 +227,14 @@ return stats.GetStatValue(statName); } - public void AddEquipmentItem(UnitEquipmentItem item) - { + internal void AddEquipmentItem(UnitEquipmentItem item) + { + Console.WriteLine("Add " + item.ID + " to " + Name); if (!equipment.ContainsKey(item.ID)) { equipment.Add(item.ID, item); equipmentKeyOrder.Add(item.ID); AddToMutexGroup(item); - item.EquipmentForUnit = this; } }