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

Method equipItem

code/src/java/pcgen/core/character/EquipSet.java:477–560  ·  view source on GitHub ↗

Apply this EquipSet to a PlayerCharacter object. @param aPC the PC to equip the item on

(PlayerCharacter aPC)

Source from the content-addressed store, hash-verified

475 * @param aPC the PC to equip the item on
476 */
477 public void equipItem(PlayerCharacter aPC)
478 {
479 final StringTokenizer aTok = new StringTokenizer(getIdPath(), Constants.EQUIP_SET_PATH_SEPARATOR);
480
481 // if the eSet.getIdPath() is longer than 3
482 // it's inside a container, don't try to equip
483 if (aTok.countTokens() > Constants.ID_PATH_LENGTH_FOR_NON_CONTAINED)
484 {
485 // Get back to carried/equipped/not carried to determine correct location
486 StringBuilder rootPath = new StringBuilder(40);
487 for (int i = 0; i < Constants.ID_PATH_LENGTH_FOR_NON_CONTAINED; i++)
488 {
489 if (i > 0)
490 {
491 rootPath.append(".");
492 }
493 rootPath.append(aTok.nextToken());
494 }
495 EquipSet rootSet = aPC.getEquipSetByIdPath(rootPath.toString());
496 if (rootSet != null && rootSet.name.startsWith(Constants.EQUIP_LOCATION_CARRIED))
497 {
498 eq_item.addEquipmentToLocation(qty, EquipmentLocation.CARRIED_NEITHER, false, aPC);
499 }
500 else if (rootSet != null && rootSet.name.startsWith(Constants.EQUIP_LOCATION_NOTCARRIED))
501 {
502 eq_item.addEquipmentToLocation(qty, EquipmentLocation.NOT_CARRIED, false, aPC);
503 }
504 else if (rootSet != null && rootSet.name.startsWith(Constants.EQUIP_LOCATION_EQUIPPED))
505 {
506 eq_item.addEquipmentToLocation(qty, EquipmentLocation.EQUIPPED_NEITHER, false, aPC);
507 }
508 else
509 {
510 eq_item.addEquipmentToLocation(qty, EquipmentLocation.CONTAINED, false, aPC);
511 }
512 }
513 else if (name.startsWith(Constants.EQUIP_LOCATION_CARRIED))
514 {
515 eq_item.addEquipmentToLocation(qty, EquipmentLocation.CARRIED_NEITHER, false, aPC);
516 }
517 else if (name.startsWith(Constants.EQUIP_LOCATION_NOTCARRIED))
518 {
519 eq_item.addEquipmentToLocation(qty, EquipmentLocation.NOT_CARRIED, false, aPC);
520 }
521 else if (eq_item.isWeapon())
522 {
523 if (name.equals(Constants.EQUIP_LOCATION_PRIMARY) || name.equals(Constants.EQUIP_LOCATION_NATURAL_PRIMARY))
524 {
525 eq_item.addWeaponToLocation(qty, EquipmentLocation.EQUIPPED_PRIMARY, aPC);
526 }
527 else if (name.startsWith(Constants.EQUIP_LOCATION_SECONDARY)
528 || name.equals(Constants.EQUIP_LOCATION_NATURAL_SECONDARY))
529 {
530 eq_item.addWeaponToLocation(qty, EquipmentLocation.EQUIPPED_SECONDARY, aPC);
531 }
532 else if (name.equals(Constants.EQUIP_LOCATION_BOTH))
533 {
534 eq_item.addWeaponToLocation(qty, EquipmentLocation.EQUIPPED_BOTH, aPC);

Callers 2

setCalcEquipmentListMethod · 0.45

Calls 11

getIdPathMethod · 0.95
setQtyMethod · 0.95
nextTokenMethod · 0.80
addWeaponToLocationMethod · 0.80
doubleValueMethod · 0.80
toStringMethod · 0.65
isWeaponMethod · 0.65
equalsMethod · 0.65
appendMethod · 0.45
getEquipSetByIdPathMethod · 0.45

Tested by 1