Mercurial > repos > snowblizz-super-API-ideas
annotate api/Commands/RemoveUnitCommand.cs @ 388:ac088cdc54ff default-army-name
Re #315: Removed 2 debug lines introduced with ticket 153
author | snowblizz |
---|---|
date | Sun, 21 Nov 2010 21:52:21 +0000 |
parents | 391446c9b250 |
children | 650bbe79b884 |
rev | line source |
---|---|
104
2f3cafb69799
Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
1 // This file (RemoveUnitCommand.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2007, 2008, 2009 IBBoard. |
15 | 2 // |
104
2f3cafb69799
Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. |
82 | 4 |
5 using System; | |
0 | 6 using IBBoard.Commands; |
215
391446c9b250
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
7 using IBBoard.Lang; |
82 | 8 using IBBoard.WarFoundry.API.Objects; |
9 | |
10 namespace IBBoard.WarFoundry.API.Commands | |
11 { | |
12 /// <summary> | |
13 /// Summary description for RemoveUnitCommand. | |
14 /// </summary> | |
15 public class RemoveUnitCommand : Command | |
16 { | |
17 private Unit unit; | |
18 private ArmyCategory cat; | |
215
391446c9b250
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
19 private string description; |
391446c9b250
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
20 private string undoDescription; |
82 | 21 |
22 public RemoveUnitCommand(Unit toRemove) | |
23 { | |
24 unit = toRemove; | |
25 cat = unit.Category; | |
26 } | |
27 | |
28 public override bool CanExecute() | |
29 { | |
30 return (unit!=null); | |
31 } | |
32 | |
33 public override string Description | |
34 { | |
215
391446c9b250
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
35 get |
391446c9b250
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
36 { |
391446c9b250
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
37 if (description == null) |
391446c9b250
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
38 { |
391446c9b250
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
39 description = Translation.GetTranslation("removeUnitCommandDescription", "remove {0} from the army", unit.Name); |
391446c9b250
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
40 } |
391446c9b250
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
41 |
391446c9b250
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
42 return description; |
391446c9b250
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
43 } |
82 | 44 } |
45 | |
46 public override string UndoDescription | |
47 { | |
215
391446c9b250
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
48 get |
391446c9b250
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
49 { |
391446c9b250
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
50 if (undoDescription == null) |
391446c9b250
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
51 { |
391446c9b250
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
52 undoDescription = Translation.GetTranslation("removeUnitCommandUndoDescription", "re-add {0} to the army", unit.Name); |
391446c9b250
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
53 } |
391446c9b250
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
54 |
391446c9b250
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
55 return undoDescription; |
391446c9b250
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
56 } |
82 | 57 } |
58 | |
59 public override bool Execute() | |
60 { | |
61 this.Redo(); | |
62 return true; | |
63 } | |
64 | |
65 public override void Redo() | |
66 { | |
67 cat.RemoveUnit(unit); | |
68 } | |
69 | |
70 public override void Undo() | |
71 { | |
72 cat.AddUnit(unit); | |
73 } | |
74 | |
75 public override string Name | |
76 { | |
77 get { return "Remove unit"; } | |
78 } | |
79 } | |
80 } |