# HG changeset patch # User IBBoard # Date 1251142219 0 # Node ID 52e8c3cdde1070f6ab43586ed7473543c4a651d6 # Parent 571eee2b7b300eade228094d940f9da363c50837 Re #127: Unit creation always assigns default equipment * Add and use new constructor for Unit that doesn't assign default values Re #54: Add Army support to WarFoundryFactory * Load unit name and unit size diff -r 571eee2b7b30 -r 52e8c3cdde10 api/Factories/Xml/WarFoundryXmlArmyParser.cs --- a/api/Factories/Xml/WarFoundryXmlArmyParser.cs Sun Aug 23 11:07:47 2009 +0000 +++ b/api/Factories/Xml/WarFoundryXmlArmyParser.cs Mon Aug 24 19:30:19 2009 +0000 @@ -75,8 +75,11 @@ { throw new RequiredDataMissingException(file.Name, "unitType", unitTypeId); } + + string name = unitElem.GetAttribute("unitName"); + int size = XmlTools.GetIntValueFromAttribute(unitElem, "size"); - Unit unit = new Unit(unitType, army.GetCategory(unitType.MainCategory)); + Unit unit = new Unit(id, name, size, unitType, army.GetCategory(unitType.MainCategory)); army.AddUnit(unit); units.Add(id, unit); diff -r 571eee2b7b30 -r 52e8c3cdde10 api/Objects/Unit.cs --- a/api/Objects/Unit.cs Sun Aug 23 11:07:47 2009 +0000 +++ b/api/Objects/Unit.cs Mon Aug 24 19:30:19 2009 +0000 @@ -28,12 +28,16 @@ public Unit(UnitType unitType, ArmyCategory parentArmyCat) : this(unitType, unitType.MinSize, parentArmyCat) { } - public Unit(UnitType unitType, int startSize, ArmyCategory parentArmyCat) + public Unit(UnitType unitType, int startSize, ArmyCategory parentArmyCat) : this("", "", startSize, unitType, parentArmyCat) + { + SetInitialEquipment(); + } + + public Unit(string id, string name, int startSize, UnitType unitType, ArmyCategory parentArmyCat) : base(id, name) { Category = parentArmyCat; type = unitType; Size = startSize; - SetInitialEquipment(); CalcCost(); UnitEquipmentAmountChanged+= new DoubleValChangedDelegate(UnitEquipmentAmountChangedHandler); UnitSizeChanged+= new IntValChangedDelegate(UnitSizeChangedHandler);