Mercurial > repos > snowblizz-super-API-ideas
annotate api/Objects/EquipmentItem.cs @ 43:d0812d7de39d
Re #49 - Resolve namespace issues
* Fix up some XPath queries
* Remove one unnecessary namespace
* Check local name of elements, not name (which is qualified)
* Add method to get double value from an attribute including handling INF
* Remove min/max for equipment item as it is now moved to the UnitType's reference to the equipment item
*
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 22 Mar 2009 17:05:01 +0000 |
parents | 548cfc776f54 |
children | 3a90f70dac73 |
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 { | |
43
d0812d7de39d
Re #49 - Resolve namespace issues
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
15 private double cost, min, max; |
0 | 16 private ArmourType armourType; |
17 private Race equipForRace; | |
18 | |
43
d0812d7de39d
Re #49 - Resolve namespace issues
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
19 public EquipmentItem(string id, string name, double itemCost, double minimum, double maximum, ArmourType itemArmourType, Race race) : base(id, name) |
0 | 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 | |
43
d0812d7de39d
Re #49 - Resolve namespace issues
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
33 public double MinNumber |
0 | 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 | |
43
d0812d7de39d
Re #49 - Resolve namespace issues
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
47 public double MaxNumber |
0 | 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 | |
43
d0812d7de39d
Re #49 - Resolve namespace issues
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
67 public double Cost |
0 | 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 } |