annotate api/Objects/UnitEquipmentNumericForRatioSelection.cs @ 181:8c6f55d289b0

Fixes #200: Stats names should be case-insensitive * ToLower() all stat names/IDs so that they are case-insensitive
author IBBoard <dev@ibboard.co.uk>
date Sat, 24 Oct 2009 15:18:00 +0000
parents 85dc413279a4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
97
95746083d037 Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 // This file (UnitEquipmentNumericForRatioSelection.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard
95746083d037 Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
104
2f3cafb69799 Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents: 97
diff changeset
3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
97
95746083d037 Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4
95746083d037 Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using System;
171
85dc413279a4 * Change imports to stop references to deprecated code
IBBoard <dev@ibboard.co.uk>
parents: 139
diff changeset
6 using IBBoard.CustomMath;
97
95746083d037 Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7
95746083d037 Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 namespace IBBoard.WarFoundry.API.Objects
95746083d037 Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 {
95746083d037 Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 /// <summary>
95746083d037 Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 /// An object to hold the selection of a unit's equipment where the selection was made as an absolute number and the
95746083d037 Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 /// equipment item has a ratio limit
95746083d037 Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 /// </summary>
95746083d037 Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 public class UnitEquipmentNumericForRatioSelection : UnitEquipmentNumericSelection
95746083d037 Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 {
95746083d037 Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 public UnitEquipmentNumericForRatioSelection(Unit unit, UnitEquipmentItem item, double amount) : base(unit, item, amount)
95746083d037 Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 {
95746083d037 Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 }
95746083d037 Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19
95746083d037 Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 public UnitEquipmentNumericForRatioSelection(Unit unit, UnitEquipmentItem item) : base(unit, item, IBBMath.Round(unit.Size * item.MinPercentage, item.RoundNumberUp))
95746083d037 Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 {
95746083d037 Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 }
95746083d037 Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23
95746083d037 Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 protected override bool IsInRange (double newValue)
95746083d037 Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 {
139
70808ff799e6 * white space cleaup
IBBoard <dev@ibboard.co.uk>
parents: 136
diff changeset
26 int minLimit = (int) IBBMath.Round(EquipmentForUnit.Size * EquipmentItem.MinPercentage / 100, EquipmentItem.RoundNumberUp);
70808ff799e6 * white space cleaup
IBBoard <dev@ibboard.co.uk>
parents: 136
diff changeset
27 int maxLimit = (int) IBBMath.Round(EquipmentForUnit.Size * EquipmentItem.MaxPercentage / 100, EquipmentItem.RoundNumberUp);
136
413a7a049e41 Fixes #146: Incorrect logic in Unit.AddEquipmentAmount()
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
28 newValue = (newValue == WarFoundryCore.INFINITY ? EquipmentForUnit.Size : newValue);
97
95746083d037 Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 bool isInRange = (minLimit <= newValue) && (newValue <= maxLimit);
95746083d037 Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 return isInRange && IsWholeNumber(newValue);
95746083d037 Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 }
95746083d037 Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 }
95746083d037 Fixes #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 }