comparison api/Objects/EquipmentItem.cs @ 0:520818033bb6

Initial commit of WarFoundry code
author IBBoard <dev@ibboard.co.uk>
date Fri, 19 Dec 2008 15:57:51 +0000
parents
children 306558904c2a
comparison
equal deleted inserted replaced
-1:000000000000 0:520818033bb6
1 using System;
2 using System.Xml;
3
4 namespace IBBoard.WarFoundry.API.Objects
5 {
6 /// <summary>
7 /// Summary description for EquipmentItem.
8 /// </summary>
9 public class EquipmentItem : WarFoundryObject
10 {
11 private float cost, min, max;
12 private ArmourType armourType;
13 private Race equipForRace;
14
15 public EquipmentItem(string id, string name, float itemCost, float minimum, float maximum, ArmourType itemArmourType, Race race) : base(id, name)
16 {
17 cost = itemCost;
18 min = minimum;
19 max = maximum;
20 armourType = itemArmourType;
21 equipForRace = race;
22 }
23
24 public bool IsRatioLimit
25 {
26 get { return ((MaxNumber < 1 && MaxNumber > 0) || (MaxNumber == 1 && MinNumber > 0)); }
27 }
28
29 public float MinNumber
30 {
31 get { return min; }
32 set
33 {
34 min = (value >= 0 || value == -1) ? value : 0;
35
36 if (MaxNumber != -1 && min > MaxNumber)
37 {
38 MaxNumber = min;
39 }
40 }
41 }
42
43 public float MaxNumber
44 {
45 get { return max; }
46 set
47 {
48 max = (value > 0 || value == -1) ? value : -1;
49
50 if (max != -1 && MinNumber > max)
51 {
52 MinNumber = max;
53 }
54 }
55 }
56
57 public ArmourType ItemArmourType
58 {
59 get { return armourType; }
60 set { armourType = value; }
61 }
62
63 public float Cost
64 {
65 get { return cost; }
66 set { cost = value; }
67 }
68
69 public Race EquipmentForRace
70 {
71 get { return equipForRace; }
72 }
73
74 public bool CanBeUsedWithItem(EquipmentItem item)
75 {
76 return CanBeUsedWithArmourType(item.ItemArmourType);
77 }
78
79 public bool CanBeUsedWithArmourType(ArmourType otherItemType)
80 {
81 return (this.ItemArmourType & otherItemType) == 0;
82 }
83 }
84 }