MCPcopy Create free account
hub / github.com/PCGen/pcgen / apply

Method apply

code/src/java/pcgen/core/kit/KitGear.java:390–438  ·  view source on GitHub ↗
(PlayerCharacter aPC)

Source from the content-addressed store, hash-verified

388 }
389
390 @Override
391 public void apply(PlayerCharacter aPC)
392 {
393 final Equipment existing = aPC.getEquipmentNamed(theEquipment.getName());
394
395 if (existing == null)
396 {
397 theEquipment.setQty(Float.valueOf(theQty));
398
399 aPC.addEquipment(theEquipment);
400 Globals.getContext().getReferenceContext().importObject(theEquipment);
401 }
402 else
403 {
404 existing.setQty(existing.qty() + theQty);
405 }
406
407 // If the target is null, try and grab it incase it is there now
408 Equipment theTarget = null;
409 EquipSet eSet;
410 if (!theLocation.equalsIgnoreCase(Constants.EQUIP_LOCATION_CARRIED)
411 && !theLocation.equalsIgnoreCase(Constants.EQUIP_LOCATION_NOTCARRIED)
412 && !theLocation.equalsIgnoreCase(Constants.EQUIP_LOCATION_EQUIPPED))
413 {
414 theTarget = EquipmentUtilities.findEquipmentByBaseKey(aPC.getEquipmentMasterList(), theLocation);
415 if (theTarget == null)
416 {
417 theLocation = Constants.EQUIP_LOCATION_CARRIED;
418 }
419 }
420 if (theTarget == null)
421 {
422 eSet = aPC.getEquipSetByIdPath(EquipSet.DEFAULT_SET_PATH);
423 }
424 else
425 {
426 eSet = aPC.getEquipSetForItem(aPC.getEquipSetByIdPath(EquipSet.DEFAULT_SET_PATH), theTarget);
427 }
428
429 //
430 // Equip the item to the default EquipSet.
431 //
432 aPC.addEquipToTarget(eSet, theTarget, theLocation, theEquipment, (float) theQty);
433
434 BigDecimal currentGold = new BigDecimal(ChannelUtilities
435 .readControlledChannel(aPC.getCharID(), CControl.GOLDINPUT).toString());
436 ChannelUtilities.setControlledChannel(aPC.getCharID(),
437 CControl.GOLDINPUT, currentGold.subtract(theCost));
438 }
439
440 @Override
441 public String getObjectName()

Callers

nothing calls this directly

Calls 15

getContextMethod · 0.95
setQtyMethod · 0.95
qtyMethod · 0.95
readControlledChannelMethod · 0.95
setControlledChannelMethod · 0.95
getEquipmentNamedMethod · 0.80
importObjectMethod · 0.80
equalsIgnoreCaseMethod · 0.80
getEquipSetForItemMethod · 0.80
addEquipToTargetMethod · 0.80

Tested by

no test coverage detected