changeset 101:f7b9423c2a5a

Big mess of updates, breaking our rules on "commit little and often" because the code was so ugly. This revision will be broken for the WinForms UI, but as MonoDevelop/eSVN don't have a way of committing multiple projects in one go it can't be helped (Eclipse's Team Sync view could handle it) Fixes #122: Make usage of percentage or ratio common * All usage of ratio amounts for equipment items should now assume percentage * Properly calculate number taken for ratio selection (divide by 0 now we're using percentages) Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts * Added extra commands that differentiate between ratio and absolute amounts Fixes #120: Numeric limit equipment items show large percentages * Now made formatting treat ratios as percentages (don't multiply by 100) * Move string formatting to UnitEquipmentItem...Selection classes * Add method to Unit to say whether an equipment item is a numeric or ratio amount
author IBBoard <dev@ibboard.co.uk>
date Thu, 13 Aug 2009 21:09:20 +0000
parents 38e788859199
children c85ea8988455
files IBBoard.WarFoundry.API.csproj api/Commands/AbstractReplaceUnitEquipmentCommand.cs api/Commands/AbstractSetUnitEquipmentAmountCommand.cs api/Commands/ReplaceUnitEquipmentCommand.cs api/Commands/ReplaceUnitEquipmentWithNumericAmountItemCommand.cs api/Commands/ReplaceUnitEquipmentWithRatioAmountItemCommand.cs api/Commands/SetUnitEquipmentAmountCommand.cs api/Commands/SetUnitEquipmentNumericAmountCommand.cs api/Commands/SetUnitEquipmentRatioAmountCommand.cs api/Objects/AbstractUnitEquipmentItemSelection.cs api/Objects/Unit.cs api/Objects/UnitEquipmentItem.cs api/Objects/UnitEquipmentNumericSelection.cs api/Objects/UnitEquipmentRatioSelection.cs
diffstat 14 files changed, 369 insertions(+), 175 deletions(-) [+]
line wrap: on
line diff
--- a/IBBoard.WarFoundry.API.csproj	Thu Aug 13 19:07:04 2009 +0000
+++ b/IBBoard.WarFoundry.API.csproj	Thu Aug 13 21:09:20 2009 +0000
@@ -58,9 +58,9 @@
   <ItemGroup>
     <Compile Include="api\Commands\CreateAndAddUnitCommand.cs" />
     <Compile Include="api\Commands\RemoveUnitCommand.cs" />
-    <Compile Include="api\Commands\ReplaceUnitEquipmentCommand.cs" />
+    <Compile Include="api\Commands\AbstractReplaceUnitEquipmentCommand.cs" />
     <Compile Include="api\Commands\SetNameCommand.cs" />
-    <Compile Include="api\Commands\SetUnitEquipmentAmountCommand.cs" />
+    <Compile Include="api\Commands\SetUnitEquipmentNumericAmountCommand.cs" />
     <Compile Include="api\Commands\SetUnitSizeCommand.cs" />
     <Compile Include="api\Delegates.cs" />
     <Compile Include="api\Factories\AbstractNativeWarFoundryFactory.cs" />
@@ -130,6 +130,10 @@
     <Compile Include="api\Objects\UnitEquipmentNumericForRatioSelection.cs" />
     <Compile Include="api\Objects\UnitEquipmentNumericSelection.cs" />
     <Compile Include="api\Objects\UnitEquipmentRatioSelection.cs" />
