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 diff
     1.1 --- a/API/Objects/Requirement/RequiresNUnitsForMObjectsRequirement.cs	Sat Mar 31 15:23:49 2012 +0100
     1.2 +++ b/API/Objects/Requirement/RequiresNUnitsForMObjectsRequirement.cs	Sat Mar 31 20:18:42 2012 +0100
     1.3 @@ -58,7 +58,8 @@
     1.4  
     1.5  		private bool IsValidByRequirement(UnitCountRequirementData limit, int allowedTypeCount, int limitedTypeCount)
     1.6  		{
     1.7 -			double normalisedLimited = limitedTypeCount / (limit.Count * 1.0);
     1.8 +			//Round down limited units to get only whole amounts
     1.9 +			double normalisedLimited = Math.Floor(limitedTypeCount / (limit.Count * 1.0));
    1.10  			double normalisedAllowed = allowedTypeCount / (limit.AllowsCount * 1.0);
    1.11  			return normalisedLimited >= 1 && normalisedAllowed <= normalisedLimited;
    1.12  		}