Mercurial > repos > IBDev-IBBoard.WarFoundry.API
changeset 172:f364a9e5463e
Fixes #195: Setting max equipment without min may not function correctly
* Make min = max for numeric and percentage limit when max is set and min isn't set
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 12 Oct 2009 19:43:45 +0000 |
parents | 85dc413279a4 |
children | e83fc7b493f4 |
files | api/Objects/UnitEquipmentItem.cs |
diffstat | 1 files changed, 37 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/api/Objects/UnitEquipmentItem.cs Mon Oct 12 18:41:17 2009 +0000 +++ b/api/Objects/UnitEquipmentItem.cs Mon Oct 12 19:43:45 2009 +0000 @@ -137,8 +137,16 @@ if (value >= 0 || value == WarFoundryCore.INFINITY) { minNum = value; + CheckMaxNumber(); } - //TODO: Check Min<Max + } + } + + private void CheckMaxNumber() + { + if (MaxNumber < MinNumber) + { + MaxNumber = MinNumber; } } @@ -150,8 +158,16 @@ if (value >= 0 || value == WarFoundryCore.INFINITY) { maxNum = value; - } - //TODO: Check Min<Max + CheckMinNumber(); + } + } + } + + private void CheckMinNumber() + { + if (MinNumber > MaxNumber || (MinNumber == 0 && MaxNumber != 0)) + { + MinNumber = MaxNumber; } } @@ -163,8 +179,16 @@ if (value >= 0 && value <= 100) { minPercentage = value; + CheckMaxPercentage(); } - //TODO: Check Min<Max + } + } + + private void CheckMaxPercentage() + { + if (MaxPercentage < MinPercentage) + { + MaxPercentage = MinPercentage; } } @@ -176,8 +200,16 @@ if (value >= 0 && value <= 100) { maxPercentage = value; + CheckMinPercentage(); } - //TODO: Check Min<Max + } + } + + private void CheckMinPercentage() + { + if (MinPercentage > MaxPercentage|| (MinPercentage == 0 && MaxPercentage != 0)) + { + MinPercentage = MaxPercentage; } }