Mercurial > repos > IBBoard.WarFoundry.API
annotate api/Commands/ReplaceUnitEquipmentCommand.cs @ 54:3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
* Remove min/max from EquipmentItem and add description
* Add min/max numbers and percentages to UnitEquipmentItem
* Make Race schema define min/max number without the ratio (which is the percentage)
* Replace use of EquipmentItem with UnitEquipmentItem because of increased use of UnitEquipmentItem for unit-specific data
* Use doubles instead of floats for equipment amounts
* Distinguish between ratio and absolute limits
* Delete UnitEquipmentItemObj helper class that was purely used for UI
Re #9 - Use smaller methods
* Deprecate long Race and EquipmentItem constructors and ensure all getters/setters exist
Also:
* Migrate Unit to using genericed collections
* Always use GameSystem object for Race, not ID string
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 05 Apr 2009 13:45:23 +0000 |
parents | 306558904c2a |
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 } |