comparison api/Commands/CreateAndAddUnitCommand.cs @ 58:e53ed2d613a1

Re #61 - Complete structure of WarFoundry API objects * Migrate AddUnit/RemoveUnit methods to Army for easier army loading * Migrate requirement checking call to Army, since ArmyCategory just called parent army anyway Also: * Use genericed collections in Army * Remove failed unit requirements from ArmyCategory * Alter army.xsd to stop negatives in equipment amounts
author IBBoard <dev@ibboard.co.uk>
date Tue, 07 Apr 2009 15:28:06 +0000
parents 306558904c2a
children 3ea0ab04352b
comparison
equal deleted inserted replaced
57:e0ce5578e7c2 58:e53ed2d613a1
11 { 11 {
12 public class CreateAndAddUnitCommand : Command 12 public class CreateAndAddUnitCommand : Command
13 { 13 {
14 private UnitType addedUnitType; 14 private UnitType addedUnitType;
15 private Army army; 15 private Army army;
16 private ArmyCategory cat;
17 private Unit addedUnit; 16 private Unit addedUnit;
18 17
19 public CreateAndAddUnitCommand(UnitType toAdd, ArmyCategory catTo, Army armyTo) 18 public CreateAndAddUnitCommand(UnitType toAdd, Army armyTo)
20 { 19 {
21 addedUnitType = toAdd; 20 addedUnitType = toAdd;
22 cat = catTo;
23 army = armyTo; 21 army = armyTo;
24 } 22 }
25 23
24 [Obsolete("Use two parameter constructor instead")]
25 public CreateAndAddUnitCommand(UnitType toAdd, ArmyCategory catTo, Army armyTo) : this(toAdd, armyTo)
26 {
27 }
28
29 [Obsolete("Use two parameter constructor instead")]
26 public CreateAndAddUnitCommand(UnitType toAdd, Category catTo, Army armyTo) : this (toAdd, armyTo.GetCategory(catTo), armyTo) 30 public CreateAndAddUnitCommand(UnitType toAdd, Category catTo, Army armyTo) : this (toAdd, armyTo.GetCategory(catTo), armyTo)
27 { 31 {
28 } 32 }
29 33
30 public override bool CanExecute() 34 public override bool CanExecute()
49 return true; 53 return true;
50 } 54 }
51 55
52 public override void Redo() 56 public override void Redo()
53 { 57 {
54 cat.AddUnit(addedUnit); 58 army.AddUnit(addedUnit);
55 } 59 }
56 60
57 public override void Undo() 61 public override void Undo()
58 { 62 {
59 cat.RemoveUnit(addedUnit); 63 army.RemoveUnit(addedUnit);
60 } 64 }
61 65
62 66
63 public override string Name 67 public override string Name
64 { 68 {