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);
}
}
}
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;
}
}
}
}
}
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;
}
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();
}
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());
}
}
}
Aggregations