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 min = (value >= 0 || value == -1) ? value : 0;
|
|
39
|
|
40 if (MaxNumber != -1 && min > MaxNumber)
|
|
41 {
|
|
42 MaxNumber = min;
|
|
43 }
|
|
44 }
|
|
45 }
|
|
46
|
|
47 public float MaxNumber
|
|
48 {
|
|
49 get { return max; }
|
|
50 set
|
|
51 {
|
|
52 max = (value > 0 || value == -1) ? value : -1;
|
|
53
|
|
54 if (max != -1 && MinNumber > max)
|
|
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 }
|