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

Method canEquip

code/src/java/pcgen/core/character/EquipSet.java:661–751  ·  view source on GitHub ↗
(PlayerCharacter theCharacter, EquipNode node,
		Equipment item)

Source from the content-addressed store, hash-verified

659 }
660
661 public boolean canEquip(PlayerCharacter theCharacter, EquipNode node,
662 Equipment item)
663 {
664 // Check for a required location (i.e. you can't carry a natural weapon)
665 EquipNode requiredLoc = getNatWeaponLoc(theCharacter, item);
666 if (requiredLoc != null)
667 {
668 return validLocationForNaturalWeapon(node, item, requiredLoc);
669 }
670
671 // Is this a container? Then check if the object can fit in
672 if (node.getNodeType() == EquipNode.NodeType.EQUIPMENT)
673 {
674 EquipmentFacade parent = node.getEquipment();
675 if ((parent instanceof Equipment) && ((Equipment) parent).isContainer())
676 {
677 // Check if it fits
678 if (((Equipment) parent).canContain(theCharacter, item) == 1)
679 {
680 return true;
681 }
682 }
683 }
684
685 if (node.getNodeType() == EquipNode.NodeType.PHANTOM_SLOT)
686 {
687 // Check first for an already full or taken slot
688 if (!getNodeList().containsElement(node))
689 {
690 return false;
691 }
692 EquipSlot slot = node.getSlot();
693 if (slot.canContainType(item.getType()))
694 {
695 if (item.isWeapon())
696 {
697 final String slotName = slot.getSlotName();
698
699 if (item.isUnarmed() && slotName.equals(Constants.EQUIP_LOCATION_UNARMED))
700 {
701 return true;
702 }
703 if (item.isShield() && slotName.equals(Constants.EQUIP_LOCATION_SHIELD))
704 {
705 return true;
706 }
707
708 // If it is outsized, they can't equip it to a weapon slot
709 if (item.isWeaponOutsizedForPC(theCharacter))
710 {
711 return false;
712 }
713
714 if (slotName.startsWith(Constants.EQUIP_LOCATION_BOTH))
715 {
716 return true;
717 }
718 if (item.isMelee() && item.isDouble() && slotName.equals(Constants.EQUIP_LOCATION_DOUBLE))

Callers

nothing calls this directly

Calls 15

getNatWeaponLocMethod · 0.95
getNodeListMethod · 0.95
canContainTypeMethod · 0.95
getSlotNameMethod · 0.95
isHoldsAnyTypeMethod · 0.95
isForbiddenMethod · 0.95
canContainMethod · 0.80
isUnarmedMethod · 0.80
isShieldMethod · 0.80
isWeaponOutsizedForPCMethod · 0.80
isMeleeMethod · 0.80

Tested by

no test coverage detected