diff api/Objects/AbstractUnitEquipmentItemSelection.cs @ 97:95746083d037

Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts * Add extra "NumericSelection" type so that ratio selections check the absolute value is within their ratio range * Update structure of checking for valid values * Move cost calculation for equipment selection in to abstract class and add abstract method to get "number of items taken" * Handle numeric selection and numeric selection for ratio differently in Unit
author IBBoard <dev@ibboard.co.uk>
date Sun, 09 Aug 2009 12:02:35 +0000
parents ced5a18d9f52
children f7b9423c2a5a
line wrap: on
line diff
--- a/api/Objects/AbstractUnitEquipmentItemSelection.cs	Sun Aug 09 11:09:12 2009 +0000
+++ b/api/Objects/AbstractUnitEquipmentItemSelection.cs	Sun Aug 09 12:02:35 2009 +0000
@@ -38,11 +38,6 @@
 			}
 		}
 		
-		public abstract double TotalCost
-		{
-			get;
-		}
-		
 		public double AmountTaken
 		{
 			get 
@@ -62,6 +57,24 @@
 			}
 		}
 		
-		protected abstract bool IsValidValue(double newValue);
+		protected bool IsValidValue(double newValue)
+		{
+			return IsInRange(newValue);
+		}
+		
+		protected abstract bool IsInRange(double newValue);
+		
+		public double TotalCost
+		{
+			get
+			{
+				return NumberTaken * EquipmentItem.Cost;
+			}
+		}
+		
+		public abstract int NumberTaken
+		{
+			 get;
+		}
 	}
 }