Mercurial > repos > IBBoard.WarFoundry.API
annotate api/Commands/SetUnitSizeCommand.cs @ 132:e9c415839462
Re #68: Add "export" of army
* Add total to title and points value to units
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 01 Sep 2009 17:32:27 +0000 |
parents | 2f3cafb69799 |
children | 391446c9b250 |
rev | line source |
---|---|
104
2f3cafb69799
Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
1 // This file (SetUnitSizeCommand.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; |
82 | 7 using IBBoard.WarFoundry.API.Objects; |
8 | |
9 namespace IBBoard.WarFoundry.API.Commands | |
10 { | |
11 /// <summary> | |
12 /// Summary description for SetNameCommand. | |
13 /// </summary> | |
14 public class SetUnitSizeCommand : Command | |
15 { | |
16 private Unit unit; | |
17 private int newSize, oldSize; | |
18 | |
19 public SetUnitSizeCommand(Unit toResize, int size) | |
20 { | |
21 unit = toResize; | |
22 newSize = size; | |
23 oldSize = unit.Size; | |
24 } | |
25 | |
26 public override bool CanExecute() | |
27 { | |
28 return (unit!=null && newSize >0 && oldSize > 0); | |
29 } | |
30 | |
31 public override string Description | |
32 { | |
33 get { return "Change size of "+unit.Name; } | |
34 } | |
35 | |
36 public override string UndoDescription | |
37 { | |
38 get { return "Revert size of "+unit.Name; } | |
39 } | |
40 | |
41 public override bool Execute() | |
42 { | |
43 this.Redo(); | |
44 return true; | |
45 } | |
46 | |
47 public override void Redo() | |
48 { | |
49 unit.Size = newSize; | |
50 } | |
51 | |
52 public override void Undo() | |
53 { | |
54 unit.Size = oldSize; | |
55 } | |
56 | |
57 public override string Name | |
58 { | |
59 get { return "Change unit size"; } | |
60 } | |
61 } | |
62 } |