Mercurial > repos > snowblizz-super-API-ideas
comparison api/Util/UnitEquipmentUtil.cs @ 190:6f67f16a67fb
Re #198: Add equipment slots
* Add method for getting min equipment percentage
* Remove percentage comparison between min and max limts
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 28 Oct 2009 20:52:10 +0000 |
parents | 0b413f41e6e3 |
children | 1412a42190a1 |
comparison
equal
deleted
inserted
replaced
189:0b413f41e6e3 | 190:6f67f16a67fb |
---|---|
152 } | 152 } |
153 else | 153 else |
154 { | 154 { |
155 if (equip.IsRatioLimit) | 155 if (equip.IsRatioLimit) |
156 { | 156 { |
157 limit = Math.Max(((IPercentageLimit)equip.MinLimit).Percentage, ((IPercentageLimit)equip.MaxLimit).Percentage); | 157 limit = ((IPercentageLimit)equip.MaxLimit).Percentage; |
158 } | 158 } |
159 else | 159 else |
160 { | 160 { |
161 int unitSize = unit.Size; | 161 int unitSize = unit.Size; |
162 limit = (equip.MaxLimit.GetLimit(unitSize) / (double)unitSize) * 100.0; | 162 limit = (equip.MaxLimit.GetLimit(unitSize) / (double)unitSize) * 100.0; |
168 } | 168 } |
169 } | 169 } |
170 | 170 |
171 return limit; | 171 return limit; |
172 } | 172 } |
173 | |
174 public static double GetMinEquipmentPercentage(Unit unit, UnitEquipmentItem equip) | |
175 { | |
176 double limit = 0; | |
177 AbstractLimit slotLimit = GetSlotLimitForItem(unit, equip); | |
178 | |
179 | |
180 if (!(slotLimit is IPercentageLimit || slotLimit is UnlimitedLimit) || unit.GetEquipmentAmountInSlot (equip.SlotName) != 0) | |
181 { | |
182 limit = (GetMinEquipmentCount(unit, equip) / (double)unit.Size) * 100.0; | |
183 } | |
184 else | |
185 { | |
186 if (equip.IsRatioLimit) | |
187 { | |
188 limit = ((IPercentageLimit)equip.MinLimit).Percentage; | |
189 } | |
190 else | |
191 { | |
192 int unitSize = unit.Size; | |
193 limit = (equip.MinLimit.GetLimit(unitSize) / (double)unitSize) * 100.0; | |
194 } | |
195 | |
196 if (slotLimit is IPercentageLimit) | |
197 { | |
198 limit = Math.Min(((IPercentageLimit)slotLimit).Percentage, limit); | |
199 } | |
200 } | |
201 | |
202 return limit; | |
203 } | |
173 } | 204 } |
174 } | 205 } |