Search in sources :

Example 1 with EquipNodeImpl

use of pcgen.gui2.facade.EquipmentSetFacadeImpl.EquipNodeImpl in project pcgen by PCGen.

the class EquipmentSetFacadeImplTest method testInitWithEquipment.

/**
	 * Check that EquipmentSetFacadeImpl can be initialised with a dataset 
	 * containing equipment.  
	 */
public void testInitWithEquipment() {
    PlayerCharacter pc = getCharacter();
    EquipSet es = new EquipSet("0.1", "Unit Test Equip");
    Equipment item = new Equipment();
    item.setName(SATCHEL);
    Equipment item2 = new Equipment();
    item2.setName(BOOK);
    Equipment item3 = new Equipment();
    item3.setName(QUARTERSTAFF);
    item3.put(IntegerKey.SLOTS, 2);
    EquipSet satchelEs = addEquipToEquipSet(pc, es, item, 1.0f);
    addEquipToEquipSet(pc, satchelEs, item2, 1.0f);
    addEquipToEquipSet(pc, es, item3, 1.0f, LOC_BOTH_HANDS);
    int adjustedBaseNodes = NUM_BASE_NODES - 4;
    EquipmentSetFacadeImpl esfi = new EquipmentSetFacadeImpl(uiDelegate, pc, es, dataset, equipmentList, todoManager, null);
    ListFacade<EquipNode> nodeList = esfi.getNodes();
    assertFalse("Expected a non empty path set", nodeList.isEmpty());
    EquipNodeImpl node = (EquipNodeImpl) nodeList.getElementAt(0);
    assertEquals("Incorrect body struct name", Constants.EQUIP_LOCATION_EQUIPPED, node.toString());
    assertEquals("Incorrect body struct type", NodeType.BODY_SLOT, node.getNodeType());
    assertEquals("Incorrect sort key", "00", node.getSortKey());
    assertEquals("Incorrect parent", null, node.getParent());
    node = (EquipNodeImpl) nodeList.getElementAt(adjustedBaseNodes);
    assertEquals("Incorrect container name", item.getName(), node.toString());
    assertEquals("Incorrect container type", NodeType.EQUIPMENT, node.getNodeType());
    assertEquals("Incorrect sort key", "00|" + item.getName(), node.getSortKey());
    assertEquals("Incorrect parent", nodeList.getElementAt(0), node.getParent());
    node = (EquipNodeImpl) nodeList.getElementAt(adjustedBaseNodes + 2);
    assertEquals("Incorrect item name", item2.getName(), node.toString());
    assertEquals("Incorrect item type", NodeType.EQUIPMENT, node.getNodeType());
    assertEquals("Incorrect sort key", "00|" + item.getName() + "|" + item2.getName(), node.getSortKey());
    assertEquals("Incorrect parent", nodeList.getElementAt(adjustedBaseNodes), node.getParent());
    node = (EquipNodeImpl) nodeList.getElementAt(adjustedBaseNodes + 1);
    assertEquals("Incorrect item name", item3.getName(), node.toString());
    assertEquals("Incorrect item type", NodeType.EQUIPMENT, node.getNodeType());
    assertEquals("Incorrect sort key", "01|" + item3.getName(), node.getSortKey());
    assertEquals("Incorrect parent", LOC_HANDS, node.getParent().toString());
    node = (EquipNodeImpl) nodeList.getElementAt(adjustedBaseNodes + 2);
    EquipNode parent = node.getParent();
    assertEquals("Root incorrect", Constants.EQUIP_LOCATION_EQUIPPED, parent.getParent().toString());
    assertEquals("Leaf incorrect", item.getName(), parent.toString());
    assertEquals("Incorrect nuber of paths found", adjustedBaseNodes + 3, nodeList.getSize());
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) Equipment(pcgen.core.Equipment) EquipNodeImpl(pcgen.gui2.facade.EquipmentSetFacadeImpl.EquipNodeImpl) EquipSet(pcgen.core.character.EquipSet) EquipNode(pcgen.facade.core.EquipmentSetFacade.EquipNode)

Example 2 with EquipNodeImpl

use of pcgen.gui2.facade.EquipmentSetFacadeImpl.EquipNodeImpl in project pcgen by PCGen.

the class EquipmentSetFacadeImplTest method testMoveEquipmentDown.

/**
	 * Check that EquipmentSetFacadeImpl can move an equipment item down the list.
	 */
