Mercurial > repos > IBDev-IBBoard.WarFoundry.API
annotate api/Objects/UnitType.cs @ 131:5145b7c61ae0
Re #68: Add "export army list" function
* Add initial body of an export method (doesn't list costs, total or equipment)
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 01 Sep 2009 16:06:39 +0000 |
parents | 2f3cafb69799 |
children | 0c0e14f03785 |
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; |
8 using IBBoard.Logging; | |
82 | 9 using IBBoard.WarFoundry.API.Requirements; |
10 | |
11 namespace IBBoard.WarFoundry.API.Objects | |
12 { | |
13 /// <summary> | |
14 /// 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. | |
15 /// </summary> | |
16 public class UnitType : WarFoundryObject | |
0 | 17 { |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
18 private Category mainCat; |
82 | 19 private Race race; |
20 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
|
21 private int minSize, maxSize; |
82 | 22 private double baseUnitCost; |
23 private double costPerTrooper; | |
24 private Stats stats; | |
25 private List<UnitRequirement> requirements = new List<UnitRequirement>(); | |
26 private Dictionary<string, UnitEquipmentItem> equipment = new Dictionary<string, UnitEquipmentItem>(); | |
27 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
|
28 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
|
29 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
|
30 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
|
31 private String notes = ""; |
66
d100ca4bd0c1
Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
32 private List<UnitType> containedTypes = new List<UnitType>(); |
82 | 33 private Dictionary<string, string> extraData = new Dictionary<string, string>(); |
34 | |
35 | |
36 public UnitType(string id, string typeName, Race parentRace) : base(id, typeName) | |
37 { | |
38 race = parentRace; | |
39 } | |
40 | |
12
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
41 [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
|
42 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 | 43 { |
34 | 44 mainCat = race.GetCategory(mainCategoryID); |
12
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
45 MinNumber = minNum; |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
46 MaxNumber = maxNum; |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
47 MinSize = minimumSize; |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
48 MaxSize = maximumSize; |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
49 BaseUnitCost = unitCost; |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
50 CostPerTrooper = trooperCost; |
82 | 51 SetUnitStats(unitStats); |
52 | |
53 foreach (UnitRequirement requirement in requirements) | |
54 { | |
55 AddRequirement(requirement); | |
0 | 56 } |
82 | 57 } |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
58 |
68
10d14a7051d5
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
67
diff
changeset
|
59 public GameSystem GameSystem |
10d14a7051d5
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
67
diff
changeset
|
60 { |
10d14a7051d5
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
67
diff
changeset
|
61 get { return Race.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 |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
64 /// <value> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
65 /// Gets the <see cref=" Race"/> that this unit belongs to. |
82 | 66 /// </value> |
67 public Race Race | |
68 { | |
69 get { return race; } | |
70 } | |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
71 |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
72 /// <value> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
73 /// Gets or sets the <see cref=" Category"/> that this unit type is a member of. |
82 | 74 /// </value> |
75 public virtual Category MainCategory | |
76 { | |
0 | 77 get |
12
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
78 { |
0 | 79 return mainCat; |
82 | 80 } |
81 set | |
82 { | |
83 mainCat = value; | |
84 } | |
85 } | |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
86 |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
87 /// <value> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
88 /// 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 | 89 /// </value> |
90 public int MinSize | |
91 { | |
92 get { return minSize; } | |
93 set | |
12
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
94 { |
82 | 95 minSize = (value >= 0 ? value : 0); |
96 CheckMinimumSize(); | |
97 } | |
98 } | |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
99 |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
100 /// <value> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
101 /// 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 | 102 /// </value> |
103 public int MaxSize | |
104 { | |
105 get { return maxSize; } | |
106 set | |
107 { | |
108 maxSize = (value >= 0 ? value : WarFoundryCore.INFINITY); | |
109 CheckMinimumSize(); | |
110 } | |
0 | 111 } |
82 | 112 |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
113 /// <value> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
114 /// 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 | 115 /// </value> |
116 public int MinNumber | |
117 { | |
118 get { return min; } | |
119 set | |
12
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
120 { |
82 | 121 min = (value >= 0 ? value : 0); |
122 CheckMinimumNumber(); | |
123 } | |
124 } | |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
125 |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
126 /// <value> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
127 /// 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 | 128 /// </value> |
129 public int MaxNumber | |
130 { | |
131 get { return max; } | |
132 set | |
133 { | |
134 max = (value >= 0 ? value : WarFoundryCore.INFINITY); | |
135 CheckMinimumNumber(); | |
136 } | |
137 } | |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
138 |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
139 /// <summary> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
140 /// Makes sure that the minimum number isn't more than the maximum number, hence the warning on the properties |
82 | 141 /// </summary> |
142 private void CheckMinimumNumber() | |
143 { | |
38
548cfc776f54
Fixes #34 - Remove "Choices" and "Base/Increment" from Category
IBBoard <dev@ibboard.co.uk>
parents:
34
diff
changeset
|
144 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
|
145 { |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
146 MinNumber = MaxNumber; |
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
147 LogNotifier.WarnFormat(GetType(), "Unit type {0} ({1}) had a minimum number greater than their maximum number.", Name, ID); |
82 | 148 } |
149 } | |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
150 |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
151 /// <summary> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
152 /// Makes sure that the minimum unit size isn't more than the maximum unit size, hence the warning on the properties |
82 | 153 /// </summary> |
154 private void CheckMinimumSize() | |
155 { | |
38
548cfc776f54
Fixes #34 - Remove "Choices" and "Base/Increment" from Category
IBBoard <dev@ibboard.co.uk>
parents:
34
diff
changeset
|
156 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
|
157 { |
34 | 158 MinSize = MaxSize; |
12
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
159 LogNotifier.WarnFormat(GetType(), "Unit type {0} ({1}) had a minimum size greater than their maximum size.", Name, ID); |
82 | 160 } |
0 | 161 } |
162 | |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
163 //// <value> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
164 /// 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
|
165 /// </value> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
166 public int BaseSize |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
167 { |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
168 get { return baseSize; } |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
169 set { baseSize = (value >= 0 ? value : 0); } |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
170 } |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
171 |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
172 /// <value> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
173 /// 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
|
174 /// </value> |
0 | 175 public double BaseUnitCost |
176 { | |
82 | 177 get { return baseUnitCost; } |
12
ac232763858b
Re #9 - Make WarFoundry API use smaller methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
178 set { baseUnitCost = (value >= 0 ? value : 0); } |
82 | 179 } |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
180 |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
181 //// <value> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
182 /// 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 | 183 /// </value> |
184 public double CostPerTrooper | |
185 { | |
186 get { return costPerTrooper; } | |
187 set { costPerTrooper = (value >= 0 ? value : 0); } | |
188 } | |
189 | |
190 protected override string DefaultName() | |
191 { | |
192 throw new InvalidOperationException("Unit type with id "+id+" did not have a name specified"); | |
193 } | |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
194 |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
195 /// <value> |
81
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
196 /// The set of <see cref="Stat"/>s for the unit in a format that is valid for the game system. |
82 | 197 /// </value> |
198 public Stat[] UnitStatsArray | |
199 { | |
200 get | |
201 { | |
202 return stats.StatsArray; | |
203 } | |
81
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
204 } |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
205 |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
206 //// <value> |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
207 /// 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
|
208 /// </value> |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
209 public Stat[] UnitStatsArrayWithName |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
210 { |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
211 get |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
212 { |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
213 Stat[] extendedStats = new Stat[stats.StatCount+1]; |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
214 extendedStats[0] = new Stat(new StatSlot("Name"), Name); |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
215 stats.StatsArray.CopyTo(extendedStats, 1); |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
216 return extendedStats; |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
217 } |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
218 } |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
219 |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
220 public void SetUnitStats(Stats newStats) |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
221 { |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
222 stats = newStats; |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
223 } |
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 public string GetStatValue(string statName) |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
226 { |
032b174fc17a
Re #10 - Refactoring for readability
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
227 return stats.GetStatValue(statName); |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
228 } |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
229 |
92
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
230 internal void AddEquipmentItem(UnitEquipmentItem item) |
93
789dfab13449
* Remove debugging Console.WriteLine call
IBBoard <dev@ibboard.co.uk>
parents:
92
diff
changeset
|
231 { |
85
46ad6f478203
Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
232 if (!equipment.ContainsKey(item.ID)) |
46ad6f478203
Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
233 { |
46ad6f478203
Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
234 equipment.Add(item.ID, item); |
46ad6f478203
Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
235 equipmentKeyOrder.Add(item.ID); |
46ad6f478203
Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
236 AddToMutexGroup(item); |
46ad6f478203
Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
237 } |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
238 } |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
239 |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
240 private void AddToMutexGroup(UnitEquipmentItem item) |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
241 { |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
242 string mutexGroup = item.MutexGroup; |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
243 |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
244 if (mutexGroup!="" && mutexGroup!=null) |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
245 { |
66
d100ca4bd0c1
Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
246 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
|
247 |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
248 if (items == null) |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
249 { |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
250 items = new List<UnitEquipmentItem>(); |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
251 equipmentExclusionGroups.Add(mutexGroup, items); |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
252 } |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
253 |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
254 items.Add(item); |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
255 } |
82 | 256 } |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
257 |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
258 /// <summary> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
259 /// 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
|
260 /// </summary> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
261 /// <param name="id"> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
262 /// The ID of the UnitEquipmentItem to get |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
263 /// </param> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
264 /// <returns> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
265 /// The <see cref="UnitEquipmentItem"/> for the given ID string, or <code>null</code> if nothing exists for that ID |
82 | 266 /// </returns> |
267 public UnitEquipmentItem GetEquipmentItem(string id) | |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
268 { |
82 | 269 return DictionaryUtils.GetValue(equipment, id); |
64
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
270 } |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
271 |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
272 /// <summary> |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
273 /// 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
|
274 /// </summary> |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
275 /// <param name="item"> |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
276 /// 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
|
277 /// </param> |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
278 /// <returns> |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
279 /// 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
|
280 /// </returns> |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
281 public UnitEquipmentItem GetEquipmentItem(EquipmentItem item) |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
282 { |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
283 return GetEquipmentItem(item.ID); |
82 | 284 } |
46
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
285 |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
286 /// <summary> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
287 /// 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
|
288 /// </summary> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
289 /// <returns> |
a5855fcd75ab
Re #11 - Document classes and methods
IBBoard <dev@ibboard.co.uk>
parents:
38
diff
changeset
|
290 /// An array of all available <see cref="UnitEquipmentItem"/>s for this UnitType |
82 | 291 /// </returns> |
292 public UnitEquipmentItem[] GetEquipmentItems() | |
293 { | |
294 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
|
295 } |
57
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
296 |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
297 public UnitEquipmentItem[] GetEquipmentItemsByExclusionGroup(string group) |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
298 { |
67
e6200220ece3
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
299 List<UnitEquipmentItem> list = DictionaryUtils.GetValue(equipmentExclusionGroups, group); |
57
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
300 |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
301 if (list == null) |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
302 { |
57
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
303 return new UnitEquipmentItem[0]; |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
304 } |
57
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
305 else |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
306 { |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
307 return list.ToArray(); |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
308 } |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
309 } |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
310 |
64
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
311 public bool IsRatioLimitedEquipmentItem(EquipmentItem item) |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
312 { |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
313 UnitEquipmentItem equip = GetEquipmentItem(item); |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
314 return equip != null && equip.IsRatioLimit; |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
315 } |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
316 |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
317 public bool IsAbsoluteLimitedEquipmentItem(EquipmentItem item) |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
318 { |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
319 UnitEquipmentItem equip = GetEquipmentItem(item); |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
320 return equip != null && !equip.IsRatioLimit; |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
321 } |
2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
322 |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
323 public ICollection<Ability> GetRequiredAbilities() |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
324 { |
57
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
325 return requiredAbilities.Values; |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
326 } |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
327 |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
328 public ICollection<Ability> GetOptionalAbilities() |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
329 { |
57
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
330 return optionalAbilities.Values; |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
331 } |
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
332 |
57
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
333 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
|
334 { |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
335 string id = ability.ID; |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
336 |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
337 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
|
338 { |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
339 if (isRequired) |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
340 { |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
341 requiredAbilities[id] = ability; |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
342 } |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
343 else |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
344 { |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
345 optionalAbilities[id] = ability; |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
346 } |
56
9561ef46c6fb
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
347 } |
82 | 348 } |
349 | |
350 public void AddRequirement(UnitRequirement requirement) | |
351 { | |
352 requirements.Add(requirement); | |
57
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
353 } |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
354 |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
355 public UnitRequirement[] Requirements |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
356 { |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
357 get { return requirements.ToArray(); } |
82 | 358 } |
0 | 359 |
360 public List<FailedUnitRequirement> CanAddToArmy(Army army) | |
361 { | |
362 List<FailedUnitRequirement> failures = new List<FailedUnitRequirement>(); | |
363 | |
82 | 364 if (requirements!=null && requirements.Count > 0) |
0 | 365 { |
366 foreach (UnitRequirement requirement in requirements) | |
367 { | |
368 FailedUnitRequirement failure = (FailedUnitRequirement)requirement.CanAddToWarFoundryObject(army); | |
369 | |
370 if (failure!=null) | |
371 { | |
372 failures.Add(failure); | |
373 } | |
374 } | |
375 } | |
376 | |
377 return failures; | |
378 } | |
379 | |
380 public List<FailedUnitRequirement> CanRemoveFromArmy(Army army) | |
381 { | |
382 List<FailedUnitRequirement> failures = new List<FailedUnitRequirement>(); | |
383 | |
82 | 384 if (requirements!=null && requirements.Count > 0) |
0 | 385 { |
386 foreach (UnitRequirement requirement in requirements) | |
387 { | |
388 FailedUnitRequirement failure = (FailedUnitRequirement)requirement.CanRemoveFromWarFoundryObject(army); | |
389 | |
390 if (failure!=null) | |
391 { | |
392 failures.Add(failure); | |
393 } | |
394 } | |
395 } | |
396 | |
397 return failures; | |
57
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
398 } |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
399 |
69
91cf8efbea0b
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
400 public string Notes |
57
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
401 { |
69
91cf8efbea0b
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
402 get { return notes; } |
91cf8efbea0b
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
403 set { notes = value; } |
57
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
404 } |
69
91cf8efbea0b
Re #50 - Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
405 |
61
3c77722a02b5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
57
diff
changeset
|
406 public bool CanContainUnit(Unit unit) |
3c77722a02b5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
57
diff
changeset
|
407 { |
3c77722a02b5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
57
diff
changeset
|
408 return CanContainUnitType(unit.UnitType); |
3c77722a02b5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
57
diff
changeset
|
409 } |
3c77722a02b5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
57
diff
changeset
|
410 |
3c77722a02b5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
57
diff
changeset
|
411 public bool CanContainUnitType(UnitType unitType) |
3c77722a02b5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
57
diff
changeset
|
412 { |
3c77722a02b5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
57
diff
changeset
|
413 return containedTypes.Contains(unitType); |
3c77722a02b5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
57
diff
changeset
|
414 } |
3c77722a02b5
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
57
diff
changeset
|
415 |
57
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
416 public UnitType[] ContainedUnitTypes |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
417 { |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
418 get { return containedTypes.ToArray(); } |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
419 } |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
420 |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
421 public void AddContainedUnitType(UnitType containedType) |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
422 { |
e0ce5578e7c2
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
56
diff
changeset
|
423 containedTypes.Add(containedType); |
66
d100ca4bd0c1
Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
424 } |
d100ca4bd0c1
Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
425 |
d100ca4bd0c1
Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
426 public void AddExtraData(string id, string data) |
d100ca4bd0c1
Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
427 { |
d100ca4bd0c1
Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
428 extraData[id] = data; |
d100ca4bd0c1
Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
429 } |
d100ca4bd0c1
Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
430 |
d100ca4bd0c1
Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
431 public string GetExtraData(string id) |
d100ca4bd0c1
Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
432 { |
d100ca4bd0c1
Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
433 return DictionaryUtils.GetValue(extraData, id); |
82 | 434 } |
131
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
435 |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
436 public string StatsID |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
437 { |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
438 get |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
439 { |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
440 return stats.StatsID; |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
441 } |
5145b7c61ae0
Re #68: Add "export army list" function
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
442 } |
82 | 443 } |
66
d100ca4bd0c1
Re #61 - Update classes to match schema
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
444 } |