Search in sources :

Example 6 with EquipmentFacade

use of pcgen.facade.core.EquipmentFacade in project pcgen by PCGen.

the class UnequippedList method elementRemoved.

@Override
public void elementRemoved(ListEvent<EquipmentFacade> e) {
    EquipmentFacade equipment = e.getElement();
    if (e.getSource() == purchasedList) {
        removeEquipment(equipment);
        // We remember this item has been removed as we could be getting a 
        // message to say it has been unequipped shortly.
        lastRemoved = equipment;
    } else {
        if (equipment.equals(lastRemoved)) {
            if (Logging.isDebugMode()) {
                Logging.debugPrint("Ignoring unequip of item just removed: " + equipment);
            }
            return;
        }
        int quantity = purchasedList.getQuantity(equipment) - equippedList.getQuantity(equipment);
        if (quantityMap.containsKey(equipment)) {
            setQuantity(equipment, quantity);
        } else {
            addEquipment(equipment, quantity);
        }
    }
}
Also used : EquipmentFacade(pcgen.facade.core.EquipmentFacade)

Example 7 with EquipmentFacade

use of pcgen.facade.core.EquipmentFacade in project pcgen by PCGen.

the class EquipmentSetFacadeImpl method quantityChanged.

@Override
public void quantityChanged(EquipmentListEvent e) {
    EquipmentFacade equipmentFacade = e.getEquipment();
    if (equippedItemsList.containsElement(equipmentFacade)) {
        int quantity = purchasedList.getQuantity(equipmentFacade) - equippedItemsList.getQuantity(equipmentFacade);
        if (quantity < 0) {
            if (Logging.isDebugMode()) {
                Logging.debugPrint("Currently equipped item " + equipmentFacade + " is being partially removed " + quantity + " from " + equippedItemsList.getQuantity(equipmentFacade));
            }
            int numStillToRemove = -1 * quantity;
            List<EquipNodeImpl> affectedList = findEquipmentNodes(equipmentFacade);
            // TODO: Custom sort order
            affectedList.sort(new EquipLocImportantComparator());
            for (EquipNodeImpl equipNode : affectedList) {
                EquipSet eSet = charDisplay.getEquipSetByIdPath(equipNode.getIdPath());
                if (eSet != null) {
                    int numToRemove = Math.min(eSet.getQty().intValue(), numStillToRemove);
                    removeEquipment(equipNode, numToRemove);
                    numStillToRemove -= numToRemove;
                }
                if (numStillToRemove <= 0) {
                    return;
                }
            }
        }
    }
}
Also used : EquipmentFacade(pcgen.facade.core.EquipmentFacade) EquipSet(pcgen.core.character.EquipSet)

Example 8 with EquipmentFacade

use of pcgen.facade.core.EquipmentFacade in project pcgen by PCGen.

the class EquipmentSetFacadeImpl method canEquip.

/**
	 * @see pcgen.core.facade.EquipmentSetFacade#canEquip(pcgen.core.facade.EquipmentSetFacade.EquipNode, pcgen.core.facade.EquipmentFacade)
	 */
@Override
public boolean canEquip(EquipNode node, EquipmentFacade equipment) {
    if (!(equipment instanceof Equipment) || (node == null)) {
        return false;
    }
    Equipment item = (Equipment) equipment;
    // Check for a required location (i.e. you can't carry a natural weapon)
    EquipNode requiredLoc = getNaturalWeaponLoc(equipment);
    if (requiredLoc != null) {
        return validLocationForNaturalWeapon(node, item, requiredLoc);
    }
    // Is this a container? Then check if the object can fit in
    if (node.getNodeType() == NodeType.EQUIPMENT) {
        EquipmentFacade parent = node.getEquipment();
        if ((parent instanceof Equipment) && ((Equipment) parent).isContainer()) {
            // Check if it fits
            if (((Equipment) parent).canContain(theCharacter, item) == 1) {
                return true;
            }
        }
    }
    if (node.getNodeType() == NodeType.PHANTOM_SLOT) {
        // Check first for an already full or taken slot
        if (!getNodes().containsElement(node)) {
            return false;
        }
        EquipSlot slot = ((EquipNodeImpl) node).getSlot();
        if (slot.canContainType(item.getType())) {
            if (item.isWeapon()) {
                final String slotName = slot.getSlotName();
                if (item.isUnarmed() && slotName.equals(Constants.EQUIP_LOCATION_UNARMED)) {
                    return true;
                }
                if (item.isShield() && slotName.equals(Constants.EQUIP_LOCATION_SHIELD)) {
                    return true;
                }
                // If it is outsized, they can't equip it to a weapon slot
                if (item.isWeaponOutsizedForPC(theCharacter)) {
                    return false;
                }
                if (slotName.startsWith(Constants.EQUIP_LOCATION_BOTH)) {
                    return true;
                }
                if (item.isMelee() && item.isDouble() && slotName.equals(Constants.EQUIP_LOCATION_DOUBLE)) {
                    return true;
                }
                if (item.isWeaponOneHanded(theCharacter)) {
                    if (slotName.equals(Constants.EQUIP_LOCATION_PRIMARY) || slotName.startsWith(Constants.EQUIP_LOCATION_SECONDARY)) {
                        return true;
                    }
                }
            } else {
                return true;
            }
        }
    }
    // Is this a body structure? Then check if the object be placed there
    if (node.getNodeType() == NodeType.BODY_SLOT) {
        BodyStructure root = (BodyStructure) node.getBodyStructure();
        if (root.isHoldsAnyType()) {
            return !root.isForbidden(item.getTrueTypeList(false));
        }
    }
    // This item can't be equipped in this location
    return false;
}
Also used : EquipmentFacade(pcgen.facade.core.EquipmentFacade) EquipSlot(pcgen.core.character.EquipSlot) Equipment(pcgen.core.Equipment) BodyStructure(pcgen.core.BodyStructure)

