use of pcgen.core.character.EquipSlot in project pcgen by PCGen.
the class PlayerCharacter method getSingleLocation.
/**
* If an item can only go in one location, return the name of that location
* to add to an EquipSet
*
* @param eqI
* @return single location
*/
private String getSingleLocation(Equipment eqI) {
// Handle natural weapons
String loc = getNaturalWeaponLocation(eqI);
if (loc != null) {
return loc;
}
// unless they are also armor (ie: with Armor Spikes)
if ((eqI.isWeapon()) && !(eqI.isArmor())) {
return Constants.EMPTY_STRING;
}
List<EquipSlot> eqSlotList = SystemCollections.getUnmodifiableEquipSlotList();
if ((eqSlotList == null) || eqSlotList.isEmpty()) {
return Constants.EMPTY_STRING;
}
for (EquipSlot es : eqSlotList) {
// see if this EquipSlot can contain this item TYPE
if (es.canContainType(eqI.getType())) {
return es.getSlotName();
}
}
return Constants.EMPTY_STRING;
}
use of pcgen.core.character.EquipSlot in project pcgen by PCGen.
the class DataSet method initLists.
private void initLists() {
List<Race> raceList = new ArrayList<>(context.getReferenceContext().getConstructedCDOMObjects(Race.class));
raceList.sort(new RaceComparator());
for (Race race : raceList) {
if (race.getSafe(ObjectKey.VISIBILITY).isVisibleTo(View.VISIBLE_DISPLAY)) {
races.addElement(race);
}
}
List<PCClass> classList = new ArrayList<>(context.getReferenceContext().getConstructedCDOMObjects(PCClass.class));
classList.sort(new PCClassComparator());
for (PCClass pcClass : classList) {
if (pcClass.getSafe(ObjectKey.VISIBILITY).isVisibleTo(View.VISIBLE_DISPLAY)) {
classes.addElement(pcClass);
}
}
for (Skill skill : context.getReferenceContext().getConstructedCDOMObjects(Skill.class)) {
if (skill.getSafe(ObjectKey.VISIBILITY).isVisibleTo(View.VISIBLE_DISPLAY)) {
skills.addElement(skill);
}
}
for (Deity deity : context.getReferenceContext().getConstructedCDOMObjects(Deity.class)) {
deities.addElement(deity);
}
for (PCTemplate template : context.getReferenceContext().getConstructedCDOMObjects(PCTemplate.class)) {
if (template.getSafe(ObjectKey.VISIBILITY).isVisibleTo(View.VISIBLE_DISPLAY)) {
templates.addElement(template);
}
}
for (Kit kit : context.getReferenceContext().getConstructedCDOMObjects(Kit.class)) {
kits.addElement(kit);
}
for (PCAlignment alignment : context.getReferenceContext().getOrderSortedCDOMObjects(PCAlignment.class)) {
alignments.addElement(alignment);
}
for (PCStat stat : context.getReferenceContext().getOrderSortedCDOMObjects(PCStat.class)) {
stats.addElement(stat);
}
// new AbilityCategoryComparator());
for (AbilityCategory category : gameMode.getAllAbilityCategories()) {
if (category.isVisibleTo(View.VISIBLE_DISPLAY)) {
// categories.addElement(category);
List<Ability> abList = new ArrayList<>(Globals.getContext().getReferenceContext().getManufacturer(Ability.class, category).getAllObjects());
Globals.sortPObjectListByName(abList);
DefaultListFacade<AbilityFacade> abilityList = new DefaultListFacade<>(abList);
for (Iterator<AbilityFacade> iterator = abilityList.iterator(); iterator.hasNext(); ) {
AbilityFacade facade = iterator.next();
if (facade instanceof Ability) {
Ability ability = (Ability) facade;
if (!(ability.getSafe(ObjectKey.VISIBILITY).isVisibleTo(View.VISIBLE_DISPLAY))) {
iterator.remove();
}
}
}
abilityMap.put(category, abilityList);
}
}
Map<String, BodyStructure> structMap = new HashMap<>(SystemCollections.getUnmodifiableBodyStructureList().size() + 3);
for (String name : SystemCollections.getUnmodifiableBodyStructureList()) {
// TODO i18n the display name and correct the DataSetTest
String displayName = name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase();
final BodyStructure bodyStructure = new BodyStructure(displayName);
bodyStructures.addElement(bodyStructure);
structMap.put(name, bodyStructure);
}
Set<Type> typesWithDesignatedSlots = buildSlottedTypeList();
bodyStructures.addElement(new BodyStructure(Constants.EQUIP_LOCATION_EQUIPPED, true, typesWithDesignatedSlots));
bodyStructures.addElement(new BodyStructure(Constants.EQUIP_LOCATION_CARRIED, true));
bodyStructures.addElement(new BodyStructure(Constants.EQUIP_LOCATION_NOTCARRIED, true));
for (EquipSlot es : SystemCollections.getUnmodifiableEquipSlotList()) {
if (structMap.containsKey(es.getBodyStructureName())) {
structMap.get(es.getBodyStructureName()).addEquipSlot(es);
}
}
for (Equipment eq : context.getReferenceContext().getConstructedCDOMObjects(Equipment.class)) {
if (eq.getSafe(ObjectKey.VISIBILITY).isVisibleTo(View.VISIBLE_DISPLAY)) {
equipment.addElement(eq);
}
}
for (String xpTableName : gameMode.getXPTableNames()) {
xpTableNames.addElement(xpTableName);
}
for (String characterType : gameMode.getCharacterTypeList()) {
characterTypes.addElement(characterType);
}
for (SizeAdjustment size : context.getReferenceContext().getSortedList(SizeAdjustment.class, IntegerKey.SIZEORDER)) {
sizes.addElement(size);
}
createGearBuySellSchemes();
}
use of pcgen.core.character.EquipSlot in project pcgen by PCGen.
the class EquipmentSetFacadeImpl method buildNodeList.
private void buildNodeList() {
nodeList = new DefaultListFacade<>();
equipSlotNodeMap = new LinkedHashMap<>();
int index = 0;
for (BodyStructureFacade bodyStruct : dataSet.getEquipmentLocations()) {
String structString = bodyStruct.toString();
EquipNodeImpl node = new EquipNodeImpl((BodyStructure) bodyStruct, index++);
nodeList.addElement(node);
// Add locations for this body structure
for (EquipSlot slot : SystemCollections.getUnmodifiableEquipSlotList()) {
String bodyStructureName = slot.getBodyStructureName();
final String hands = "HANDS";
if ("Ring".equalsIgnoreCase(slot.getSlotName()) || "Fingers".equalsIgnoreCase(slot.getSlotName())) {
bodyStructureName = hands;
}
if (bodyStructureName.equalsIgnoreCase(structString)) {
if (slot.canContainType("WEAPON")) {
// Add phantom nodes for the various weapon slots
if (getPCHands() > 0) {
addEquipNodeForEquipSlot(node, createWeaponEquipSlot(slot, Constants.EQUIP_LOCATION_PRIMARY), true);
}
for (int i = 1; i < getPCHands(); ++i) {
if (i > 1) {
addEquipNodeForEquipSlot(node, createWeaponEquipSlot(slot, Constants.EQUIP_LOCATION_SECONDARY + " " + i), true);
} else {
addEquipNodeForEquipSlot(node, createWeaponEquipSlot(slot, Constants.EQUIP_LOCATION_SECONDARY), true);
}
}
addEquipNodeForEquipSlot(node, createWeaponEquipSlot(slot, Constants.EQUIP_LOCATION_DOUBLE), true);
addEquipNodeForEquipSlot(node, createWeaponEquipSlot(slot, Constants.EQUIP_LOCATION_BOTH), true);
addEquipNodeForEquipSlot(node, createWeaponEquipSlot(slot, Constants.EQUIP_LOCATION_UNARMED), true);
} else {
addEquipNodeForEquipSlot(node, slot, false);
}
}
}
}
}
use of pcgen.core.character.EquipSlot 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.core.character.EquipSlot in project pcgen by PCGen.
the class EquipmentSetFacadeImpl method getIncompatibleWeaponSlots.
/**
* Calculate a list of weapon slots that are not compatible with the
* supplied slot. These can then be removed from the list to be displayed
* when the slot is filled and added back in when the slot is empty.
*
* @param targetNode The node to be check.
* @return The list of incompatible nodes, empty if the target is not a weapon slot.
*/
private List<EquipNode> getIncompatibleWeaponSlots(EquipNodeImpl targetNode) {
List<EquipNode> wpnList = new ArrayList<>();
if (targetNode.getNodeType() != NodeType.PHANTOM_SLOT) {
return wpnList;
}
String[] incompatLocNames = {};
final String slotName = targetNode.getSlot().toString();
if (Constants.EQUIP_LOCATION_PRIMARY.equals(slotName)) {
incompatLocNames = new String[] { Constants.EQUIP_LOCATION_BOTH, Constants.EQUIP_LOCATION_DOUBLE };
} else if (Constants.EQUIP_LOCATION_SECONDARY.equals(slotName)) {
incompatLocNames = new String[] { Constants.EQUIP_LOCATION_BOTH, Constants.EQUIP_LOCATION_DOUBLE, Constants.EQUIP_LOCATION_SHIELD };
} else if (Constants.EQUIP_LOCATION_SHIELD.equals(slotName)) {
incompatLocNames = new String[] { Constants.EQUIP_LOCATION_BOTH, Constants.EQUIP_LOCATION_DOUBLE, Constants.EQUIP_LOCATION_SECONDARY };
} else if (Constants.EQUIP_LOCATION_BOTH.equals(slotName)) {
incompatLocNames = new String[] { Constants.EQUIP_LOCATION_PRIMARY, Constants.EQUIP_LOCATION_DOUBLE, Constants.EQUIP_LOCATION_SECONDARY, Constants.EQUIP_LOCATION_SHIELD };
} else if (Constants.EQUIP_LOCATION_DOUBLE.equals(slotName)) {
incompatLocNames = new String[] { Constants.EQUIP_LOCATION_PRIMARY, Constants.EQUIP_LOCATION_BOTH, Constants.EQUIP_LOCATION_SECONDARY, Constants.EQUIP_LOCATION_SHIELD };
}
//TODO: Extra secondary locations for more than 2 arms
List<String> namesList = Arrays.asList(incompatLocNames);
for (EquipSlot slot : equipSlotNodeMap.keySet()) {
if (namesList.contains(slot.toString())) {
wpnList.add(equipSlotNodeMap.get(slot));
}
}
return wpnList;
}
Aggregations