Mercurial > repos > IBBoard.WarFoundry.API
annotate api/Commands/ReplaceUnitEquipmentCommand.cs @ 71:0303ac938fc5
Re #50 - Complete core loading of WarFoundry XML files
* Fix XPath query to get a specific unit from a document
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 25 Apr 2009 19:38:55 +0000 |
parents | 3a90f70dac73 |
children | 3ea0ab04352b |
rev | line source |
---|---|
15 | 1 // This file (ReplaceUnitEquipmentCommand.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard. |
2 // | |
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 | |
0 | 5 using System; |
6 using IBBoard.Commands; | |
7 using IBBoard.Lang; | |
8 using IBBoard.WarFoundry.API.Objects; | |
9 | |
10 namespace IBBoard.WarFoundry.API.Commands | |
11 { | |
12 /// <summary> | |
13 /// Summary description for ReplaceUnitEquipmentCommand. | |
14 /// </summary> | |
15 public class ReplaceUnitEquipmentCommand : Command | |
16 { | |
17 private SetUnitEquipmentAmountCommand removeOldCommand, addNewCommand; | |
18 | |
54
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
19 public ReplaceUnitEquipmentCommand(Unit unit, UnitEquipmentItem oldItem, UnitEquipmentItem newItem, double amount) |
0 | 20 { |
21 removeOldCommand = new SetUnitEquipmentAmountCommand(unit, oldItem, 0); | |
22 addNewCommand = new SetUnitEquipmentAmountCommand(unit, newItem, amount); | |
23 } | |
24 | |
25 public override bool CanExecute() | |
26 { | |
27 return removeOldCommand.CanExecute() && addNewCommand.CanExecute(); | |
28 } | |
29 | |
30 public override string Description | |
31 { | |
32 get { return "Replace "+StringManipulation.CutToLength(removeOldCommand.EquipItem.Name, 20)+" with "+StringManipulation.CutToLength(addNewCommand.EquipItem.Name, 20)+ " for "+StringManipulation.CutToLength(removeOldCommand.Unit.Name, 20); } | |
33 } | |
34 | |
35 public override string UndoDescription | |
36 { | |
37 get { return "Replace "+StringManipulation.CutToLength(addNewCommand.EquipItem.Name, 20)+" with "+StringManipulation.CutToLength(removeOldCommand.EquipItem.Name, 20)+ " for "+StringManipulation.CutToLength(removeOldCommand.Unit.Name, 20); } | |
38 } | |
39 | |
40 public override bool Execute() | |
41 { | |
42 this.Redo(); | |
43 return true; | |
44 } | |
45 | |
46 public override void Redo() | |
47 { | |
48 removeOldCommand.Redo(); | |
49 addNewCommand.Redo(); | |
50 } | |
51 | |
52 public override void Undo() | |
53 { | |
54 addNewCommand.Undo(); | |
55 removeOldCommand.Undo(); | |
56 } | |
57 | |
58 | |
59 public override string Name | |
60 { | |
61 get { return "Replace required equipment"; } | |
62 } | |
63 } | |
64 } |