15
|
1 // This file (RemoveUnitCommand.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard.
|
|
2 //
|
82
|
3 // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license.
|
|
4
|
|
5 using System;
|
0
|
6 using IBBoard.Commands;
|
82
|
7 using IBBoard.WarFoundry.API.Objects;
|
|
8
|
|
9 namespace IBBoard.WarFoundry.API.Commands
|
|
10 {
|
|
11 /// <summary>
|
|
12 /// Summary description for RemoveUnitCommand.
|
|
13 /// </summary>
|
|
14 public class RemoveUnitCommand : Command
|
|
15 {
|
|
16 private Unit unit;
|
|
17 private ArmyCategory cat;
|
|
18
|
|
19 public RemoveUnitCommand(Unit toRemove)
|
|
20 {
|
|
21 unit = toRemove;
|
|
22 cat = unit.Category;
|
|
23 }
|
|
24
|
|
25 public override bool CanExecute()
|
|
26 {
|
|
27 return (unit!=null);
|
|
28 }
|
|
29
|
|
30 public override string Description
|
|
31 {
|
|
32 get { return "Remove an existing unit from the army"; }
|
|
33 }
|
|
34
|
|
35 public override string UndoDescription
|
|
36 {
|
|
37 get { return "Replace a removed unit"; }
|
|
38 }
|
|
39
|
|
40 public override bool Execute()
|
|
41 {
|
|
42 this.Redo();
|
|
43 return true;
|
|
44 }
|
|
45
|
|
46 public override void Redo()
|
|
47 {
|
|
48 cat.RemoveUnit(unit);
|
|
49 }
|
|
50
|
|
51 public override void Undo()
|
|
52 {
|
|
53 cat.AddUnit(unit);
|
|
54 }
|
|
55
|
|
56 public override string Name
|
|
57 {
|
|
58 get { return "Remove unit"; }
|
|
59 }
|
|
60 }
|
|
61 }
|