# HG changeset patch # User IBBoard # Date 1306597914 0 # Node ID 1a70ca80ef412c28bb35f0e784e875f3d1dedaa2 # Parent 4993e6f7c5092f4139d4f542cc1307f8b95fbc38 Re #27: Define unit requirements * Remove remaining references to old Requirements namespace diff -r 4993e6f7c509 -r 1a70ca80ef41 API/Factories/Xml/WarFoundryXmlFactory.cs --- a/API/Factories/Xml/WarFoundryXmlFactory.cs Sat May 28 15:40:05 2011 +0000 +++ b/API/Factories/Xml/WarFoundryXmlFactory.cs Sat May 28 15:51:54 2011 +0000 @@ -14,7 +14,6 @@ using IBBoard.Lang; using IBBoard.Logging; using IBBoard.Xml; -using IBBoard.WarFoundry.API.Requirements; using IBBoard.WarFoundry.API.Objects; using ICSharpCode.SharpZipLib.Zip; using System.Text.RegularExpressions; diff -r 4993e6f7c509 -r 1a70ca80ef41 API/Objects/Army.cs --- a/API/Objects/Army.cs Sat May 28 15:40:05 2011 +0000 +++ b/API/Objects/Army.cs Sat May 28 15:51:54 2011 +0000 @@ -27,7 +27,6 @@ public event ObjectAddDelegate UnitAdded; public event ObjectRemoveDelegate UnitRemoved; - public event FailedUnitRequirementDelegate FailedRequirement; public event DoubleValChangedDelegate PointsValueChanged; private DoubleValChangedDelegate PointsValueChangedMethod; @@ -69,7 +68,6 @@ cat.PointsValueChanged+= PointsValueChangedMethod; cat.UnitAdded+=new ObjectAddDelegate(Army_UnitAdded); cat.UnitRemoved+=new ObjectRemoveDelegate(Army_UnitRemoved); - cat.FailedRequirement+=new FailedUnitRequirementDelegate(Army_FailedRequirement); } } @@ -97,40 +95,18 @@ protected void OnUnitAdded(Unit unit) { - OnUnitAdded(unit, null); - } - - protected void OnUnitAdded(Unit unit, List failedReqs) - { if (UnitAdded != null) { UnitAdded(unit); } - - OnFailedRequirement(failedReqs); } protected void OnUnitRemoved(Unit unit) { - OnUnitRemoved(unit, null); - } - - protected void OnUnitRemoved(Unit unit, List failedReqs) - { if (UnitRemoved!=null) { UnitRemoved(unit); } - - OnFailedRequirement(failedReqs); - } - - protected void OnFailedRequirement(List failedReqs) - { - if (FailedRequirement != null && failedReqs != null && failedReqs.Count > 0) - { - FailedRequirement(failedReqs); - } } private void OnPointsValueChanged(double oldValue, double newValue) @@ -227,30 +203,6 @@ } } - [Obsolete] - public List CanAddUnit(Unit unit) - { - return CanAddUnitType(unit.UnitType); - } - - [Obsolete] - public List CanAddUnitType(UnitType unitType) - { - return unitType.CanAddToArmy(this); - } - - [Obsolete] - public List CanRemoveUnit(Unit unit) - { - return CanRemoveUnitType(unit.UnitType); - } - - [Obsolete] - public List CanRemoveUnitType(UnitType unitType) - { - return unitType.CanRemoveFromArmy(this); - } - public int GetUnitTypeCount(UnitType unitType) { int count = 0; @@ -273,11 +225,6 @@ OnUnitRemoved((Unit)val); } - private void Army_FailedRequirement(List val) - { - OnFailedRequirement(val); - } - public ICollection GetRequirements () { return Race.GetRequirements(); diff -r 4993e6f7c509 -r 1a70ca80ef41 API/Objects/ArmyCategory.cs --- a/API/Objects/ArmyCategory.cs Sat May 28 15:40:05 2011 +0000 +++ b/API/Objects/ArmyCategory.cs Sat May 28 15:51:54 2011 +0000 @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; -using IBBoard.WarFoundry.API.Requirements; namespace IBBoard.WarFoundry.API.Objects { @@ -21,7 +20,6 @@ private DoubleValChangedDelegate PointsValueChangedMethod; public event ObjectAddDelegate UnitAdded; public event ObjectRemoveDelegate UnitRemoved; - public event FailedUnitRequirementDelegate FailedRequirement; public event DoubleValChangedDelegate PointsValueChanged; public ArmyCategory(Army army, Category cat) : base() @@ -67,7 +65,8 @@ internal void AddUnit(Unit unit) { - List failedReqs = ParentArmy.CanAddUnit(unit); + //TODO: Put back a similar check + //List failedReqs = ParentArmy.CanAddUnit(unit); units.Add(unit); unit.Category = this; unit.PointsValueChanged+= PointsValueChangedMethod; @@ -75,17 +74,18 @@ unitTypes.TryGetValue(unit.UnitType.ID, out unitTypeCount); unitTypes[unit.UnitType.ID] = (int)unitTypeCount + 1; TotalPoints+= unit.Points; - OnUnitAdded(unit, failedReqs); + OnUnitAdded(unit); } internal void RemoveUnit(Unit unit) { - List failedReqs = ParentArmy.CanRemoveUnit(unit); + //TODO: Put back a similar check + //List failedReqs = ParentArmy.CanRemoveUnit(unit); units.Remove(unit); unitTypes[unit.UnitType.ID] = ((int)unitTypes[unit.UnitType.ID])-1; TotalPoints-= unit.Points; unit.PointsValueChanged-= PointsValueChangedMethod; - OnUnitRemoved(unit, failedReqs); + OnUnitRemoved(unit); } public int GetUnitTypeCount(UnitType unitType) @@ -129,38 +129,18 @@ protected void OnUnitAdded(Unit unit) { - OnUnitAdded(unit, null); - } - - protected void OnUnitAdded(Unit unit, List failedReqs) - { if (UnitAdded != null) { UnitAdded(unit); } - - if (FailedRequirement != null && failedReqs != null && failedReqs.Count > 0) - { - FailedRequirement(failedReqs); - } } protected void OnUnitRemoved(Unit unit) { - OnUnitRemoved(unit, null); - } - - protected void OnUnitRemoved(Unit unit, List failedReqs) - { if (UnitRemoved != null) { UnitRemoved(unit); } - - if (FailedRequirement != null && failedReqs != null && failedReqs.Count > 0) - { - FailedRequirement(failedReqs); - } } protected virtual void OnPointsValueChanged(double oldValue, double newValue) diff -r 4993e6f7c509 -r 1a70ca80ef41 API/Objects/UnitType.cs --- a/API/Objects/UnitType.cs Sat May 28 15:40:05 2011 +0000 +++ b/API/Objects/UnitType.cs Sat May 28 15:51:54 2011 +0000 @@ -7,7 +7,6 @@ using System.Xml; using IBBoard.Limits; using IBBoard.Logging; -using IBBoard.WarFoundry.API.Requirements; using IBBoard.WarFoundry.API.Objects.Requirement; namespace IBBoard.WarFoundry.API.Objects @@ -510,20 +509,6 @@ return reqs.ToArray(); } - - [Obsolete] - public List CanAddToArmy(Army army) - { - List failures = new List(); - return failures; - } - - [Obsolete] - public List CanRemoveFromArmy(Army army) - { - List failures = new List(); - return failures; - } public string Notes {