annotate api/Objects/GameSystem.cs @ 392:db6713d5b35f default-army-size

RRe #97: Default army size issues
author snowblizz
date Wed, 01 Dec 2010 20:00:58 +0000
parents d576034ad1dd
children b90db11edc64
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
392
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
1 // This file (GameSystem.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2007, 2008, 2009 IBBoard.
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
2 //
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
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.
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
4
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
5 using System;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
6 using System.Collections.Generic;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
7 using System.Xml;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
8 using System.IO;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
9 using IBBoard.Logging;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
10 using IBBoard.WarFoundry.API.Factories;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
11 using ICSharpCode.SharpZipLib.Zip;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
12
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
13 namespace IBBoard.WarFoundry.API.Objects
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
14 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
15 /// <summary>
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
16 /// Summary description for GameSystem.
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
17 /// </summary>
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
18 public class GameSystem : WarFoundryStagedLoadingObject
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
19 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
20
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
21 private bool warnOnError;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
22 private bool allowAllies;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
23 private Dictionary<string, Category> categories = new Dictionary<string,Category>();
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
24 private Dictionary<string, SystemStats> stats = new Dictionary<string,SystemStats>();
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
25 private string defaultStats;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
26 private int defaultArmySize;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
27
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
28 public GameSystem(string systemID, string systemName, IWarFoundryFactory creatingFactory)
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
29 : base(systemID, systemName, creatingFactory)
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
30 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
31 stats = new Dictionary<string,SystemStats>();
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
32 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
33
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
34 public int SystemArmyDefaultSize
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
35 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
36 get { return defaultArmySize; }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
37 set
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
38 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
39 if (value == 0)
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
40 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
41 defaultArmySize = 1;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
42 throw new ArgumentException("No default system army size");
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
43
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
44 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
45
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
46 defaultArmySize = value;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
47 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
48 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
49
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
50 public bool AllowAllies
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
51 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
52 get { return allowAllies; }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
53 set { allowAllies = value; }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
54 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
55
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
56 public void AddCategory(Category cat)
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
57 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
58 RawCategories[cat.ID] = cat;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
59 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
60
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
61 public Category GetCategory(string id)
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
62 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
63 EnsureFullyLoaded();
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
64 Category cat = null;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
65 RawCategories.TryGetValue(id, out cat);
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
66 return cat;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
67 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
68
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
69 public Category[] Categories
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
70 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
71 get
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
72 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
73 EnsureFullyLoaded();
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
74 return DictionaryUtils.ToArray<string, Category>(RawCategories);
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
75 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
76 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
77
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
78 protected Dictionary<string, Category> RawCategories
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
79 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
80 get { return categories; }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
81 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
82
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
83 public bool WarnOnError
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
84 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
85 get
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
86 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
87 return warnOnError;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
88 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
89 set { warnOnError = value; }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
90 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
91
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
92 public void AddSystemStats(SystemStats sysStats)
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
93 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
94 stats[sysStats.ID] = sysStats;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
95 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
96
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
97 public SystemStats StandardSystemStats
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
98 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
99 get
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
100 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
101 EnsureFullyLoaded();
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
102 return stats[defaultStats];
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
103 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
104 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
105
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
106 public string StandardSystemStatsID
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
107 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
108 get
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
109 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
110 EnsureFullyLoaded();
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
111 return defaultStats;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
112 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
113
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
114 set
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
115 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
116 if (value != null && value.Trim().Length > 0)
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
117 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
118 defaultStats = value;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
119 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
120 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
121 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
122
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
123 public SystemStats[] SystemStats
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
124 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
125 get
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
126 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
127 EnsureFullyLoaded();
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
128 SystemStats[] statsArray = new SystemStats[stats.Count];
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
129 stats.Values.CopyTo(statsArray, 0);
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
130 return statsArray;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
131 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
132 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
133
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
134 public SystemStats GetSystemStatsForID(string id)
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
135 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
136 EnsureFullyLoaded();
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
137 SystemStats statsForID;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
138 stats.TryGetValue(id, out statsForID);
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
139 return statsForID;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
140 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
141
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
142 public Race SystemDefaultRace
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
143 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
144 get { return WarFoundryLoader.GetDefault().GetRace(this, Race.SYSTEM_DEFAULT_RACE_ID); }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
145 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
146
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
147 public bool Matches(GameSystem otherSystem)
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
148 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
149 if (otherSystem==null)
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
150 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
151 return false;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
152 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
153
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
154 return this.ID == otherSystem.ID;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
155 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
156
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
157 public override bool Equals(object obj)
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
158 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
159 if (obj == null)
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
160 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
161 return false;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
162 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
163
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
164 if (obj.GetType().Equals(this.GetType()))
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
165 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
166 GameSystem otherSystem = (GameSystem)obj;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
167
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
168 return this.ID == otherSystem.ID && this.Name == otherSystem.Name && ((this.RawCategories == null && otherSystem.RawCategories == null) || this.RawCategories.Equals(otherSystem.RawCategories));
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
169 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
170 else
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
171 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
172 return false;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
173 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
174 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
175
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
176 public override int GetHashCode()
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
177 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
178 return ID.GetHashCode() + Name.GetHashCode() + (RawCategories!=null ? RawCategories.GetHashCode() : 0) + warnOnError.GetHashCode();
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
179 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
180
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
181 public bool UnitTypeMaxed(UnitType unitType, Army army)
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
182 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
183 return unitType.MaxNumber!=WarFoundryCore.INFINITY && army.GetUnitTypeCount(unitType) >= unitType.MaxNumber;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
184 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
185
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
186 public bool UnitTypeMinned(UnitType unitType, Army army)
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
187 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
188 return army.GetUnitTypeCount(unitType) <= unitType.MinNumber;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
189 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
190
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
191 public List<EquipmentItem> GetSystemEquipmentList()
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
192 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
193 List<EquipmentItem> items = new List<EquipmentItem>();
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
194 Race defaultRace = SystemDefaultRace;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
195
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
196 if (defaultRace!=null)
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
197 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
198 items = defaultRace.GetEquipmentList();
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
199 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
200
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
201 return items;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
202 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
203
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
204 public EquipmentItem GetSystemEquipmentItem(string id)
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
205 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
206 EquipmentItem item = null;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
207 Race defaultRace = SystemDefaultRace;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
208
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
209 if (defaultRace!=null)
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
210 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
211 item = defaultRace.GetEquipmentItem(id);
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
212 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
213
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
214 return item;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
215 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
216
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
217 public UnitType[] GetSystemUnitTypes(Category cat)
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
218 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
219 UnitType[] items = new UnitType[0];
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
220 Race defaultRace = SystemDefaultRace;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
221
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
222 if (defaultRace!=null)
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
223 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
224 items = defaultRace.GetUnitTypes(cat);
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
225 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
226
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
227 return items;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
228 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
229
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
230 public UnitType GetSystemUnitType(string id)
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
231 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
232 UnitType unit = null;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
233 Race defaultRace = SystemDefaultRace;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
234
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
235 if (defaultRace!=null)
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
236 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
237 unit = defaultRace.GetUnitType(id);
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
238 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
239
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
240 return unit;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
241 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
242
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
243 public List<Ability> GetSystemAbilityList()
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
244 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
245 List<Ability> items = new List<Ability>();
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
246 Race defaultRace = SystemDefaultRace;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
247
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
248 if (defaultRace!=null)
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
249 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
250 items = defaultRace.GetAbilityList();
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
251 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
252
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
253 return items;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
254 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
255
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
256 public Ability GetSystemAbility(string id)
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
257 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
258 Ability ability = null;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
259 Race defaultRace = SystemDefaultRace;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
260
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
261 if (defaultRace!=null)
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
262 {
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
263 ability = defaultRace.GetAbility(id);
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
264 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
265
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
266 return ability;
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
267 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
268 }
db6713d5b35f RRe #97: Default army size issues
snowblizz
parents: 276
diff changeset
269 }