Search in sources :

Example 1 with EquipNode

use of pcgen.facade.core.EquipmentSetFacade.EquipNode in project pcgen by PCGen.

the class EquipmentTreeTableModel method elementAdded.

@Override
public void elementAdded(ListEvent<EquipNode> e) {
    EquipNode child = e.getElement();
    EquipNode parent = child.getParent();
    int index = addNode(parent, child);
    fireTreeNodesInserted(this, getPathToRoot(parent), new int[] { index }, new Object[] { child });
}
Also used : EquipNode(pcgen.facade.core.EquipmentSetFacade.EquipNode)

Example 2 with EquipNode

use of pcgen.facade.core.EquipmentSetFacade.EquipNode in project pcgen by PCGen.

the class EquipmentTreeTableModel method initPathMap.

private void initPathMap() {
    ListFacade<EquipNode> equipNodes = equipSet.getNodes();
    for (EquipNode equipNode : equipNodes) {
        EquipNode parent = equipNode.getParent();
        while (parent != null && !pathMap.containsValue(parent, equipNode)) {
            addNode(parent, equipNode);
            equipNode = parent;
            parent = equipNode.getParent();
        }
        if (parent == null && !bodySlotNodes.contains(equipNode)) {
            addBodyNode(equipNode);
        }
    }
}
Also used : EquipNode(pcgen.facade.core.EquipmentSetFacade.EquipNode)

Example 3 with EquipNode

use of pcgen.facade.core.EquipmentSetFacade.EquipNode in project pcgen by PCGen.

the class EquipmentSetFacadeImplTest method testSlotManagementOnInitWithEquipment.

/**
	 * Check that EquipmentSetFacadeImpl when initialised with a dataset 
	 * containing equipment hides and shows the correct weapon slots.  
	 */
public void testSlotManagementOnInitWithEquipment() {
    PlayerCharacter pc = getCharacter();
    EquipSet es = new EquipSet("0.1", "Unit Test Equip");
    Equipment weapon = new Equipment();
    weapon.setName("Morningstar");
    addEquipToEquipSet(pc, es, weapon, 1.0f, LOC_PRIMARY);
    EquipmentSetFacadeImpl esfi = new EquipmentSetFacadeImpl(uiDelegate, pc, es, dataset, equipmentList, todoManager, null);
    ListFacade<EquipNode> nodes = esfi.getNodes();
    Map<String, EquipNode> nodeMap = new HashMap<>();
    for (EquipNode equipNode : nodes) {
        nodeMap.put(equipNode.toString(), equipNode);
    }
    EquipNode testNode = nodeMap.get("Morningstar");
    assertNotNull("Morningstar should be present", testNode);
    assertEquals("Morningstar type", EquipNode.NodeType.EQUIPMENT, testNode.getNodeType());
    assertEquals("Morningstar location", LOC_PRIMARY, esfi.getLocation(testNode));
    // Test for removed slots
    String[] removedSlots = { "Primary Hand", "Double Weapon", "Both Hands" };
    for (String slotName : removedSlots) {
        testNode = nodeMap.get(slotName);
        assertNull(slotName + " should not be present", testNode);
    }
    // Test for still present slots
    String[] retainedSlots = { "Secondary Hand", "Ring" };
    for (String slotName : retainedSlots) {
        testNode = nodeMap.get(slotName);
        assertNotNull(slotName + " should be present", testNode);
    }
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) Equipment(pcgen.core.Equipment) HashMap(java.util.HashMap) EquipSet(pcgen.core.character.EquipSet) EquipNode(pcgen.facade.core.EquipmentSetFacade.EquipNode)

Example 4 with EquipNode

use of pcgen.facade.core.EquipmentSetFacade.EquipNode in project pcgen by PCGen.

the class EquipmentSetFacadeImplTest method testSlotCreation.

/**
	 * Test the creation of phantom slots, looking at types and quantities particularly.  
	 */
