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 CharacterFacadeImpl method addNote.
@Override
public void addNote(List<EquipmentFacade> targets) {
List<Equipment> notedEquip = new ArrayList<>();
for (EquipmentFacade equipmentFacade : targets) {
if (equipmentFacade instanceof Equipment) {
notedEquip.add((Equipment) equipmentFacade);
}
}
if (notedEquip.isEmpty()) {
return;
}
for (Equipment equip : notedEquip) {
String note = getNote(equip);
if (note == null) {
return;
}
equip.setNote(note);
purchasedEquip.modifyElement(equip);
}
}
use of pcgen.facade.core.EquipmentFacade in project pcgen by PCGen.
the class CharacterFacadeImpl method modifyCharges.
@Override
public void modifyCharges(List<EquipmentFacade> targets) {
List<Equipment> chargedEquip = new ArrayList<>();
for (EquipmentFacade equipmentFacade : targets) {
if (equipmentFacade instanceof Equipment && ((Equipment) equipmentFacade).getMaxCharges() > 0) {
chargedEquip.add((Equipment) equipmentFacade);
}
}
if (chargedEquip.isEmpty()) {
return;
}
for (Equipment equip : chargedEquip) {
int selectedCharges = getSelectedCharges(equip);
if (selectedCharges < 0) {
return;
}
equip.setRemainingCharges(selectedCharges);
purchasedEquip.modifyElement(equip);
}
}
Aggregations