comparison api/Commands/RemoveUnitCommand.cs @ 0:520818033bb6

Initial commit of WarFoundry code
author IBBoard <dev@ibboard.co.uk>
date Fri, 19 Dec 2008 15:57:51 +0000
parents
children 306558904c2a
comparison
equal deleted inserted replaced
-1:000000000000 0:520818033bb6
1 using System;
2 using IBBoard.Commands;
3 using IBBoard.WarFoundry.API.Objects;
4
5 namespace IBBoard.WarFoundry.API.Commands
6 {
7 /// <summary>
8 /// Summary description for RemoveUnitCommand.
9 /// </summary>
10 public class RemoveUnitCommand : Command
11 {
12 private Unit unit;
13 private ArmyCategory cat;
14
15 public RemoveUnitCommand(Unit toRemove)
16 {
17 unit = toRemove;
18 cat = unit.Category;
19 }
20
21 public override bool CanExecute()
22 {
23 return (unit!=null);
24 }
25
26 public override string Description
27 {
28 get { return "Remove an existing unit from the army"; }
29 }
30
31 public override string UndoDescription
32 {
33 get { return "Replace a removed unit"; }
34 }
35
36 public override bool Execute()
37 {
38 this.Redo();
39 return true;
40 }
41
42 public override void Redo()
43 {
44 cat.RemoveUnit(unit);
45 }
46
47 public override void Undo()
48 {
49 cat.AddUnit(unit);
50 }
51
52 public override string Name
53 {
54 get { return "Remove unit"; }
55 }
56 }
57 }