Example 9 with EquipmentFacade

use of pcgen.facade.core.EquipmentFacade in project pcgen by PCGen.

the class Gui2InfoFactory method getHTMLInfo.

@Override
public String getHTMLInfo(InfoFacade facade) {
    if (facade == null) {
        return EMPTY_STRING;
    }
    // Use a more detailed info if we can
    if (facade instanceof AbilityFacade) {
        return getHTMLInfo((AbilityFacade) facade);
    }
    if (facade instanceof ClassFacade) {
        return getHTMLInfo((ClassFacade) facade, null);
    }
    if (facade instanceof DeityFacade) {
        return getHTMLInfo((DeityFacade) facade);
    }
    if (facade instanceof DomainFacade) {
        return getHTMLInfo((DomainFacade) facade);
    }
    if (facade instanceof EquipmentFacade) {
        return getHTMLInfo((EquipmentFacade) facade);
    }
    if (facade instanceof KitFacade) {
        return getHTMLInfo((KitFacade) facade);
    }
    if (facade instanceof RaceFacade) {
        return getHTMLInfo((RaceFacade) facade);
    }
    if (facade instanceof SkillFacade) {
        return getHTMLInfo((SkillFacade) facade);
    }
    if (facade instanceof SpellFacade) {
        return getHTMLInfo((SpellFacade) facade);
    }
    if (facade instanceof TempBonusFacade) {
        return getHTMLInfo((TempBonusFacade) facade);
    }
    if (facade instanceof TemplateFacade) {
        return getHTMLInfo((TemplateFacade) facade);
    }
    final HtmlInfoBuilder infoText = new HtmlInfoBuilder();
    infoText.appendTitleElement(facade.toString());
    infoText.appendLineBreak();
    if (!facade.getType().isEmpty()) {
        //$NON-NLS-1$
        infoText.appendI18nElement("in_irInfoType", facade.getType());
        infoText.appendLineBreak();
    }
    infoText.appendI18nElement(//$NON-NLS-1$
    "in_itmInfoLabelTextSource", facade.getSource());
    return infoText.toString();
}
Also used : DomainFacade(pcgen.facade.core.DomainFacade) EquipmentFacade(pcgen.facade.core.EquipmentFacade) ClassFacade(pcgen.facade.core.ClassFacade) KitFacade(pcgen.facade.core.KitFacade) TempBonusFacade(pcgen.facade.core.TempBonusFacade) AbilityFacade(pcgen.facade.core.AbilityFacade) SkillFacade(pcgen.facade.core.SkillFacade) DeityFacade(pcgen.facade.core.DeityFacade) HtmlInfoBuilder(pcgen.gui2.util.HtmlInfoBuilder) RaceFacade(pcgen.facade.core.RaceFacade) SpellFacade(pcgen.facade.core.SpellFacade) TemplateFacade(pcgen.facade.core.TemplateFacade)

Example 10 with EquipmentFacade

use of pcgen.facade.core.EquipmentFacade in project pcgen by PCGen.

the class EquipmentSetFacadeImpl method elementRemoved.

@Override
public void elementRemoved(ListEvent<EquipmentFacade> e) {
    EquipmentFacade equipmentFacade = e.getElement();
    if (equippedItemsList.containsElement(equipmentFacade)) {
        if (Logging.isDebugMode()) {
            Logging.debugPrint("Currently equipped item " + equipmentFacade + " is being removed.");
        }
    }
    List<EquipNodeImpl> affectedList = findEquipmentNodes(equipmentFacade);
    for (EquipNodeImpl equipNode : affectedList) {
        EquipSet eSet = charDisplay.getEquipSetByIdPath(equipNode.getIdPath());
        if (eSet != null) {
            removeEquipment(equipNode, eSet.getQty().intValue());
        }
    }
}
Also used : EquipmentFacade(pcgen.facade.core.EquipmentFacade) EquipSet(pcgen.core.character.EquipSet)

Aggregations

EquipmentFacade (pcgen.facade.core.EquipmentFacade)11 Equipment (pcgen.core.Equipment)3 ArrayList (java.util.ArrayList)2 EquipSet (pcgen.core.character.EquipSet)2 BorderLayout (java.awt.BorderLayout)1 Box (javax.swing.Box)1 JCheckBox (javax.swing.JCheckBox)1 JComboBox (javax.swing.JComboBox)1 JPanel (javax.swing.JPanel)1 JScrollPane (javax.swing.JScrollPane)1 EmptyBorder (javax.swing.border.EmptyBorder)1 BodyStructure (pcgen.core.BodyStructure)1 EquipSlot (pcgen.core.character.EquipSlot)1 AbilityFacade (pcgen.facade.core.AbilityFacade)1 CharacterFacade (pcgen.facade.core.CharacterFacade)1 ClassFacade (pcgen.facade.core.ClassFacade)1 DeityFacade (pcgen.facade.core.DeityFacade)1 DomainFacade (pcgen.facade.core.DomainFacade)1 KitFacade (pcgen.facade.core.KitFacade)1 RaceFacade (pcgen.facade.core.RaceFacade)1