Mercurial > repos > IBDev-IBBoard.WarFoundry.API
annotate api/Objects/Race.cs @ 15:306558904c2a
Re #1 - LGPL license all code
* Add LGPL header to all files
* Add COPYING.LGPL and COPYING.GPL with content of license
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 25 Jan 2009 14:50:36 +0000 |
parents | 0770e5cbba7c |
children | 85f2b9c3609c |
rev | line source |
---|---|
15 | 1 // This file (Race.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard. |
0 | 2 // |
15 | 3 // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license. |
0 | 4 |
5 using System; | |
6 using System.Collections.Generic; | |
7 using System.IO; | |
8 using System.Xml; | |
9 using IBBoard.IO; | |
10 using IBBoard.WarFoundry.API.Factories; | |
11 | |
12 namespace IBBoard.WarFoundry.API.Objects | |
13 { | |
8
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
14 public class Race : WarFoundryStagedLoadingObject |
0 | 15 { |
16 public static string SYSTEM_DEFAULT_RACE_ID = "GameDefault"; | |
17 | |
18 private string subID; | |
19 private string systemID; | |
20 private GameSystem system; | |
21 private Dictionary<Category, Dictionary<string, UnitType>> unitTypesByCat; | |
8
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
22 private Dictionary<string, UnitType> unitTypes = new Dictionary<string,UnitType>(); |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
23 private Dictionary<string, EquipmentItem> equipment = new Dictionary<string,EquipmentItem>(); |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
24 private Dictionary<string, Ability> abilities = new Dictionary<string,Ability>(); |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
25 private Dictionary<string, Category> categories = new Dictionary<string,Category>(); |
0 | 26 |
8
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
27 public Race(string raceID, string raceName, string gameSystemID, IWarFoundryFactory creatingFactory) : this(raceID, "", raceName, gameSystemID, creatingFactory) |
0 | 28 { |
29 } | |
30 | |
8
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
31 public Race(string raceID, string raceSubID, string raceName, string gameSystemID, IWarFoundryFactory creatingFactory) : base(raceID + (raceSubID!="" ? "_"+raceSubID : ""), raceName, creatingFactory) |
0 | 32 { |
33 subID = (raceSubID == null ? "" : raceSubID); | |
34 systemID = gameSystemID; | |
35 } | |
36 | |
37 public string SubID | |
38 { | |
39 get { return subID; } | |
40 set { subID = (value == null ? "" : value.Trim()); } | |
41 } | |
42 | |
43 public GameSystem GameSystem | |
44 { | |
45 get | |
46 { | |
47 if (system == null) | |
48 { | |
49 system = WarFoundryLoader.GetDefault().GetGameSystem(systemID); | |
50 } | |
51 | |
52 return system; | |
53 } | |
54 set | |
55 { | |
56 if (value == null) | |
57 { | |
58 throw new ArgumentException("Game system for a race cannot be null"); | |
59 } | |
60 | |
61 system = value; | |
62 } | |
8
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
63 } |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
64 |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
65 public void AddCategory(Category cat) |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
66 { |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
67 categories[cat.ID] = cat; |
0 | 68 } |
69 | |
70 /// <summary> | |
71 /// Gets a category from its ID. Attempts to get the category from the race's overrides, or else it falls back to getting the Game System's category with that ID. | |
72 /// </summary> | |
73 /// <param name="id"> | |
74 /// The ID of the category to get | |
75 /// </param> | |
76 /// <returns> | |
77 /// The <code>Category</code> with the specified ID, or null if one doesn't exist. | |
78 /// </returns> | |
79 public Category GetCategory(string id) | |
80 { | |
8
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
81 EnsureFullyLoaded(); |
0 | 82 Category cat = null; |
8
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
83 categories.TryGetValue(id, out cat); |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
84 |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
85 if (cat == null) |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
86 { |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
87 cat = GameSystem.GetCategory(id); |
0 | 88 } |
8
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
89 |
0 | 90 return cat; |
91 } | |
92 | |
93 public Category[] Categories | |
94 { | |
95 get | |
8
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
96 { |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
97 EnsureFullyLoaded(); |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
98 Category[] cats; |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
99 |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
100 if (!HasCategoryOverrides()) |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
101 { |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
102 cats = GameSystem.Categories; |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
103 } |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
104 else |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
105 { |
14
0770e5cbba7c
Closes #21 - File loading in order
IBBoard <dev@ibboard.co.uk>
parents:
13
diff
changeset
|
106 cats = DictionaryUtils.ToArray<string, Category>(categories); |
8
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
107 } |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
108 |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
109 return cats; |
0 | 110 } |
8
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
111 } |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
112 |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
113 public bool HasCategoryOverrides() |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
114 { |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
115 return categories.Count > 0; |
0 | 116 } |
11
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
117 |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
118 public void AddEquipmentItem(EquipmentItem item) |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
119 { |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
120 //TODO: Throw DuplicateItemException |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
121 equipment.Add(item.ID, item); |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
122 } |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
123 |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
124 [Obsolete("Use AddEquipmentItem method instead")] |
0 | 125 public void SetEquipmentItems(Dictionary<string, EquipmentItem> items) |
126 { | |
11
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
127 foreach (EquipmentItem item in items.Values) |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
128 { |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
129 AddEquipmentItem(item); |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
130 } |
0 | 131 } |
132 | |
8
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
133 public EquipmentItem GetEquipmentItem(string id) |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
134 { |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
135 EnsureFullyLoaded(); |
0 | 136 return (EquipmentItem)equipment[id]; |
137 } | |
138 | |
139 public List<EquipmentItem> GetEquipmentList() | |
140 { | |
141 List<EquipmentItem> items = new List<EquipmentItem>(); | |
142 | |
143 foreach (EquipmentItem item in equipment.Values) | |
144 { | |
145 items.Add(item); | |
146 } | |
147 | |
148 return items; | |
149 } | |
11
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
150 |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
151 public void AddUnitType(UnitType type) |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
152 { |
13 | 153 CacheUnitType(type); |
11
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
154 unitTypes.Add(type.ID, type); |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
155 } |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
156 |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
157 [Obsolete("Use AddUnitType method instead")] |
0 | 158 public void SetUnitTypes(Dictionary<string, UnitType> types) |
159 { | |
11
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
160 foreach (UnitType type in types.Values) |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
161 { |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
162 AddUnitType(type); |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
163 } |
0 | 164 } |
165 | |
166 public UnitType[] GetUnitTypes(Category cat) | |
11
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
167 { |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
168 BuildUnitTypesByCategoryCache(); |
8
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
169 Dictionary<string, UnitType> unitTypesDictionary; |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
170 unitTypesByCat.TryGetValue(cat, out unitTypesDictionary); |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
171 UnitType[] unitTypesArray; |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
172 |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
173 if (unitTypesDictionary == null) |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
174 { |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
175 unitTypesArray = new UnitType[0]; |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
176 } |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
177 else |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
178 { |
14
0770e5cbba7c
Closes #21 - File loading in order
IBBoard <dev@ibboard.co.uk>
parents:
13
diff
changeset
|
179 unitTypesArray = DictionaryUtils.ToArray<string, UnitType>(unitTypesDictionary); |
8
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
180 } |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
181 |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
182 return unitTypesArray; |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
183 } |
11
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
184 |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
185 private void CacheUnitType(UnitType unit) |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
186 { |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
187 BuildUnitTypesByCategoryCache(); |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
188 Dictionary<string,UnitType> catUnitTypes; |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
189 unitTypesByCat.TryGetValue(unit.MainCategory, out catUnitTypes); |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
190 |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
191 if (catUnitTypes == null) |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
192 { |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
193 throw new InvalidFileException(String.Format("Unit type {0} with name {1} is a unit of an undefined category", unit.ID, unit.Name)); |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
194 } |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
195 |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
196 catUnitTypes.Add(unit.ID, unit); |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
197 } |
8
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
198 |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
199 private void BuildUnitTypesByCategoryCache() |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
200 { |
11
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
201 if (unitTypesByCat == null) |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
202 { |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
203 DoBuildUnitTypesByCategoryCache(); |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
204 } |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
205 } |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
206 |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
207 private void DoBuildUnitTypesByCategoryCache() |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
208 { |
8
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
209 unitTypesByCat = new Dictionary<Category,Dictionary<string,UnitType>>(); |
0 | 210 |
11
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
211 foreach (Category category in Categories) |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
212 { |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
213 unitTypesByCat.Add(category, new Dictionary<string, UnitType>()); |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
214 } |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
215 |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
216 foreach (UnitType unit in unitTypes.Values) |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
217 { |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
218 CacheUnitType(unit); |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
219 } |
0 | 220 } |
221 | |
222 public UnitType GetUnitType(string id) | |
11
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
223 { |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
224 UnitType type = null; |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
225 unitTypes.TryGetValue(id, out type); |
5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
IBBoard <dev@ibboard.co.uk>
parents:
8
diff
changeset
|
226 return type; |
0 | 227 } |
228 | |
229 public List<Ability> GetAbilityList() | |
230 { | |
231 List<Ability> items = new List<Ability>(); | |
232 | |
233 foreach (Ability ability in abilities.Values) | |
234 { | |
235 items.Add(ability); | |
236 } | |
237 | |
238 return items; | |
239 } | |
240 | |
241 public void SetAbilities(Dictionary<string, Ability> newAbilities) | |
242 { | |
243 abilities = newAbilities; | |
244 } | |
245 | |
246 public Ability GetAbility(string id) | |
247 { | |
248 Ability ability = null; | |
249 abilities.TryGetValue(id, out ability); | |
250 return ability; | |
251 } | |
252 | |
253 protected virtual Dictionary<string, UnitType> RaceUnitTypes | |
254 { | |
255 get { return RaceRawUnitTypes; } | |
256 set { RaceRawUnitTypes = value; } | |
257 } | |
258 | |
259 protected virtual Dictionary<string, EquipmentItem> RaceEquipment | |
260 { | |
261 get { return RaceRawEquipment; } | |
262 set { RaceRawEquipment = value; } | |
263 } | |
264 | |
265 protected virtual Dictionary<string, Ability> RaceAbilities | |
266 { | |
267 get { return RaceRawAbilities; } | |
268 set { RaceRawAbilities = value; } | |
269 } | |
270 | |
271 protected Dictionary<string, UnitType> RaceRawUnitTypes | |
272 { | |
273 get { return unitTypes; } | |
274 set { unitTypes = value; } | |
275 } | |
276 | |
277 protected Dictionary<string, EquipmentItem> RaceRawEquipment | |
278 { | |
279 get { return equipment; } | |
280 set { equipment = value; } | |
281 } | |
282 | |
283 protected Dictionary<string, Ability> RaceRawAbilities | |
284 { | |
285 get { return abilities; } | |
286 set { abilities = value; } | |
287 } | |
288 } | |
289 } |