public void testMoveEquipmentDown() {
    EquipmentSetFacadeImpl esfi = prepareEquipmentSet();
    ListFacade<EquipNode> nodeList = esfi.getNodes();
    assertFalse("Expected a non empty path set", nodeList.isEmpty());
    EquipNodeImpl quarterstaffNode = getEquipNodeByName(nodeList, QUARTERSTAFF);
    //assertEquals("Incorrect item name", item3.getName(), quarterstaffNode.toString());
    assertEquals("Incorrect item type", NodeType.EQUIPMENT, quarterstaffNode.getNodeType());
    assertEquals("Incorrect parent", Constants.EQUIP_LOCATION_EQUIPPED, quarterstaffNode.getParent().toString());
    assertEquals("Incorrect path", "0.1.02", quarterstaffNode.getIdPath());
    EquipNodeImpl bookNode = getEquipNodeByName(nodeList, BOOK);
    assertEquals("Incorrect path", "0.1.01.01", bookNode.getIdPath());
    EquipNodeImpl satchelNode = getEquipNodeByName(nodeList, SATCHEL);
    assertEquals("Incorrect path", "0.1.01", satchelNode.getIdPath());
    EquipNodeImpl bedrollNode = getEquipNodeByName(nodeList, BEDROLL);
    assertEquals("Incorrect path", "0.1.03", bedrollNode.getIdPath());
    assertTrue("Move down failed unexpectedly", esfi.moveEquipment(satchelNode, 1));
    assertEquals("Incorrect quarterstaff path after move down.", "0.1.02", quarterstaffNode.getIdPath());
    assertEquals("Incorrect satchel path after move down.", "0.1.03", satchelNode.getIdPath());
    assertEquals("Incorrect book path after move down.", "0.1.03.01", bookNode.getIdPath());
    assertEquals("Incorrect bedroll path after move down.", "0.1.04", bedrollNode.getIdPath());
    assertTrue("Move to bottom failed unexpectedly", esfi.moveEquipment(satchelNode, 1));
    assertEquals("Incorrect quarterstaff path after move to bottom.", "0.1.02", quarterstaffNode.getIdPath());
    assertEquals("Incorrect satchel path after move to bottom.", "0.1.05", satchelNode.getIdPath());
    assertEquals("Incorrect book path after move to bottom.", "0.1.05.01", bookNode.getIdPath());
    assertEquals("Incorrect bedroll path after move to bottom.", "0.1.04", bedrollNode.getIdPath());
}
Also used : EquipNodeImpl(pcgen.gui2.facade.EquipmentSetFacadeImpl.EquipNodeImpl) EquipNode(pcgen.facade.core.EquipmentSetFacade.EquipNode)

Example 3 with EquipNodeImpl

use of pcgen.gui2.facade.EquipmentSetFacadeImpl.EquipNodeImpl in project pcgen by PCGen.

the class EquipmentSetFacadeImplTest method testMoveEquipmentUp.

/**
	 * Check that EquipmentSetFacadeImpl can move an equipment item up the list.
	 */
public void testMoveEquipmentUp() {
    EquipmentSetFacadeImpl esfi = prepareEquipmentSet();
    ListFacade<EquipNode> nodeList = esfi.getNodes();
    assertFalse("Expected a non empty path set", nodeList.isEmpty());
    EquipNodeImpl quarterstaffNode = getEquipNodeByName(nodeList, QUARTERSTAFF);
    //assertEquals("Incorrect item name", item3.getName(), quarterstaffNode.toString());
    assertEquals("Incorrect item type", NodeType.EQUIPMENT, quarterstaffNode.getNodeType());
    assertEquals("Incorrect parent", Constants.EQUIP_LOCATION_EQUIPPED, quarterstaffNode.getParent().toString());
    assertEquals("Incorrect path", "0.1.02", quarterstaffNode.getIdPath());
    EquipNodeImpl bookNode = getEquipNodeByName(nodeList, BOOK);
    assertEquals("Incorrect path", "0.1.01.01", bookNode.getIdPath());
    EquipNodeImpl satchelNode = getEquipNodeByName(nodeList, SATCHEL);
    assertEquals("Incorrect path", "0.1.01", satchelNode.getIdPath());
    assertTrue("Move up failed unexpectedly", esfi.moveEquipment(quarterstaffNode, -1));
    assertEquals("Incorrect quarterstaff path", "0.1.01", quarterstaffNode.getIdPath());
    assertEquals("Incorrect satchel path", "0.1.02", satchelNode.getIdPath());
    assertEquals("Incorrect book path", "0.1.02.01", bookNode.getIdPath());
}
Also used : EquipNodeImpl(pcgen.gui2.facade.EquipmentSetFacadeImpl.EquipNodeImpl) EquipNode(pcgen.facade.core.EquipmentSetFacade.EquipNode)

Aggregations

EquipNode (pcgen.facade.core.EquipmentSetFacade.EquipNode)3 EquipNodeImpl (pcgen.gui2.facade.EquipmentSetFacadeImpl.EquipNodeImpl)3 Equipment (pcgen.core.Equipment)1 PlayerCharacter (pcgen.core.PlayerCharacter)1 EquipSet (pcgen.core.character.EquipSet)1