changeset 467:750eed630c41

Fixes #395: Requirements can incorrectly allow based on common divisor * Round the "limited/required" normalised count down to get correct values
author IBBoard <dev@ibboard.co.uk>
date Sat, 31 Mar 2012 20:18:42 +0100
parents bdfa314789cc
children 95c1b68a600b
files API/Objects/Requirement/RequiresNUnitsForMObjectsRequirement.cs
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/API/Objects/Requirement/RequiresNUnitsForMObjectsRequirement.cs	Sat Mar 31 15:23:49 2012 +0100
+++ b/API/Objects/Requirement/RequiresNUnitsForMObjectsRequirement.cs	Sat Mar 31 20:18:42 2012 +0100
@@ -58,7 +58,8 @@
 
 		private bool IsValidByRequirement(UnitCountRequirementData limit, int allowedTypeCount, int limitedTypeCount)
 		{
-			double normalisedLimited = limitedTypeCount / (limit.Count * 1.0);
+			//Round down limited units to get only whole amounts
+			double normalisedLimited = Math.Floor(limitedTypeCount / (limit.Count * 1.0));
 			double normalisedAllowed = allowedTypeCount / (limit.AllowsCount * 1.0);
 			return normalisedLimited >= 1 && normalisedAllowed <= normalisedLimited;
 		}