Mercurial > repos > snowblizz-super-API-ideas
annotate api/Objects/UnitEquipmentItem.cs @ 155:df61d26c23fb
Re #178: "crash" when loading old .army file with equipment tags that are "old"
* Try to tidy up the exception messages - ideally they'll end up translated and localised
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 28 Sep 2009 19:48:37 +0000 |
parents | 4a02c07278e7 |
children | 6ff68daab5dc |
rev | line source |
---|---|
104
2f3cafb69799
Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents:
101
diff
changeset
|
1 // This file (UnitEquipmentItem.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2007, 2008, 2009 IBBoard. |
15 | 2 // |
104
2f3cafb69799
Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents:
101
diff
changeset
|
3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. |
15 | 4 |
82 | 5 using System; |
6 using IBBoard.Lang; | |
7 | |
8 namespace IBBoard.WarFoundry.API.Objects | |
9 { | |
10 /// <summary> | |
11 /// Summary description for UnitEquipmentItem. | |
12 /// </summary> | |
13 public class UnitEquipmentItem : WarFoundryObject | |
54
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
14 { |
82 | 15 private EquipmentItem item; |
54
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
16 private bool required; |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
17 private bool roundUp; |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
18 private int minNum; |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
19 private int maxNum; |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
20 private double minPercentage; |
79
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
21 private double maxPercentage; |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
22 private double costMultiplier; |
154
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
23 private RoundType roundType; |
152
0c0e14f03785
Re #180: Add multiple mutex groups
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
24 private string[] mutexGroups; |
82 | 25 private UnitType unitType; |
54
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
26 |
152
0c0e14f03785
Re #180: Add multiple mutex groups
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
27 public UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipmentFor) : this(equipmentItem, equipmentFor, new string[0]) |
138
c11c0da01bbc
Fixes #147: "Replace Weapon" button doesn't always enable (regression)
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
28 { |
c11c0da01bbc
Fixes #147: "Replace Weapon" button doesn't always enable (regression)
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
29 //Do nothing extra |
c11c0da01bbc
Fixes #147: "Replace Weapon" button doesn't always enable (regression)
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
30 } |
c11c0da01bbc
Fixes #147: "Replace Weapon" button doesn't always enable (regression)
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
31 |
152
0c0e14f03785
Re #180: Add multiple mutex groups
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
32 public UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipmentFor, params string[] mutexGroups) |
54
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
33 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
34 item = equipmentItem; |
92
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
35 unitType = equipmentFor; |
152
0c0e14f03785
Re #180: Add multiple mutex groups
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
36 this.mutexGroups = mutexGroups; |
92
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
37 unitType.AddEquipmentItem(this); |
154
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
38 } |
54
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
39 |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
40 public override string Name |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
41 { |
92
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
42 get |
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
43 { |
54
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
44 return item.Name; |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
45 } |
92
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
46 set |
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
47 { |
54
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
48 base.Name = value; |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
49 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
50 } |
92
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
51 |
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
52 public override string ID { |
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
53 get |
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
54 { |
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
55 return (EquipmentForUnit == null ? base.ID : EquipmentForUnit.ID) + EquipmentItemID; |
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
56 } |
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
57 set |
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
58 { |
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
59 base.ID = value; |
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
60 } |
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
61 } |
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
62 |
54
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
63 |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
64 public string EquipmentItemID |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
65 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
66 get { return item.ID; } |
82 | 67 } |
68 | |
69 public double Cost | |
70 { | |
79
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
71 get |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
72 { |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
73 return IBBMath.Round(EquipmentItem.Cost * CostMultiplier, CostRoundType); |
82 | 74 } |
79
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
75 } |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
76 |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
77 public double CostMultiplier |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
78 { |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
79 get { return costMultiplier; } |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
80 set |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
81 { |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
82 costMultiplier = value; |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
83 } |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
84 } |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
85 |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
86 public RoundType CostRoundType |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
87 { |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
88 get { return roundType; } |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
89 set |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
90 { |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
91 roundType = value; |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
92 } |
82 | 93 } |
94 | |
95 public bool IsRequired | |
96 { | |
97 get { return required; } | |
98 set { required = value; } | |
99 } | |
100 | |
101 public bool RoundNumberUp | |
102 { | |
103 get { return roundUp; } | |
104 set { roundUp = value; } | |
105 } | |
106 | |
152
0c0e14f03785
Re #180: Add multiple mutex groups
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
107 [Obsolete("Use MutexGroups instead for greater flexibility")] |
82 | 108 public string MutexGroup |
109 { | |
152
0c0e14f03785
Re #180: Add multiple mutex groups
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
110 get { return (mutexGroups.Length == 0 ? "" : mutexGroups[0]); } |
154
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
111 } |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
112 |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
113 public String[] MutexGroups |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
114 { |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
115 get { return (string[]) mutexGroups.Clone(); } |
82 | 116 } |
117 | |
118 public UnitType EquipmentForUnit | |
119 { | |
120 get { return unitType; } | |
54
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
121 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
122 |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
123 public bool IsRatioLimit |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
124 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
125 get { return minPercentage!=100 || maxPercentage!=100; } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
126 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
127 |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
128 public int MinNumber |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
129 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
130 get { return minNum; } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
131 set |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
132 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
133 if (value >=0 || value == WarFoundryCore.INFINITY) |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
134 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
135 minNum = value; |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
136 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
137 //TODO: Check Min<Max |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
138 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
139 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
140 |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
141 public int MaxNumber |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
142 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
143 get { return maxNum; } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
144 set |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
145 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
146 if (value >=0 || value == WarFoundryCore.INFINITY) |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
147 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
148 maxNum = value; |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
149 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
150 //TODO: Check Min<Max |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
151 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
152 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
153 |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
154 public double MinPercentage |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
155 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
156 get { return minPercentage; } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
157 set |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
158 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
159 if (value >=0 && value <= 100) |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
160 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
161 minPercentage = value; |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
162 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
163 //TODO: Check Min<Max |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
164 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
165 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
166 |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
167 public double MaxPercentage |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
168 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
169 get { return maxPercentage; } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
170 set |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
171 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
172 if (value >=0 && value <= 100) |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
173 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
174 maxPercentage = value; |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
175 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
176 //TODO: Check Min<Max |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
177 } |
82 | 178 } |
179 | |
180 public EquipmentItem EquipmentItem | |
181 { | |
182 get { return item; } | |
183 } | |
184 | |
185 public override string ToString() | |
186 { | |
187 return EquipmentItem.Name+ " ("+EquipmentItem.Cost+"pts each)"; | |
188 } | |
189 | |
190 public bool HasAlternatives() | |
191 { | |
152
0c0e14f03785
Re #180: Add multiple mutex groups
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
192 if (MutexGroups.Length == 0) |
82 | 193 { |
194 return false; | |
195 } | |
85
46ad6f478203
Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
196 else if (EquipmentForUnit == null) |
46ad6f478203
Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
197 { |
46ad6f478203
Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
198 return false; |
46ad6f478203
Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
199 } |
82 | 200 else |
201 { | |
202 //If the number of items in the MutEx group is greater than one then it must be this item plus another | |
152
0c0e14f03785
Re #180: Add multiple mutex groups
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
203 return EquipmentForUnit.GetEquipmentItemsByExclusionGroups(MutexGroups).Length > 1; |
82 | 204 } |
54
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
205 } |
79
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
206 |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
207 public ArmourType ItemArmourType |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
208 { |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
209 get { return EquipmentItem.ItemArmourType; } |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
210 } |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
211 |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
212 public string Description |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
213 { |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
214 get { return EquipmentItem.Description; } |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
215 } |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
216 |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
217 public Race EquipmentForRace |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
218 { |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
219 get { return EquipmentItem.EquipmentForRace; } |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
220 } |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
221 |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
222 public bool CanBeUsedWithItem(EquipmentItem item) |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
223 { |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
224 return EquipmentItem.CanBeUsedWithItem(item); |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
225 } |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
226 |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
227 public bool CanBeUsedWithArmourType(ArmourType otherItemType) |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
228 { |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
229 return EquipmentItem.CanBeUsedWithArmourType(otherItemType); |
154
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
230 } |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
231 |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
232 /// <summary> |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
233 /// Checks the "mutex" (mutual exclusion) groups of the other item against its own and determines whether the two items are mutually exclusive (share at least one mutex group) |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
234 /// </summary> |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
235 /// <param name="item">the item to check against</param> |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
236 /// <returns><code>true</code> if the two items share at least one mutex group, else <code>false</code></returns> |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
237 public bool IsMutuallyExclusive(UnitEquipmentItem item) |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
238 { |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
239 bool areMutex = false; |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
240 |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
241 foreach (string mutex in MutexGroups) |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
242 { |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
243 foreach (string otherMutex in item.MutexGroups) |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
244 { |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
245 if (mutex.Equals(otherMutex)) |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
246 { |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
247 areMutex = true; |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
248 goto postLoop; |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
249 } |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
250 } |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
251 } |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
252 postLoop: |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
253 |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
254 return areMutex; |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
255 } |
82 | 256 } |
257 } |