comparison api/Factories/Xml/WarFoundryXmlRaceFactory.cs @ 55:9080366031c0

Re #9 - Refactor for small methods * Replace use of obsolete constructors with small constructors and property setting
author IBBoard <dev@ibboard.co.uk>
date Sun, 05 Apr 2009 19:21:51 +0000
parents 1b35eed503ef
children e6200220ece3
comparison
equal deleted inserted replaced
54:3a90f70dac73 55:9080366031c0
42 { 42 {
43 string id = elem.GetAttribute("id"); 43 string id = elem.GetAttribute("id");
44 string subid = elem.GetAttribute("subid"); 44 string subid = elem.GetAttribute("subid");
45 string systemID = elem.GetAttribute("system"); 45 string systemID = elem.GetAttribute("system");
46 string name = elem.GetAttribute("name"); 46 string name = elem.GetAttribute("name");
47 Race race = new Race(id, subid, name, systemID, mainFactory); 47 Race race = new Race(id, subid, name, WarFoundryLoader.GetDefault().GetGameSystem(systemID), mainFactory);
48 StoreExtraData(race, elem); 48 StoreExtraData(race, elem);
49 return race; 49 return race;
50 } 50 }
51 51
52 public void CompleteLoading(Race race) 52 public void CompleteLoading(Race race)
153 153
154 private EquipmentItem CreateEquipmentItemFromElement(XmlElement elem, Race race) 154 private EquipmentItem CreateEquipmentItemFromElement(XmlElement elem, Race race)
155 { 155 {
156 string id = elem.GetAttribute("id"); 156 string id = elem.GetAttribute("id");
157 string name = elem.GetAttribute("name"); 157 string name = elem.GetAttribute("name");
158 double cost = 0, min = 0, max = 0; 158 double cost = 0;
159 ArmourType armourType; 159 ArmourType armourType;
160 160
161 try 161 try
162 { 162 {
163 cost = XmlTools.GetDoubleValueFromAttribute(elem, "cost"); 163 cost = XmlTools.GetDoubleValueFromAttribute(elem, "cost");
175 { 175 {
176 throw new InvalidFileException("Attribute 'armourType' of equipment "+id+" was not a valid value from the enumeration", ex); 176 throw new InvalidFileException("Attribute 'armourType' of equipment "+id+" was not a valid value from the enumeration", ex);
177 } 177 }
178 178
179 //TODO: Parse equipment stats if there are any 179 //TODO: Parse equipment stats if there are any
180 EquipmentItem item = new EquipmentItem(id, name, race);
181 item.Cost = cost;
182 item.ItemArmourType = armourType;
180 183
181 return new EquipmentItem(id, name, cost, min, max, armourType, race); 184 return item;
182 } 185 }
183 186
184 private Ability CreateAbilityFromElement(XmlElement elem, Race race) 187 private Ability CreateAbilityFromElement(XmlElement elem, Race race)
185 { 188 {
186 string id = elem.GetAttribute("id"); 189 string id = elem.GetAttribute("id");