Show
Ignore:
Timestamp:
06/27/09 14:39:04 (14 months ago)
Author:
ibboard
Message:

Re #90: Stop new units showing up twice

  • Hand all of unit adding/removing down to category
  • Refactor out OnFailedRequirement method in Army
  • Make Army listen to and propogate FailedRequirement events from Units
  • Add OnUnitAdded/Removed method to ArmyCategory that takes list of failures
  • Remove direct reference to Army from Unit and go via ArmyCategory instead
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • IBBoard.WarFoundry.API/trunk/api/Commands/CreateAndAddUnitCommand.cs

    r143 r146  
    1313    { 
    1414        private UnitType addedUnitType; 
    15         private Army army; 
     15        private ArmyCategory armyCat; 
    1616        private Unit addedUnit; 
    1717         
    18         public CreateAndAddUnitCommand(UnitType toAdd, Army armyTo) 
     18        public CreateAndAddUnitCommand(UnitType toAdd, ArmyCategory armyCatTo) 
    1919        { 
    2020            addedUnitType = toAdd; 
    21             army = armyTo; 
     21            armyCat = armyCatTo; 
    2222        } 
    2323 
    2424        [Obsolete("Use two parameter constructor instead")] 
    25         public CreateAndAddUnitCommand(UnitType toAdd, ArmyCategory catTo, Army armyTo) : this(toAdd, armyTo) 
     25        public CreateAndAddUnitCommand(UnitType toAdd, ArmyCategory catTo, Army armyTo) : this(toAdd, catTo) 
    2626        { 
    2727        } 
     
    3434        public override bool CanExecute() 
    3535        { 
    36             return (addedUnitType!=null && army!=null); 
     36            return (addedUnitType!=null && armyCat!=null); 
    3737        } 
    3838 
     
    4949        public override bool Execute() 
    5050        { 
    51             addedUnit = new Unit(addedUnitType, army); 
     51            addedUnit = new Unit(addedUnitType, armyCat); 
    5252            this.Redo(); 
    5353            return true; 
     
    5656        public override void Redo() 
    5757        { 
    58             army.AddUnit(addedUnit); 
     58            armyCat.AddUnit(addedUnit); 
    5959        } 
    6060 
    6161        public override void Undo() 
    6262        { 
    63             army.RemoveUnit(addedUnit); 
     63            armyCat.RemoveUnit(addedUnit); 
    6464        } 
    6565