+    <Compile Include="api\Commands\SetUnitEquipmentRatioAmountCommand.cs" />
+    <Compile Include="api\Commands\AbstractSetUnitEquipmentAmountCommand.cs" />
+    <Compile Include="api\Commands\ReplaceUnitEquipmentWithNumericAmountItemCommand.cs" />
+    <Compile Include="api\Commands\ReplaceUnitEquipmentWithRatioAmountItemCommand.cs" />
   </ItemGroup>
   <ItemGroup>
     <Content Include="libs\ICSharpCode.SharpZipLib.dll" />
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/api/Commands/AbstractReplaceUnitEquipmentCommand.cs	Thu Aug 13 21:09:20 2009 +0000
@@ -0,0 +1,66 @@
+// This file (AbstractReplaceUnitEquipmentCommand.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>
+	/// An abstract implementation of the core method for replacing one equipment item with another
+	/// </summary>
+	public abstract class AbstractReplaceUnitEquipmentCommand : Command
+	{
+		private SetUnitEquipmentNumericAmountCommand removeOldCommand;
+		private AbstractSetUnitEquipmentAmountCommand addNewCommand;
+		
+		public AbstractReplaceUnitEquipmentCommand(Unit unit, UnitEquipmentItem oldItem, AbstractSetUnitEquipmentAmountCommand addNewEquipmentCommand)
+		{
+			//We can get away with a numeric amount here even if it is a ratio item because we're setting it to 0
+			removeOldCommand = new SetUnitEquipmentNumericAmountCommand(unit, oldItem, 0);
+			addNewCommand = addNewEquipmentCommand;
+		}
+
+		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"; }
+		}
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/api/Commands/AbstractSetUnitEquipmentAmountCommand.cs	Thu Aug 13 21:09:20 2009 +0000
@@ -0,0 +1,110 @@
+//  This file (AbstractSetUnitEquipmentAmountCommand.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>
+	/// Abstract parent class for commands that set the amount of an equipment item a unit has to a fixed numeric or ratio value
+	/// </summary>
+	public abstract class AbstractSetUnitEquipmentAmountCommand : Command
+	{
+		private Unit unit;
+		private UnitEquipmentItem equip;
+		private double oldAmount;
+		private bool oldAmountWasRatio;
+		
+		public AbstractSetUnitEquipmentAmountCommand(Unit unit, UnitEquipmentItem item)
+		{
+			this.unit = unit;
+			equip = item;
+			oldAmount = unit.GetEquipmentAmount(equip);
+			oldAmountWasRatio = unit.GetEquipmentAmountIsRatio(equip);
+		}
+
+		public override bool CanExecute()
+		{
+			return (unit!=null && equip!=null);
+		}
+
+		public override string Description
+		{
+			get
+			{
+				return "Set " + StringManipulation.CutToLength(equip.Name, 20) + " ratio for " + StringManipulation.CutToLength(unit.Name, 20) + " to " + GetNewAmountString();
+			}
+		}
+
+		/// <summary>
+		/// Gets the string representation for the new amount of the equipment item to take
+		/// </summary>
+		/// <returns>
+		/// the string representation for the new amount of the equipment item to take
+		/// </returns>
+		protected abstract string GetNewAmountString();
+
+		public override string UndoDescription
+		{
+			get {
+				return "Set " + StringManipulation.CutToLength(equip.Name, 20) + " ratio for " + StringManipulation.CutToLength(unit.Name, 20) + " to " + GetOldAmountString();
+			}
+		}
+
+		/// <summary>
+		/// Gets the string representation for the old amount of the equipment item to take
+		/// </summary>
+		/// <returns>
+		/// the string representation for the old amount of the equipment item to take
+		/// </returns>
+		protected string GetOldAmountString()
+		{
+			string oldAmountString;
+			if (oldAmountWasRatio)
+			{
+				oldAmountString = UnitEquipmentRatioSelection.GetEquipmentAmountString(oldAmount);
+			}
+			else
+			{
+				oldAmountString = UnitEquipmentNumericSelection.GetEquipmentAmountString(oldAmount);
+			}
+
+			return oldAmountString;
+		}
+
+
+		public override bool Execute()
+		{
+			this.Redo();
+			return true;
+		}
+
+		public override void Undo ()
+		{
+			if (oldAmountWasRatio)
+			{
+				unit.SetEquipmentRatio(equip, oldAmount);
+			}
+			else
+			{
+				unit.SetEquipmentAmount(equip, (int)oldAmount);
+			}
+		}
+
+
+		public UnitEquipmentItem EquipItem
+		{
+			get { return equip; }
+		}
+
+		public Unit Unit
+		{
+			get { return unit; }
+		}
+	}
+}
--- a/api/Commands/ReplaceUnitEquipmentCommand.cs	Thu Aug 13 19:07:04 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-// 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;
-		
-		public ReplaceUnitEquipmentCommand(Unit unit, UnitEquipmentItem oldItem, UnitEquipmentItem newItem, double 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"; }
-		}
-	}
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/api/Commands/ReplaceUnitEquipmentWithNumericAmountItemCommand.cs	Thu Aug 13 21:09:20 2009 +0000
@@ -0,0 +1,21 @@
+//  This file (ReplaceUnitEquipmentWithNumericAmountItemCommand.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.WarFoundry.API.Objects;
+
+namespace IBBoard.WarFoundry.API.Commands
+{
+	/// <summary>
+	/// A concrete implementation of an equipment replacing command that replaces a given equipment item with a different item that has an absolute numeric amount.
+	/// </summary>
+	public class ReplaceUnitEquipmentWithNumericAmountItemCommand : AbstractReplaceUnitEquipmentCommand
+	{	
+		public ReplaceUnitEquipmentWithNumericAmountItemCommand(Unit unit, UnitEquipmentItem oldItem, UnitEquipmentItem newItem, int newItemAmount) : base(unit, oldItem, new SetUnitEquipmentNumericAmountCommand(unit, newItem, newItemAmount))
+		{
+			//Do nothing special
+		}
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/api/Commands/ReplaceUnitEquipmentWithRatioAmountItemCommand.cs	Thu Aug 13 21:09:20 2009 +0000
@@ -0,0 +1,21 @@
+//  This file (ReplaceUnitEquipmentWithRatioAmountItemCommand.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.WarFoundry.API.Objects;
+
+namespace IBBoard.WarFoundry.API.Commands
+{
+	/// <summary>
+	/// A concrete implementation of an equipment replacing command that replaces a given equipment item with a different item that has a ratio/percentage amount.
+	/// </summary>
+	public class ReplaceUnitEquipmentWithRatioAmountItemCommand : AbstractReplaceUnitEquipmentCommand
+	{	
+		public ReplaceUnitEquipmentWithRatioAmountItemCommand(Unit unit, UnitEquipmentItem oldItem, UnitEquipmentItem newItem, double newItemRatio) : base(unit, oldItem, new SetUnitEquipmentRatioAmountCommand(unit, newItem, newItemRatio))
+		{
+			//Do nothing special
+		}
+	}
+}
--- a/api/Commands/SetUnitEquipmentAmountCommand.cs	Thu Aug 13 19:07:04 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
-// This file (SetUnitEquipmentAmountCommand.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 SetUnitEquipmentAmountCommand.
-	/// </summary>
-	public class SetUnitEquipmentAmountCommand : Command
-	{
-		private Unit unit;
-		private UnitEquipmentItem equip;
-		private double newAmount;
-		private double oldAmount;
-		
-		public SetUnitEquipmentAmountCommand(Unit unit, UnitEquipmentItem item, double amount)
-		{
-			this.unit = unit;
-			equip = item;
-			newAmount = amount;
-			oldAmount = unit.GetEquipmentAmount(equip.ID);
-		}
-
-		public override bool CanExecute()
-		{
-			return (unit!=null && equip!=null);
-		}
-
-		public override string Description
-		{
-			get { return "Set "+StringManipulation.CutToLength(equip.Name, 20)+" amount for "+StringManipulation.CutToLength(unit.Name, 20)+" to "+UnitEquipmentItem.FormatEquipmentAmount(equip, newAmount); }
-		}
-
-		public override string UndoDescription
-		{
-			get { return "Set "+StringManipulation.CutToLength(equip.Name, 20)+" amount for "+StringManipulation.CutToLength(unit.Name, 20)+" to "+UnitEquipmentItem.FormatEquipmentAmount(equip, oldAmount); }
-		}
-
-		public override bool Execute()
-		{
-			this.Redo();
-			return true;
-		}
-
-		public override void Redo()
-		{
-			if (equip.IsRatioLimit)
-			{
-				unit.SetEquipmentRatio(equip, newAmount);
-			}
-			else
-			{
-				unit.SetEquipmentAmount(equip, (int)newAmount);
-			}
-		}
-
-		public override void Undo()
-		{
-			if (equip.IsRatioLimit)
-			{
-				unit.SetEquipmentRatio(equip, oldAmount);
-			}
-			else
-			{
-				unit.SetEquipmentAmount(equip, (int)oldAmount);
-			}
-		}
-
-		public override string Name
-		{
-			get { return "Set equipment amount"; }
-		}
-
-		public UnitEquipmentItem EquipItem
-		{
-			get { return equip; }
-		}
-
-		public Unit Unit
-		{
-			get { return unit; }
-		}
-	}
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/api/Commands/SetUnitEquipmentNumericAmountCommand.cs	Thu Aug 13 21:09:20 2009 +0000
@@ -0,0 +1,39 @@
+// This file (SetUnitEquipmentNumericAmountCommand.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 SetUnitEquipmentNumericAmountCommand.
+	/// </summary>
+	public class SetUnitEquipmentNumericAmountCommand : AbstractSetUnitEquipmentAmountCommand
+	{
+		private int newAmount;
+		
+		public SetUnitEquipmentNumericAmountCommand(Unit unit, UnitEquipmentItem item, int amount) : base(unit, item)
+		{
+			newAmount = amount;
+		}
+
+		protected override string GetNewAmountString ()
+		{
+			return UnitEquipmentNumericSelection.GetEquipmentAmountString(newAmount);
+		}
+		
+		public override void Redo()
+		{
+			Unit.SetEquipmentAmount(EquipItem, newAmount);
+		}
+
+		public override string Name
+		{
+			get { return "Set equipment amount"; }
+		}
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/api/Commands/SetUnitEquipmentRatioAmountCommand.cs	Thu Aug 13 21:09:20 2009 +0000
@@ -0,0 +1,39 @@
+// This file (SetUnitEquipmentRatioAmountCommand.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 SetUnitEquipmentRatioAmountCommand.
+	/// </summary>
+	public class SetUnitEquipmentRatioAmountCommand : AbstractSetUnitEquipmentAmountCommand
+	{
+		private double newAmount;
+		
+		public SetUnitEquipmentRatioAmountCommand(Unit unit, UnitEquipmentItem item, double amount) : base(unit, item)
+		{
+			newAmount = amount;
+		}
+
+		protected override string GetNewAmountString ()
+		{
+			return UnitEquipmentRatioSelection.GetEquipmentAmountString(newAmount);
+		}
+
+		public override void Redo()
+		{
+			Unit.SetEquipmentRatio(EquipItem, newAmount);
+		}
+
+		public override string Name
+		{
+			get { return "Set equipment ratio"; }
+		}
+	}
+}
--- a/api/Objects/AbstractUnitEquipmentItemSelection.cs	Thu Aug 13 19:07:04 2009 +0000
+++ b/api/Objects/AbstractUnitEquipmentItemSelection.cs	Thu Aug 13 21:09:20 2009 +0000
@@ -76,5 +76,7 @@
 		{
 			 get;
 		}
+
+		public abstract string GetEquipmentAmountString();
 	}
 }
