Mercurial > repos > snowblizz-super-API-ideas
view api/Commands/ReplaceUnitEquipmentCommand.cs @ 27:e7de5c96f5c2
Re #44 - Fix API tests
* Make AbstractNative factory silently dispose of IOExceptions - test data triggers one on the SharpZipLib DLL
* Remove unused MakeZipFile method
* Rename GetGameSystemLoadingFactoryForFile to remove reference to Race
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 14 Mar 2009 17:10:26 +0000 |
parents | 306558904c2a |
children | 3a90f70dac73 |
line wrap: on
line source
// This file (ReplaceUnitEquipmentCommand.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard. // // 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. using System; using IBBoard.Commands; using IBBoard.Lang; using IBBoard.WarFoundry.API.Objects; namespace IBBoard.WarFoundry.API.Commands { /// <summary> /// Summary description for ReplaceUnitEquipmentCommand. /// </summary> public class ReplaceUnitEquipmentCommand : Command { private SetUnitEquipmentAmountCommand removeOldCommand, addNewCommand; //private Unit unit; //private EquipmentItem oldEquip, newEquip; //private float newAmount, oldAmount; public ReplaceUnitEquipmentCommand(Unit unit, EquipmentItem oldItem, EquipmentItem newItem, float amount) { removeOldCommand = new SetUnitEquipmentAmountCommand(unit, oldItem, 0); addNewCommand = new SetUnitEquipmentAmountCommand(unit, newItem, amount); } public override bool CanExecute() { return removeOldCommand.CanExecute() && addNewCommand.CanExecute(); } public override string Description { get { return "Replace "+StringManipulation.CutToLength(removeOldCommand.EquipItem.Name, 20)+" with "+StringManipulation.CutToLength(addNewCommand.EquipItem.Name, 20)+ " for "+StringManipulation.CutToLength(removeOldCommand.Unit.Name, 20); } } public override string UndoDescription { get { return "Replace "+StringManipulation.CutToLength(addNewCommand.EquipItem.Name, 20)+" with "+StringManipulation.CutToLength(removeOldCommand.EquipItem.Name, 20)+ " for "+StringManipulation.CutToLength(removeOldCommand.Unit.Name, 20); } } public override bool Execute() { this.Redo(); return true; } public override void Redo() { removeOldCommand.Redo(); addNewCommand.Redo(); } public override void Undo() { addNewCommand.Undo(); removeOldCommand.Undo(); } public override string Name { get { return "Replace required equipment"; } } } }