Mercurial > repos > IBBoard.WarFoundry.API
annotate api/Objects/EquipmentItem.cs @ 54:3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
* Remove min/max from EquipmentItem and add description
* Add min/max numbers and percentages to UnitEquipmentItem
* Make Race schema define min/max number without the ratio (which is the percentage)
* Replace use of EquipmentItem with UnitEquipmentItem because of increased use of UnitEquipmentItem for unit-specific data
* Use doubles instead of floats for equipment amounts
* Distinguish between ratio and absolute limits
* Delete UnitEquipmentItemObj helper class that was purely used for UI
Re #9 - Use smaller methods
* Deprecate long Race and EquipmentItem constructors and ensure all getters/setters exist
Also:
* Migrate Unit to using genericed collections
* Always use GameSystem object for Race, not ID string
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 05 Apr 2009 13:45:23 +0000 |
parents | d0812d7de39d |
children | 3ea0ab04352b |
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 { | |
54
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
15 private double cost; |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
16 private string description; |
0 | 17 private ArmourType armourType; |
54
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
18 private Race equipForRace; |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
19 |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
20 public EquipmentItem(string id, string name, Race race) : base(id, name) |
0 | 21 { |
22 equipForRace = race; | |
54
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
23 description = ""; |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
24 armourType = ArmourType.None; |
0 | 25 } |
54
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
26 |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
27 [Obsolete("Use the three argument constructor and the appropriate 'set' methods")] |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
28 public EquipmentItem(string id, string name, double itemCost, double minimum, double maximum, ArmourType itemArmourType, Race race) : this(id, name, race) |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
29 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
30 ItemArmourType = itemArmourType; |
0 | 31 } |
32 | |
33 public ArmourType ItemArmourType | |
34 { | |
35 get { return armourType; } | |
36 set { armourType = value; } | |
37 } | |
38 | |
43
d0812d7de39d
Re #49 - Resolve namespace issues
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
39 public double Cost |
0 | 40 { |
41 get { return cost; } | |
54
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
42 set |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
43 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
44 if (value >= 0) |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
45 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
46 cost = value; |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
47 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
48 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
49 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
50 |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
51 public string Description |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
52 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
53 get { return description; } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
54 set { description = (value == null ? "" : value); } |
0 | 55 } |
56 | |
57 public Race EquipmentForRace | |
58 { | |
59 get { return equipForRace; } | |
60 } | |
61 | |
62 public bool CanBeUsedWithItem(EquipmentItem item) | |
63 { | |
64 return CanBeUsedWithArmourType(item.ItemArmourType); | |
65 } | |
66 | |
67 public bool CanBeUsedWithArmourType(ArmourType otherItemType) | |
68 { | |
69 return (this.ItemArmourType & otherItemType) == 0; | |
70 } | |
71 } | |
72 } |