diff api/Commands/RemoveUnitCommand.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/RemoveUnitCommand.cs	Fri Dec 19 15:57:51 2008 +0000
@@ -0,0 +1,57 @@
+using System;
+using IBBoard.Commands;
+using IBBoard.WarFoundry.API.Objects;
+
+namespace IBBoard.WarFoundry.API.Commands
+{
+	/// <summary>
+	/// Summary description for RemoveUnitCommand.
+	/// </summary>
+	public class RemoveUnitCommand : Command
+	{
+		private Unit unit;
+		private ArmyCategory cat;
+
+		public RemoveUnitCommand(Unit toRemove)
+		{
+			unit = toRemove;
+			cat = unit.Category;
+		}
+
+		public override bool CanExecute()
+		{
+			return (unit!=null);
+		}
+
+		public override string Description
+		{
+			get { return "Remove an existing unit from the army"; }
+		}
+
+		public override string UndoDescription
+		{
+			get { return "Replace a removed unit"; }
+		}
+
+		public override bool Execute()
+		{
+			this.Redo();
+			return true;
+		}
+
+		public override void Redo()
+		{
+			cat.RemoveUnit(unit);
+		}
+
+		public override void Undo()
+		{
+			cat.AddUnit(unit);
+		}
+
+		public override string Name
+		{
+			get { return "Remove unit"; }
+		}
+	}
+}