public void testSlotCreation() {
    EquipSet es = new EquipSet("0.1", "Unit Test Equip");
    EquipmentSetFacadeImpl esfi = new EquipmentSetFacadeImpl(uiDelegate, getCharacter(), es, dataset, equipmentList, todoManager, null);
    ListFacade<EquipNode> nodes = esfi.getNodes();
    Map<String, EquipNode> nodeMap = new HashMap<>();
    for (EquipNode equipNode : nodes) {
        nodeMap.put(equipNode.toString(), equipNode);
    }
    EquipNode testNode = nodeMap.get("Primary Hand");
    assertNotNull("Primary Hand should be present", testNode);
    assertEquals("Primary Hand type", EquipNode.NodeType.PHANTOM_SLOT, testNode.getNodeType());
    assertEquals("Primary Hand count", 1, esfi.getQuantity(testNode));
    testNode = nodeMap.get("Secondary Hand");
    assertNotNull("Secondary Hand should be present", testNode);
    assertEquals("Secondary Hand type", EquipNode.NodeType.PHANTOM_SLOT, testNode.getNodeType());
    assertEquals("Secondary Hand count", 1, esfi.getQuantity(testNode));
    testNode = nodeMap.get(Constants.EQUIP_LOCATION_SECONDARY + " 1");
    assertNull(Constants.EQUIP_LOCATION_SECONDARY + " 1 should not be present", testNode);
    testNode = nodeMap.get(Constants.EQUIP_LOCATION_SECONDARY + " 2");
    assertNull(Constants.EQUIP_LOCATION_SECONDARY + " 2 should not be present", testNode);
    testNode = nodeMap.get("Double Weapon");
    assertNotNull("Double Weapon should be present", testNode);
    assertEquals("Double Weapon type", EquipNode.NodeType.PHANTOM_SLOT, testNode.getNodeType());
    assertEquals("Double Weapon count", 1, esfi.getQuantity(testNode));
    testNode = nodeMap.get("Both Hands");
    assertNotNull("Both Hands should be present", testNode);
    assertEquals("Both Hands type", EquipNode.NodeType.PHANTOM_SLOT, testNode.getNodeType());
    assertEquals("Both Hands count", 1, esfi.getQuantity(testNode));
    testNode = nodeMap.get("Unarmed");
    assertNotNull("Unarmed should be present", testNode);
    assertEquals("Unarmed type", EquipNode.NodeType.PHANTOM_SLOT, testNode.getNodeType());
    assertEquals("Unarmed count", 1, esfi.getQuantity(testNode));
    testNode = nodeMap.get("Ring");
    assertNotNull("Ring should be present", testNode);
    assertEquals("Ring type", EquipNode.NodeType.PHANTOM_SLOT, testNode.getNodeType());
    assertEquals("Ring count", 2, esfi.getQuantity(testNode));
}
Also used : HashMap(java.util.HashMap) EquipSet(pcgen.core.character.EquipSet) EquipNode(pcgen.facade.core.EquipmentSetFacade.EquipNode)

Example 5 with EquipNode

use of pcgen.facade.core.EquipmentSetFacade.EquipNode in project pcgen by PCGen.

the class EquipmentSetFacadeImplTest method testBonusSlot.

public void testBonusSlot() {
    EquipSet es = new EquipSet("0.1", "Unit Test Equip");
    PlayerCharacter pc = getCharacter();
    EquipmentSetFacadeImpl esfi = new EquipmentSetFacadeImpl(uiDelegate, pc, es, dataset, equipmentList, todoManager, null);
    ListFacade<EquipNode> nodes = esfi.getNodes();
    Map<String, EquipNode> nodeMap = new HashMap<>();
    for (EquipNode equipNode : nodes) {
        nodeMap.put(equipNode.toString(), equipNode);
    }
    EquipNode testNode = nodeMap.get("Ring");
    assertNotNull("Ring should be present", testNode);
    assertEquals("Ring type", EquipNode.NodeType.PHANTOM_SLOT, testNode.getNodeType());
    assertEquals("Ring count", 2, esfi.getQuantity(testNode));
    PCTemplate template = TestHelper.makeTemplate("RingBonus");
    Globals.getContext().unconditionallyProcess(template, "BONUS", "SLOTS|Ring|1");
    pc.addTemplate(template);
    assertEquals("Ring count", 3, esfi.getQuantity(testNode));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) HashMap(java.util.HashMap) EquipSet(pcgen.core.character.EquipSet) PCTemplate(pcgen.core.PCTemplate) EquipNode(pcgen.facade.core.EquipmentSetFacade.EquipNode)

Aggregations

EquipNode (pcgen.facade.core.EquipmentSetFacade.EquipNode)14 EquipSet (pcgen.core.character.EquipSet)7 Equipment (pcgen.core.Equipment)4 HashMap (java.util.HashMap)3 PlayerCharacter (pcgen.core.PlayerCharacter)3 EquipNodeImpl (pcgen.gui2.facade.EquipmentSetFacadeImpl.EquipNodeImpl)3 ArrayList (java.util.ArrayList)1 PCTemplate (pcgen.core.PCTemplate)1