comparison api/Objects/Unit.cs @ 158:eb9a6d91a6db

Fixes #190: Mutex groups aren't honoured when adding equipment * Make "get additional equipment" method check mutex groups Also: * Line ending cleanup
author IBBoard <dev@ibboard.co.uk>
date Tue, 29 Sep 2009 19:50:46 +0000
parents 4a02c07278e7
children 81abc04b3dbe
comparison
equal deleted inserted replaced
157:6ff68daab5dc 158:eb9a6d91a6db
218 } 218 }
219 } 219 }
220 } 220 }
221 } 221 }
222 222
223 public UnitEquipmentItem[] GetAllowedOptionalEquipment() 223 public UnitEquipmentItem[] GetAllowedAdditionalEquipment()
224 { 224 {
225 List<UnitEquipmentItem> list = new List<UnitEquipmentItem>(); 225 List<UnitEquipmentItem> list = new List<UnitEquipmentItem>();
226 List<string> existingMutexGroups = new List<string>();
227
228 foreach (UnitEquipmentItem item in GetEquipment())
229 {
230 foreach (string mutex in item.MutexGroups)
231 {
232 existingMutexGroups.Add(mutex);
233 }
234 }
226 235
227 foreach (UnitEquipmentItem item in UnitType.GetEquipmentItems()) 236 foreach (UnitEquipmentItem item in UnitType.GetEquipmentItems())
228 { 237 {
229 if (!item.IsRequired) 238 bool mutexMatch = false;
239
240 foreach (string mutex in item.MutexGroups)
241 {
242 if (existingMutexGroups.Contains(mutex))
243 {
244 mutexMatch = true;
245 break;
246 }
247 }
248
249 if (!mutexMatch)
230 { 250 {
231 list.Add(item); 251 list.Add(item);
232 } 252 }
233 } 253 }
234 254