--- a/api/Objects/Unit.cs	Thu Aug 13 19:07:04 2009 +0000
+++ b/api/Objects/Unit.cs	Thu Aug 13 21:09:20 2009 +0000
@@ -268,6 +268,16 @@
 		{
 			return GetEquipmentAmount(UnitType.GetEquipmentItem(equipID));
 		}
+
+		public bool GetEquipmentAmountIsRatio(UnitEquipmentItem item)
+		{
+			return (DictionaryUtils.GetValue(equipment, item) is UnitEquipmentRatioSelection);
+		}
+
+		public bool GetEquipmentAmountIsRatio(string itemID)
+		{
+			return GetEquipmentAmountIsRatio(UnitType.GetEquipmentItem(itemID));
+		}
 		
 		public void SetEquipmentAmount(UnitEquipmentItem equip, int amount)
 		{
@@ -330,9 +340,9 @@
 				throw new InvalidOperationException("Equipment with ID "+equip.ID+" for unit of type "+UnitType.ID+" has an absolute limit, not a ratio limit");
 			}
 			
-			if (ratio > 1)
+			if (ratio > 100)
 			{
-				ratio = 1;
+				ratio = 100;
 			}
 			else if (ratio < 0)
 			{
--- a/api/Objects/UnitEquipmentItem.cs	Thu Aug 13 19:07:04 2009 +0000
+++ b/api/Objects/UnitEquipmentItem.cs	Thu Aug 13 21:09:20 2009 +0000
@@ -218,21 +218,5 @@
 		{
 			return EquipmentItem.CanBeUsedWithArmourType(otherItemType);
 		}
-		
-		public static string FormatEquipmentAmount(UnitEquipmentItem item, double amount)
-		{
-			if (amount == WarFoundryCore.INFINITY)
-			{
-				return "all"; //TODO: Translate
-			}
-			else if (item.IsRatioLimit)
-			{
-				return Math.Round(amount * 100) + "%";
-			}
-			else
-			{
-				return amount.ToString();
-			}
-		}
 	}
 }
