Mercurial > repos > IBDev-IBBoard.WarFoundry.API
comparison API/Objects/Requirement/RequiresNUnitsForMObjectsRequirement.cs @ 464:59e1fb8a476a
Re #394: Make requirements (or factory) more closely match Rollcall methods
* Fix ratio check - we were doing an unnecessary division
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 24 Mar 2012 16:40:01 +0000 |
parents | 159dc9be36c2 |
children | 7b9ff7b1df24 |
comparison
equal
deleted
inserted
replaced
463:cbeee87dc2d3 | 464:59e1fb8a476a |
---|---|
69 return IsValidByRequirement(limit, allowedTypeCount, limitedTypeCount); | 69 return IsValidByRequirement(limit, allowedTypeCount, limitedTypeCount); |
70 } | 70 } |
71 | 71 |
72 private bool IsValidByRequirement(UnitCountRequirementData limit, int allowedTypeCount, int limitedTypeCount) | 72 private bool IsValidByRequirement(UnitCountRequirementData limit, int allowedTypeCount, int limitedTypeCount) |
73 { | 73 { |
74 int wholeNumLimited = (limitedTypeCount / limit.Count); | |
75 double allowedRatio = (limit.AllowsCount / (limit.Count * 1.0)); | 74 double allowedRatio = (limit.AllowsCount / (limit.Count * 1.0)); |
76 return allowedRatio * wholeNumLimited >= allowedTypeCount; | 75 return allowedRatio * limitedTypeCount >= allowedTypeCount; |
77 } | 76 } |
78 | 77 |
79 public override Validation AllowsAdding(IWarFoundryObject wfObject, Army toArmy) | 78 public override Validation AllowsAdding(IWarFoundryObject wfObject, Army toArmy) |
80 { | 79 { |
81 Validation canAdd = Validation.NotApplicable; | 80 Validation canAdd = Validation.NotApplicable; |