Mercurial > repos > IBDev-IBBoard.WarFoundry.API
annotate api/Objects/UnitType.cs @ 252:a54da5a8b5bb
Re #268: Restructure stats for re-use
* Add "Member Type" class
* Add member type setting and getting to Race
* Load member types from XML files
* Make unit type pull stat line from stats or first member type, or fall back to a blank stat line
* Change Stats object to initialise blank values
* Change schema
* Make stats optional
* Add member type list to race
* Add optional member type references to units
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 25 Apr 2010 15:07:08 +0000 |
parents | 8c6f55d289b0 |
children | 79943fcf4de2 |
rev | line source |
---|---|
104
2f3cafb69799
Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents:
93
diff
changeset
|
1 // This file (UnitType.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:
93
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 |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
5 using System; |
82 | 6 using System.Collections.Generic; |
0 | 7 using System.Xml; |
176
22429737cd77
Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
170
diff
changeset
|
8 using IBBoard.Limits; |
0 | 9 using IBBoard.Logging; |
82 | 10 using IBBoard.WarFoundry.API.Requirements; |
11 | |
12 namespace IBBoard.WarFoundry.API.Objects | |
13 { | |
14 /// <summary> | |
15 /// A UnitType is a type for a <see cref=" Unit"/>, normally relating to an entry in an army list. The UnitType defines the name, cost, minimum and maximum limits of a unit, and the equipment units of the type can take. | |
16 /// </summary> | |
17 public class UnitType : WarFoundryObject | |
0 | 18 { |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
19 private Category mainCat; |
82 | 20 private Race race; |
21 private int min, max, baseSize = 0; | |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
22 private int minSize, maxSize; |
82 | 23 private double baseUnitCost; |
24 private double costPerTrooper; | |
25 private Stats stats; | |
26 private List<UnitRequirement> requirements = new List<UnitRequirement>(); | |
27 private Dictionary<string, UnitEquipmentItem> equipment = new Dictionary<string, UnitEquipmentItem>(); | |
28 private Dictionary<string, List<UnitEquipmentItem>> equipmentExclusionGroups = new Dictionary<string, List<UnitEquipmentItem>>(); | |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
29 private List<string> equipmentKeyOrder = new List<string>(); |
57
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
30 private Dictionary<string, Ability> requiredAbilities = new Dictionary<string, Ability>(); |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
31 private Dictionary<string, Ability> optionalAbilities = new Dictionary<string, Ability>(); |
69
91cf8efbea0b
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
32 private String notes = ""; |
170 | 33 private List<UnitType> containedTypes = new List<UnitType>(); |
34 private Dictionary<string, string> extraData = new Dictionary<string, string>(); | |
176
22429737cd77
Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
170
diff
changeset
|
35 private Dictionary<string, AbstractLimit> slotLimits = new Dictionary<string, AbstractLimit>(); |
252
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
36 private Dictionary<string, UnitMemberType> unitMemberTypes = new Dictionary<string, UnitMemberType>(); |
82 | 37 |
38 public UnitType(string id, string typeName, Race parentRace) : base(id, typeName) | |
39 { | |
40 race = parentRace; | |
41 } | |
42 | |
12
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
43 [Obsolete("Use three parameter constructor and setters")] |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
44 public UnitType(string id, string typeName, string mainCategoryID, string[] allCategoryIDs, int minNum, int maxNum, int minimumSize, int maximumSize, double unitCost, double trooperCost, Stats unitStats, UnitRequirement[] unitRequirements, Race parentRace) : this (id, typeName, parentRace) |
0 | 45 { |
34 | 46 mainCat = race.GetCategory(mainCategoryID); |
12
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
47 MinNumber = minNum; |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
48 MaxNumber = maxNum; |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
49 MinSize = minimumSize; |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
50 MaxSize = maximumSize; |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
51 BaseUnitCost = unitCost; |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
52 CostPerTrooper = trooperCost; |
82 | 53 SetUnitStats(unitStats); |
54 | |
55 foreach (UnitRequirement requirement in requirements) | |
56 { | |
57 AddRequirement(requirement); | |
0 | 58 } |
82 | 59 } |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
60 |
68
10d14a7051d5
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
67
diff
changeset
|
61 public GameSystem GameSystem |
10d14a7051d5
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
67
diff
changeset
|
62 { |
10d14a7051d5
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
67
diff
changeset
|
63 get { return Race.GameSystem; } |
10d14a7051d5
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
67
diff
changeset
|
64 } |
10d14a7051d5
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
67
diff
changeset
|
65 |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
66 /// <value> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
67 /// Gets the <see cref=" Race"/> that this unit belongs to. |
82 | 68 /// </value> |
69 public Race Race | |
70 { | |
71 get { return race; } | |
72 } | |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
73 |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
74 /// <value> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
75 /// Gets or sets the <see cref=" Category"/> that this unit type is a member of. |
82 | 76 /// </value> |
77 public virtual Category MainCategory | |
78 { | |
0 | 79 get |
12
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
80 { |
0 | 81 return mainCat; |
82 | 82 } |
83 set | |
84 { | |
85 mainCat = value; | |
86 } | |
87 } | |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
88 |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
89 /// <value> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
90 /// Gets or sets the minimum size of each unit of this type. Note: This should be set AFTER MaxSize, otherwise an unintended default value may be set for the minimum |
82 | 91 /// </value> |
92 public int MinSize | |
93 { | |
94 get { return minSize; } | |
95 set | |
12
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
96 { |
82 | 97 minSize = (value >= 0 ? value : 0); |
98 CheckMinimumSize(); | |
99 } | |
100 } | |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
101 |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
102 /// <value> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
103 /// Gets or sets the maximum size of each unit of this type. Note: This should be set BEFORE MinSize, otherwise an unintended default value may be set for the minimum |
82 | 104 /// </value> |
105 public int MaxSize | |
106 { | |
107 get { return maxSize; } | |
108 set | |
109 { | |
110 maxSize = (value >= 0 ? value : WarFoundryCore.INFINITY); | |
111 CheckMinimumSize(); | |
112 } | |
0 | 113 } |
82 | 114 |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
115 /// <value> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
116 /// Gets or sets the minimum number of units of this type that must be taken in an army. Note: This should be set AFTER MaxNumber, otherwise an unintended default value may be set for the minimum |
82 | 117 /// </value> |
118 public int MinNumber | |
119 { | |
120 get { return min; } | |
121 set | |
12
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
122 { |
82 | 123 min = (value >= 0 ? value : 0); |
124 CheckMinimumNumber(); | |
125 } | |
126 } | |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
127 |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
128 /// <value> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
129 /// Gets or sets the maximum number of units of this type that can be taken in an army. Note: This should be set BEFORE MinNumber, otherwise an unintended default value may be set for the minimum |
82 | 130 /// </value> |
131 public int MaxNumber | |
132 { | |
133 get { return max; } | |
134 set | |
135 { | |
136 max = (value >= 0 ? value : WarFoundryCore.INFINITY); | |
137 CheckMinimumNumber(); | |
138 } | |
139 } | |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
140 |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
141 /// <summary> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
142 /// Makes sure that the minimum number isn't more than the maximum number, hence the warning on the properties |
82 | 143 /// </summary> |
144 private void CheckMinimumNumber() | |
145 { | |
38
548cfc776f54
Fixes #34 - Remove "Choices" and "Base/Increment" from Category
IBBoard <dev@ibboard.co.uk>
parents:
34
diff
changeset
|
146 if (MinNumber > MaxNumber && MaxNumber!=WarFoundryCore.INFINITY) |
12
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
147 { |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
148 MinNumber = MaxNumber; |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
149 LogNotifier.WarnFormat(GetType(), "Unit type {0} ({1}) had a minimum number greater than their maximum number.", Name, ID); |
82 | 150 } |
151 } | |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
152 |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
153 /// <summary> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
154 /// Makes sure that the minimum unit size isn't more than the maximum unit size, hence the warning on the properties |
82 | 155 /// </summary> |
156 private void CheckMinimumSize() | |
157 { | |
38
548cfc776f54
Fixes #34 - Remove "Choices" and "Base/Increment" from Category
IBBoard <dev@ibboard.co.uk>
parents:
34
diff
changeset
|
158 if (MinSize > MaxSize && MaxSize!=WarFoundryCore.INFINITY) |
12
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
159 { |
34 | 160 MinSize = MaxSize; |
12
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
161 LogNotifier.WarnFormat(GetType(), "Unit type {0} ({1}) had a minimum size greater than their maximum size.", Name, ID); |
82 | 162 } |
0 | 163 } |
164 | |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
165 //// <value> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
166 /// Gets or sets the "base size" of a unit, which is the number of troopers the unit has in it for its "base cost". For a lot of units this value will be 0 as the cost is worked out based on the total number of members. |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
167 /// </value> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
168 public int BaseSize |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
169 { |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
170 get { return baseSize; } |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
171 set { baseSize = (value >= 0 ? value : 0); } |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
172 } |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
173 |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
174 /// <value> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
175 /// The number of points that a "base unit" of <code>BaseSize</code> models costs. Additional models are charged at <code>CostPerTrooper</code> each. |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
176 /// </value> |
0 | 177 public double BaseUnitCost |
178 { | |
82 | 179 get { return baseUnitCost; } |
12
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
180 set { baseUnitCost = (value >= 0 ? value : 0); } |
82 | 181 } |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
182 |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
183 //// <value> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
184 /// The cost of an individual trooper. This value is the cost for a basic trooper without weapons, which are added on top of the cost before calculating a unit cost. |
82 | 185 /// </value> |
186 public double CostPerTrooper | |
187 { | |
188 get { return costPerTrooper; } | |
189 set { costPerTrooper = (value >= 0 ? value : 0); } | |
190 } | |
191 | |
192 protected override string DefaultName() | |
193 { | |
194 throw new InvalidOperationException("Unit type with id "+id+" did not have a name specified"); | |
195 } | |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
196 |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
197 /// <value> |
81
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
198 /// The set of <see cref="Stat"/>s for the unit in a format that is valid for the game system. |
82 | 199 /// </value> |
200 public Stat[] UnitStatsArray | |
201 { | |
252
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
202 get |
82 | 203 { |
252
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
204 Stat[] statsArray = null; |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
205 |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
206 if (stats != null) |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
207 { |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
208 statsArray = stats.StatsArray; |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
209 } |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
210 else if (unitMemberTypes.Count > 0) |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
211 { |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
212 UnitMemberType[] memberTypeArray = DictionaryUtils.ToArray(unitMemberTypes); |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
213 statsArray = memberTypeArray[0].StatsArray; |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
214 } |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
215 else |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
216 { |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
217 SystemStats systemStats = GameSystem.StandardSystemStats; |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
218 Stats tempStats = new Stats(systemStats); |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
219 statsArray = tempStats.StatsArray; |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
220 } |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
221 |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
222 return statsArray; |
82 | 223 } |
81
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
224 } |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
225 |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
226 //// <value> |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
227 /// The set of <see cref="Stat"/>s for the unit including an additional column that contains the unit type name |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
228 /// </value> |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
229 public Stat[] UnitStatsArrayWithName |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
230 { |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
231 get |
252
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
232 { |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
233 Stat[] statsArray = null; |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
234 |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
235 if (stats != null) |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
236 { |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
237 statsArray = ExtendStatsArrayWithName(stats.StatsArray); |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
238 } |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
239 else if (unitMemberTypes.Count > 0) |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
240 { |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
241 UnitMemberType[] memberTypeArray = DictionaryUtils.ToArray(unitMemberTypes); |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
242 statsArray = memberTypeArray[0].StatsArrayWithName; |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
243 } |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
244 else |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
245 { |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
246 SystemStats systemStats = GameSystem.StandardSystemStats; |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
247 Stats tempStats = new Stats(systemStats); |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
248 statsArray = ExtendStatsArrayWithName(tempStats.StatsArray); |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
249 } |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
250 |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
251 return statsArray; |
81
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
252 } |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
253 } |
252
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
254 |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
255 public Stat[] ExtendStatsArrayWithName(Stat[] statsArray) |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
256 { |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
257 Stat[] extendedStats = new Stat[statsArray.Length+1]; |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
258 extendedStats[0] = new Stat(new StatSlot("name"), Name); |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
259 statsArray.CopyTo(extendedStats, 1); |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
260 return extendedStats; |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
261 } |
81
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
262 |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
263 public void SetUnitStats(Stats newStats) |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
264 { |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
265 stats = newStats; |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
266 } |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
267 |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
268 public string GetStatValue(string statName) |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
269 { |
181
8c6f55d289b0
Fixes #200: Stats names should be case-insensitive
IBBoard <dev@ibboard.co.uk>
parents:
176
diff
changeset
|
270 return stats.GetStatValue(statName.ToLower()); |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
271 } |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
272 |
92
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
273 internal void AddEquipmentItem(UnitEquipmentItem item) |
93
789dfab13449
* Remove debugging Console.WriteLine call
IBBoard <dev@ibboard.co.uk>
parents:
92
diff
changeset
|
274 { |
85
46ad6f478203
Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
275 if (!equipment.ContainsKey(item.ID)) |
46ad6f478203
Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
276 { |
46ad6f478203
Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
277 equipment.Add(item.ID, item); |
46ad6f478203
Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
278 equipmentKeyOrder.Add(item.ID); |
152
0c0e14f03785
Re #180: Add multiple mutex groups
IBBoard <dev@ibboard.co.uk>
parents:
131
diff
changeset
|
279 AddToMutexGroups(item); |
85
46ad6f478203
Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
280 } |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
281 } |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
282 |
152
0c0e14f03785
Re #180: Add multiple mutex groups
IBBoard <dev@ibboard.co.uk>
parents:
131
diff
changeset
|
283 private void AddToMutexGroups(UnitEquipmentItem item) |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
284 { |
152
0c0e14f03785
Re #180: Add multiple mutex groups
IBBoard <dev@ibboard.co.uk>
parents:
131
diff
changeset
|
285 string[] mutexGroups = item.MutexGroups; |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
286 |
152
0c0e14f03785
Re #180: Add multiple mutex groups
IBBoard <dev@ibboard.co.uk>
parents:
131
diff
changeset
|
287 foreach (string mutexGroup in mutexGroups) |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
288 { |
66
d100ca4bd0c1
Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
289 List<UnitEquipmentItem> items = DictionaryUtils.GetValue(equipmentExclusionGroups, mutexGroup); |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
290 |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
291 if (items == null) |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
292 { |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
293 items = new List<UnitEquipmentItem>(); |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
294 equipmentExclusionGroups.Add(mutexGroup, items); |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
295 } |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
296 |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
297 items.Add(item); |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
298 } |
82 | 299 } |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
300 |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
301 /// <summary> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
302 /// Gets a <see cref="UnitEquipmentItem"/> for the given ID string, or <code>null</code> if nothing exists for that ID |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
303 /// </summary> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
304 /// <param name="id"> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
305 /// The ID of the UnitEquipmentItem to get |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
306 /// </param> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
307 /// <returns> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
308 /// The <see cref="UnitEquipmentItem"/> for the given ID string, or <code>null</code> if nothing exists for that ID |
82 | 309 /// </returns> |
310 public UnitEquipmentItem GetEquipmentItem(string id) | |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
311 { |
82 | 312 return DictionaryUtils.GetValue(equipment, id); |
64
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
313 } |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
314 |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
315 /// <summary> |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
316 /// Gets a <see cref=" UnitEquipmentItem"/> for the given <see cref=" EquipmentItem"/>, or <code>null</code> if the unit can't take that <code>EquipmentItem</code> |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
317 /// </summary> |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
318 /// <param name="item"> |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
319 /// The <see cref="EquipmentItem"/> to get the <see cref=" UnitEquipmentItem"/> |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
320 /// </param> |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
321 /// <returns> |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
322 /// The <see cref="UnitEquipmentItem"/> that definies the UnitType's restrictions for taking the <see cref=" EquipmentItem"/> |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
323 /// </returns> |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
324 public UnitEquipmentItem GetEquipmentItem(EquipmentItem item) |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
325 { |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
326 return GetEquipmentItem(item.ID); |
82 | 327 } |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
328 |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
329 /// <summary> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
330 /// Gets an array of all available <see cref="UnitEquipmentItem"/>s for this UnitType |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
331 /// </summary> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
332 /// <returns> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
333 /// An array of all available <see cref="UnitEquipmentItem"/>s for this UnitType |
82 | 334 /// </returns> |
335 public UnitEquipmentItem[] GetEquipmentItems() | |
336 { | |
337 return DictionaryUtils.ToArray<string, UnitEquipmentItem>(equipment); | |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
338 } |
57
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
339 |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
340 public UnitEquipmentItem[] GetEquipmentItemsByExclusionGroup(string group) |
154
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
341 { |
152
0c0e14f03785
Re #180: Add multiple mutex groups
IBBoard <dev@ibboard.co.uk>
parents:
131
diff
changeset
|
342 return GetEquipmentItemsByExclusionGroups(new string[] { group }); |
0c0e14f03785
Re #180: Add multiple mutex groups
IBBoard <dev@ibboard.co.uk>
parents:
131
diff
changeset
|
343 } |
57
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
344 |
152
0c0e14f03785
Re #180: Add multiple mutex groups
IBBoard <dev@ibboard.co.uk>
parents:
131
diff
changeset
|
345 public UnitEquipmentItem[] GetEquipmentItemsByExclusionGroups(string[] groups) |
0c0e14f03785
Re #180: Add multiple mutex groups
IBBoard <dev@ibboard.co.uk>
parents:
131
diff
changeset
|
346 { |
154
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
347 List<UnitEquipmentItem> list = new List<UnitEquipmentItem>(); |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
348 |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
349 foreach (string group in groups) |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
350 { |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
351 List<UnitEquipmentItem> groupList = DictionaryUtils.GetValue(equipmentExclusionGroups, group); |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
352 |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
353 if (groupList != null) |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
354 { |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
355 list.AddRange(groupList); |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
356 } |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
357 } |
4a02c07278e7
Re #185: Problems with decimals in race definitions
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
358 |
152
0c0e14f03785
Re #180: Add multiple mutex groups
IBBoard <dev@ibboard.co.uk>
parents:
131
diff
changeset
|
359 return list.ToArray(); |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
360 } |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
361 |
64
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
362 public bool IsRatioLimitedEquipmentItem(EquipmentItem item) |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
363 { |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
364 UnitEquipmentItem equip = GetEquipmentItem(item); |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
365 return equip != null && equip.IsRatioLimit; |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
366 } |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
367 |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
368 public bool IsAbsoluteLimitedEquipmentItem(EquipmentItem item) |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
369 { |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
370 UnitEquipmentItem equip = GetEquipmentItem(item); |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
371 return equip != null && !equip.IsRatioLimit; |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
372 } |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
373 |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
374 public ICollection<Ability> GetRequiredAbilities() |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
375 { |
57
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
376 return requiredAbilities.Values; |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
377 } |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
378 |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
379 public ICollection<Ability> GetOptionalAbilities() |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
380 { |
57
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
381 return optionalAbilities.Values; |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
382 } |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
383 |
57
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
384 public void AddAbility(Ability ability, bool isRequired) |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
385 { |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
386 string id = ability.ID; |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
387 |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
388 if (!requiredAbilities.ContainsKey(id) && !optionalAbilities.ContainsKey(id)) |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
389 { |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
390 if (isRequired) |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
391 { |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
392 requiredAbilities[id] = ability; |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
393 } |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
394 else |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
395 { |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
396 optionalAbilities[id] = ability; |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
397 } |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
398 } |
82 | 399 } |
400 | |
401 public void AddRequirement(UnitRequirement requirement) | |
402 { | |
403 requirements.Add(requirement); | |
57
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
404 } |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
405 |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
406 public UnitRequirement[] Requirements |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
407 { |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
408 get { return requirements.ToArray(); } |
82 | 409 } |
0 | 410 |
411 public List<FailedUnitRequirement> CanAddToArmy(Army army) | |
412 { | |
413 List<FailedUnitRequirement> failures = new List<FailedUnitRequirement>(); | |
414 | |
82 | 415 if (requirements!=null && requirements.Count > 0) |
0 | 416 { |
417 foreach (UnitRequirement requirement in requirements) | |
418 { | |
419 FailedUnitRequirement failure = (FailedUnitRequirement)requirement.CanAddToWarFoundryObject(army); | |
420 | |
421 if (failure!=null) | |
422 { | |
423 failures.Add(failure); | |
424 } | |
425 } | |
426 } | |
427 | |
428 return failures; | |
429 } | |
430 | |
431 public List<FailedUnitRequirement> CanRemoveFromArmy(Army army) | |
432 { | |
433 List<FailedUnitRequirement> failures = new List<FailedUnitRequirement>(); | |
434 | |
82 | 435 if (requirements!=null && requirements.Count > 0) |
0 | 436 { |
437 foreach (UnitRequirement requirement in requirements) | |
438 { | |
439 FailedUnitRequirement failure = (FailedUnitRequirement)requirement.CanRemoveFromWarFoundryObject(army); | |
440 | |
441 if (failure!=null) | |
442 { | |
443 failures.Add(failure); | |
444 } | |
445 } | |
446 } | |
447 | |
448 return failures; | |
57
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
449 } |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
450 |
69
91cf8efbea0b
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
451 public string Notes |
57
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
452 { |
69
91cf8efbea0b
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
453 get { return notes; } |
91cf8efbea0b
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
454 set { notes = value; } |
57
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
455 } |
69
91cf8efbea0b
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
456 |
61
3c77722a02b5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
57
diff
changeset
|
457 public bool CanContainUnit(Unit unit) |
3c77722a02b5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
57
diff
changeset
|
458 { |
3c77722a02b5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
57
diff
changeset
|
459 return CanContainUnitType(unit.UnitType); |
3c77722a02b5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
57
diff
changeset
|
460 } |
3c77722a02b5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
57
diff
changeset
|
461 |
3c77722a02b5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
57
diff
changeset
|
462 public bool CanContainUnitType(UnitType unitType) |
3c77722a02b5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
57
diff
changeset
|
463 { |
3c77722a02b5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
57
diff
changeset
|
464 return containedTypes.Contains(unitType); |
3c77722a02b5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
57
diff
changeset
|
465 } |
3c77722a02b5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
57
diff
changeset
|
466 |
57
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
467 public UnitType[] ContainedUnitTypes |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
468 { |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
469 get { return containedTypes.ToArray(); } |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
470 } |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
471 |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
472 public void AddContainedUnitType(UnitType containedType) |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
473 { |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
474 containedTypes.Add(containedType); |
66
d100ca4bd0c1
Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
475 } |
d100ca4bd0c1
Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
476 |
d100ca4bd0c1
Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
477 public void AddExtraData(string id, string data) |
d100ca4bd0c1
Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
478 { |
d100ca4bd0c1
Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
479 extraData[id] = data; |
d100ca4bd0c1
Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
480 } |
d100ca4bd0c1
Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
481 |
d100ca4bd0c1
Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
482 public string GetExtraData(string id) |
d100ca4bd0c1
Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
483 { |
d100ca4bd0c1
Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
484 return DictionaryUtils.GetValue(extraData, id); |
82 | 485 } |
131
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
486 |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
487 public string StatsID |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
488 { |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
489 get |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
490 { |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
491 return stats.StatsID; |
170 | 492 } |
493 } | |
494 | |
176
22429737cd77
Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
170
diff
changeset
|
495 public void AddEquipmentSlot(string slotName, AbstractLimit slotLimit) |
170 | 496 { |
497 slotLimits.Add(slotName, slotLimit); | |
498 } | |
499 | |
500 public bool HasEquipmentSlot(string slotName) | |
501 { | |
502 return slotLimits.ContainsKey(slotName); | |
503 } | |
504 | |
505 /// <summary> | |
176
22429737cd77
Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
170
diff
changeset
|
506 /// Gets the maximum limit on the number of items allowed in a single slot |
170 | 507 /// </summary> |
176
22429737cd77
Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
170
diff
changeset
|
508 /// <param name="slotName">The name of the equipment slot to get the limit for</param> |
22429737cd77
Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
170
diff
changeset
|
509 /// <returns>The limit of the number of items allowed in a slot, or an infinite limit if the slot is the default one or has not been specified</returns> |
22429737cd77
Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
170
diff
changeset
|
510 public AbstractLimit GetEquipmentSlotLimit(string slotName) |
170 | 511 { |
176
22429737cd77
Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
170
diff
changeset
|
512 AbstractLimit slotLimit = null; |
170 | 513 |
514 if (HasEquipmentSlot(slotName)) | |
515 { | |
516 slotLimit = DictionaryUtils.GetValue(slotLimits, slotName); | |
517 } | |
176
22429737cd77
Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
170
diff
changeset
|
518 |
22429737cd77
Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
170
diff
changeset
|
519 if (slotLimit == null) |
22429737cd77
Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
170
diff
changeset
|
520 { |
22429737cd77
Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
170
diff
changeset
|
521 slotLimit = new UnlimitedLimit(); |
22429737cd77
Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
170
diff
changeset
|
522 } |
170 | 523 |
524 return slotLimit; | |
131
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
525 } |
252
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
526 |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
527 public void AddUnitMemberType(UnitMemberType unitMemberType) |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
528 { |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
529 unitMemberTypes.Add(unitMemberType.ID, unitMemberType); |
a54da5a8b5bb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
181
diff
changeset
|
530 } |
82 | 531 } |
66
d100ca4bd0c1
Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
532 } |