--- a/api/Objects/UnitEquipmentNumericSelection.cs	Thu Aug 13 19:07:04 2009 +0000
+++ b/api/Objects/UnitEquipmentNumericSelection.cs	Thu Aug 13 21:09:20 2009 +0000
@@ -49,5 +49,35 @@
 			
 			return isInRange;
 		}
+
+		public override string GetEquipmentAmountString ()
+		{
+			return GetEquipmentAmountString(AmountTaken);
+		}
+
+		/// <summary>
+		/// Gets a string representing the amount of equipment taken when the amount is a numeric selection
+		/// </summary>
+		/// <param name="amount">
+		/// A <see cref="System.Double"/>
+		/// </param>
+		/// <returns>
+		/// A <see cref="System.String"/>
+		/// </returns>
+		public static string GetEquipmentAmountString(double amount)
+		{
+			string amountString;
+			
+			if (amount == WarFoundryCore.INFINITY)
+			{
+				amountString = "all"; //TODO: Translate
+			}
+			else
+			{
+				amountString = amount.ToString();
+			}
+
+			return amountString;
+		}
 	}
 }
--- a/api/Objects/UnitEquipmentRatioSelection.cs	Thu Aug 13 19:07:04 2009 +0000
+++ b/api/Objects/UnitEquipmentRatioSelection.cs	Thu Aug 13 21:09:20 2009 +0000
@@ -24,7 +24,7 @@
 		{
 			get
 			{
-				double numberTaken = AmountTaken * EquipmentForUnit.Size;
+				double numberTaken = (AmountTaken / 100) * EquipmentForUnit.Size;
 				return (int) (EquipmentItem.RoundNumberUp ? Math.Ceiling(numberTaken) : Math.Floor(numberTaken));
 			}
 		}
@@ -33,5 +33,27 @@
 		{
 			return (EquipmentItem.MinPercentage <= newValue) && (newValue <= EquipmentItem.MaxPercentage);
 		}
+
+		public override string GetEquipmentAmountString ()
+		{
+			return GetEquipmentAmountString(AmountTaken);
+		}
+
+		public static string GetEquipmentAmountString(double amount)
+		{
+			string amountString;
+			
+			if (amount == 100)
+			{
+				amountString = "all"; //TODO: Translate
+			}
+			else
+			{
+				amountString = amount  + "%";
+			}
+
+			return amountString;
+		}
+
 	}
 }