Mercurial > repos > IBDev-IBBoard.WarFoundry.API
diff api/Objects/UnitEquipmentNumericSelection.cs @ 183:36adabb1c3ea
Re #198: Add slots with counts to units
* Remove old Min/MaxNumber/Percentage for equipment and replace with limits
* Refactor equipment selections and remove "numeric for ratio" as the limits handle the upper/lower limit differences
* Stop equipment selections taking an amount of 0 for out of range amounts
* Add "IsValid" property for selections
* Removed use of "-1" as an 'infinity' limit - now use 100% as a more correct value
* Change "unlimitedSize" limit in schema to "unitSizeLimit"
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 26 Oct 2009 20:55:04 +0000 |
parents | 2f3cafb69799 |
children | dce340f9cedc |
line wrap: on
line diff
--- a/api/Objects/UnitEquipmentNumericSelection.cs Sat Oct 24 18:59:04 2009 +0000 +++ b/api/Objects/UnitEquipmentNumericSelection.cs Mon Oct 26 20:55:04 2009 +0000 @@ -15,7 +15,7 @@ { } - public UnitEquipmentNumericSelection(Unit unit, UnitEquipmentItem item) : base(unit, item, item.MinNumber) + public UnitEquipmentNumericSelection(Unit unit, UnitEquipmentItem item) : base(unit, item, item.MinLimit.GetLimit(unit.Size)) { } @@ -23,7 +23,7 @@ { get { - return (AmountTaken == WarFoundryCore.INFINITY ? EquipmentForUnit.Size : (int) AmountTaken); + return (int) AmountTaken; } } @@ -32,22 +32,9 @@ return newValue == Math.Round(newValue); } - protected override bool IsInRange(double newValue) + protected override bool IsValidValue (double newValue) { - bool isInRange = IsWholeNumber(newValue); - - if (newValue == WarFoundryCore.INFINITY) - { - isInRange = (EquipmentItem.MaxNumber == WarFoundryCore.INFINITY); - } - else if (isInRange) - { - int minLimit = (EquipmentItem.MinNumber == WarFoundryCore.INFINITY ? EquipmentForUnit.Size : EquipmentItem.MinNumber); - int maxLimit = (EquipmentItem.MaxNumber == WarFoundryCore.INFINITY ? EquipmentForUnit.Size : EquipmentItem.MaxNumber); - isInRange = (minLimit <= newValue) && (newValue <= maxLimit); - } - - return isInRange; + return base.IsValidValue(newValue) && IsWholeNumber(newValue); } public override string GetEquipmentAmountString () @@ -66,18 +53,7 @@ /// </returns> public static string GetEquipmentAmountString(double amount) { - string amountString; - - if (amount == WarFoundryCore.INFINITY) - { - amountString = "all"; //TODO: Translate - } - else - { - amountString = amount.ToString(); - } - - return amountString; + return amount.ToString(); } } }