Mercurial > repos > snowblizz-super-API-ideas
annotate api/Objects/EquipmentItem.cs @ 38:548cfc776f54
Fixes #34 - Remove "Choices" and "Base/Increment" from Category
* Remove Choices and Base/Increment from code
Re #47: Remove magic numbers
* Replace "-1" magic number with WarFoundryCore.INFINITY
* Use INFINITY instead of -1 in code
* Use INF in schemas instead of -1
* Handle and parse INF as a special value in XML Factory
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Thu, 19 Mar 2009 20:11:07 +0000 |
parents | 306558904c2a |
children | d0812d7de39d |
rev | line source |
---|---|
15 | 1 // This file (EquipmentItem.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard. |
2 // | |
3 // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license. | |
4 | |
0 | 5 using System; |
6 using System.Xml; | |
7 | |
8 namespace IBBoard.WarFoundry.API.Objects | |
9 { | |
10 /// <summary> | |
11 /// Summary description for EquipmentItem. | |
12 /// </summary> | |
13 public class EquipmentItem : WarFoundryObject | |
14 { | |
15 private float cost, min, max; | |
16 private ArmourType armourType; | |
17 private Race equipForRace; | |
18 | |
19 public EquipmentItem(string id, string name, float itemCost, float minimum, float maximum, ArmourType itemArmourType, Race race) : base(id, name) | |
20 { | |
21 cost = itemCost; | |
22 min = minimum; | |
23 max = maximum; | |
24 armourType = itemArmourType; | |
25 equipForRace = race; | |
26 } | |
27 | |
28 public bool IsRatioLimit | |
29 { | |
30 get { return ((MaxNumber < 1 && MaxNumber > 0) || (MaxNumber == 1 && MinNumber > 0)); } | |
31 } | |
32 | |
33 public float MinNumber | |
34 { | |
35 get { return min; } | |
36 set | |
37 { | |
38
548cfc776f54
Fixes #34 - Remove "Choices" and "Base/Increment" from Category
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
38 min = (value >= 0 || value == WarFoundryCore.INFINITY) ? value : 0; |
0 | 39 |
38
548cfc776f54
Fixes #34 - Remove "Choices" and "Base/Increment" from Category
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
40 if (MaxNumber != WarFoundryCore.INFINITY && min > MaxNumber) |
0 | 41 { |
42 MaxNumber = min; | |
43 } | |
44 } | |
45 } | |
46 | |
47 public float MaxNumber | |
48 { | |
49 get { return max; } | |
50 set | |
51 { | |
38
548cfc776f54
Fixes #34 - Remove "Choices" and "Base/Increment" from Category
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
52 max = (value > 0 || value == WarFoundryCore.INFINITY) ? value : WarFoundryCore.INFINITY; |
0 | 53 |
38
548cfc776f54
Fixes #34 - Remove "Choices" and "Base/Increment" from Category
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
54 if (max != WarFoundryCore.INFINITY && MinNumber > max) |
0 | 55 { |
56 MinNumber = max; | |
57 } | |
58 } | |
59 } | |
60 | |
61 public ArmourType ItemArmourType | |
62 { | |
63 get { return armourType; } | |
64 set { armourType = value; } | |
65 } | |
66 | |
67 public float Cost | |
68 { | |
69 get { return cost; } | |
70 set { cost = value; } | |
71 } | |
72 | |
73 public Race EquipmentForRace | |
74 { | |
75 get { return equipForRace; } | |
76 } | |
77 | |
78 public bool CanBeUsedWithItem(EquipmentItem item) | |
79 { | |
80 return CanBeUsedWithArmourType(item.ItemArmourType); | |
81 } | |
82 | |
83 public bool CanBeUsedWithArmourType(ArmourType otherItemType) | |
84 { | |
85 return (this.ItemArmourType & otherItemType) == 0; | |
86 } | |
87 } | |
88 } |