(final EquipSet eSet, final Equipment eqTarget, String locName, final Equipment eqI, Float newQty)
| 7245 | } |
| 7246 | |
| 7247 | public EquipSet addEquipToTarget(final EquipSet eSet, final Equipment eqTarget, String locName, final Equipment eqI, |
| 7248 | Float newQty) |
| 7249 | { |
| 7250 | float tempQty = 1.0f; |
| 7251 | if (newQty != null) |
| 7252 | { |
| 7253 | tempQty = newQty; |
| 7254 | } else |
| 7255 | { |
| 7256 | newQty = tempQty; |
| 7257 | } |
| 7258 | boolean addAll = false; |
| 7259 | boolean mergeItem = false; |
| 7260 | |
| 7261 | Equipment masterEq = getEquipmentNamed(eqI.getName()); |
| 7262 | if (masterEq == null) |
| 7263 | { |
| 7264 | return null; |
| 7265 | } |
| 7266 | float diffQty = masterEq.getQty() - getEquippedQty(eSet, eqI); |
| 7267 | |
| 7268 | // if newQty is less than zero, we want to |
| 7269 | // add all of this item to the EquipSet |
| 7270 | // or all remaining items that havn't already |
| 7271 | // been added to the EquipSet |
| 7272 | if (newQty < 0.0f) |
| 7273 | { |
| 7274 | tempQty = diffQty; |
| 7275 | newQty = tempQty + getEquippedQty(eSet, eqI); |
| 7276 | addAll = true; |
| 7277 | } |
| 7278 | |
| 7279 | // Check to make sure this EquipSet does not exceed |
| 7280 | // the PC's equipmentList number for this item |
| 7281 | if (tempQty > diffQty) |
| 7282 | { |
| 7283 | return null; |
| 7284 | } |
| 7285 | |
| 7286 | // check to see if the target item is a container |
| 7287 | if ((eqTarget != null) && eqTarget.isContainer()) |
| 7288 | { |
| 7289 | // set these to newQty just for testing |
| 7290 | eqI.setQty(newQty); |
| 7291 | eqI.setNumberCarried(newQty); |
| 7292 | |
| 7293 | // Make sure the container accepts items |
| 7294 | // of this type and is not full |
| 7295 | if (eqTarget.canContain(this, eqI) == 1) |
| 7296 | { |
| 7297 | locName = eqTarget.getName(); |
| 7298 | addAll = true; |
| 7299 | mergeItem = true; |
| 7300 | } else |
| 7301 | { |
| 7302 | return null; |
| 7303 | } |
| 7304 | } |
no test coverage detected