comparison api/Util/UnitEquipmentUtil.cs @ 196:4bbf5624ced6

* Only check current amount of equipment when the slot isn't unlimited (needs unit test writing) no-open-ticket
author IBBoard <dev@ibboard.co.uk>
date Fri, 30 Oct 2009 20:58:19 +0000
parents 1412a42190a1
children 4d7ff70bb109
comparison
equal deleted inserted replaced
195:11bad32cfa06 196:4bbf5624ced6
142 142
143 public static double GetMaxEquipmentPercentage(Unit unit, UnitEquipmentItem equip) 143 public static double GetMaxEquipmentPercentage(Unit unit, UnitEquipmentItem equip)
144 { 144 {
145 double limit = 0; 145 double limit = 0;
146 AbstractLimit slotLimit = GetSlotLimitForItem(unit, equip); 146 AbstractLimit slotLimit = GetSlotLimitForItem(unit, equip);
147 147
148 148
149 if (!(slotLimit is IPercentageLimit || slotLimit is UnlimitedLimit) || unit.GetEquipmentAmountInSlot (equip.SlotName) != 0) 149 if (!(slotLimit is IPercentageLimit || slotLimit is UnlimitedLimit) || (!(slotLimit is UnlimitedLimit) && unit.GetEquipmentAmountInSlotWithoutItem(equip) != 0))
150 { 150 {
151 limit = (GetMaxEquipmentCount(unit, equip) / (double)unit.Size) * 100.0; 151 limit = (GetMaxEquipmentCount(unit, equip) / (double)unit.Size) * 100.0;
152 } 152 }
153 else 153 else
154 { 154 {
175 { 175 {
176 double limit = 0; 176 double limit = 0;
177 AbstractLimit slotLimit = GetSlotLimitForItem(unit, equip); 177 AbstractLimit slotLimit = GetSlotLimitForItem(unit, equip);
178 178
179 179
180 if (!(slotLimit is IPercentageLimit || slotLimit is UnlimitedLimit) || unit.GetEquipmentAmountInSlot (equip.SlotName) != 0) 180 if (!(slotLimit is IPercentageLimit || slotLimit is UnlimitedLimit) || (!(slotLimit is UnlimitedLimit) && unit.GetEquipmentAmountInSlotWithoutItem(equip) != 0))
181 { 181 {
182 limit = (GetMinEquipmentCount(unit, equip) / (double)unit.Size) * 100.0; 182 limit = (GetMinEquipmentCount(unit, equip) / (double)unit.Size) * 100.0;
183 } 183 }
184 else 184 else
185 { 185 {