Mercurial > repos > IBBoard.WarFoundry.API
view api/Commands/SetUnitSizeCommand.cs @ 9:6ad505b6c36e
Re #10 - Refactor for readability
* Refactor out repeated number parsing in to a separate method
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 04 Jan 2009 20:06:28 +0000 |
parents | 520818033bb6 |
children | 306558904c2a |
line wrap: on
line source
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"; } } } }