Mercurial > repos > IBDev-IBBoard.WarFoundry.API
diff api/Commands/SetUnitSizeCommand.cs @ 0:520818033bb6
Initial commit of WarFoundry code
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Fri, 19 Dec 2008 15:57:51 +0000 |
parents | |
children | 306558904c2a |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/api/Commands/SetUnitSizeCommand.cs Fri Dec 19 15:57:51 2008 +0000 @@ -0,0 +1,58 @@ +using System; +using IBBoard.Commands; +using IBBoard.WarFoundry.API.Objects; + +namespace IBBoard.WarFoundry.API.Commands +{ + /// <summary> + /// Summary description for SetNameCommand. + /// </summary> + public class SetUnitSizeCommand : Command + { + private Unit unit; + private int newSize, oldSize; + + public SetUnitSizeCommand(Unit toResize, int size) + { + unit = toResize; + newSize = size; + oldSize = unit.Size; + } + + public override bool CanExecute() + { + return (unit!=null && newSize >0 && oldSize > 0); + } + + public override string Description + { + get { return "Change size of "+unit.Name; } + } + + public override string UndoDescription + { + get { return "Revert size of "+unit.Name; } + } + + public override bool Execute() + { + this.Redo(); + return true; + } + + public override void Redo() + { + unit.Size = newSize; + } + + public override void Undo() + { + unit.Size = oldSize; + } + + public override string Name + { + get { return "Change unit size"; } + } + } +}