Search in sources :

Example 11 with EquipNode

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

the class EquipmentSetFacadeImplTest method testGetRequiredLoc.

/**
	 * Verify the getRequiredLoc method. 
	 */
public void testGetRequiredLoc() {
    EquipSet es = new EquipSet("0.1", "Unit Test Equip");
    EquipmentSetFacadeImpl esfi = new EquipmentSetFacadeImpl(uiDelegate, getCharacter(), es, dataset, equipmentList, todoManager, null);
    assertNull("Null equipment should give null location", esfi.getNaturalWeaponLoc(null));
    Equipment eq = new Equipment();
    eq.addType(Type.MELEE);
    eq.addType(Type.WEAPON);
    EquipNode requiredLoc = esfi.getNaturalWeaponLoc(eq);
    assertNull("Melee weapon should not have required location.", requiredLoc);
    eq.addType(Type.NATURAL);
    eq.put(IntegerKey.SLOTS, 0);
    eq.setName("Sting");
    requiredLoc = esfi.getNaturalWeaponLoc(eq);
    assertNotNull("Natural weapon should have required location.", requiredLoc);
    assertEquals("Incorrect name for secondary natural weapon", "Natural-Secondary", requiredLoc.toString());
    assertEquals("Natural weapom should replace hands.", "HANDS", requiredLoc.getBodyStructure().toString());
    eq.setModifiedName("Natural/Primary");
    requiredLoc = esfi.getNaturalWeaponLoc(eq);
    assertNotNull("Natural weapon should have required location.", requiredLoc);
    assertEquals("Incorrect name for primary natural weapon", "Natural-Primary", requiredLoc.toString());
    assertEquals("Natural weapom should replace hands.", "HANDS", requiredLoc.getBodyStructure().toString());
}
Also used : Equipment(pcgen.core.Equipment) EquipSet(pcgen.core.character.EquipSet) EquipNode(pcgen.facade.core.EquipmentSetFacade.EquipNode)

Example 12 with EquipNode

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

the class EquipmentSetFacadeImplTest method testAddRemove.

/**
	 * Check that EquipmentSetFacadeImpl can manage addition and removal of equipment.  
	 */
public void testAddRemove() {
    EquipSet es = new EquipSet("0.1", "Unit Test Equip");
    CharacterFacadeImpl charFacade = new CharacterFacadeImpl(getCharacter(), uiDelegate, dataset);
    EquipmentSetFacadeImpl esfi = new EquipmentSetFacadeImpl(uiDelegate, getCharacter(), es, dataset, equipmentList, todoManager, charFacade);
    EquipNode root = esfi.getNodes().getElementAt(0);
    Equipment item = new Equipment();
    item.setName("Dart");
    assertEquals("Initial num carried", 0, item.getCarried(), 0.01);
    assertEquals("Initial num equipped", 0, item.getNumberEquipped());
    assertEquals("Initial node list size", NUM_BASE_NODES, esfi.getNodes().getSize());
    Equipment addedEquip = (Equipment) esfi.addEquipment(root, item, 2);
    assertEquals("First add num carried", 2, addedEquip.getCarried(), 0.01);
    assertEquals("First add num equipped", 2, addedEquip.getNumberEquipped());
    assertEquals("Should be no sideeffects to num carried", 0, item.getCarried(), 0.01);
    assertEquals("Should be no sideeffects to equipped", 0, item.getNumberEquipped());
    assertEquals("First add node list size", NUM_BASE_NODES + 1, esfi.getNodes().getSize());
    assertEquals("generated equip set id", "0.1.01", ((EquipNodeImpl) esfi.getNodes().getElementAt(NUM_BASE_NODES)).getIdPath());
    Equipment secondEquip = (Equipment) esfi.addEquipment(root, item, 1);
    assertEquals("Second add num carried", 3, secondEquip.getCarried(), 0.01);
    assertEquals("Second add num equipped", 3, secondEquip.getNumberEquipped());
    assertEquals("Should be no sideeffects to num carried", 0, item.getCarried(), 0.01);
    assertEquals("Should be no sideeffects to equipped", 0, item.getNumberEquipped());
    assertTrue("Same equipment item should have been used", addedEquip == secondEquip);
    assertEquals("First add node list size", NUM_BASE_NODES + 1, esfi.getNodes().getSize());
    EquipNode target = esfi.getNodes().getElementAt(NUM_BASE_NODES);
    Equipment removedEquip = (Equipment) esfi.removeEquipment(target, 2);
    assertEquals("First add num carried", 1, removedEquip.getCarried(), 0.01);
    assertEquals("First add num equipped", 1, removedEquip.getNumberEquipped());
    assertTrue("Same equipment item should have been used", addedEquip == removedEquip);
    assertEquals("Should be no sideeffects to num carried", 0, item.getCarried(), 0.01);
    assertEquals("Should be no sideeffects to equipped", 0, item.getNumberEquipped());
    assertEquals("First add node list size", NUM_BASE_NODES + 1, esfi.getNodes().getSize());
    esfi.removeEquipment(target, 1);
    assertEquals("First add num carried", 0, addedEquip.getCarried(), 0.01);
    assertEquals("First add num equipped", 0, addedEquip.getNumberEquipped());
    assertEquals("Should be no sideeffects to num carried", 0, item.getCarried(), 0.01);
    assertEquals("Should be no sideeffects to equipped", 0, item.getNumberEquipped());
    assertEquals("First add node list size", NUM_BASE_NODES, esfi.getNodes().getSize());
}
Also used : Equipment(pcgen.core.Equipment) EquipSet(pcgen.core.character.EquipSet) EquipNode(pcgen.facade.core.EquipmentSetFacade.EquipNode)

Example 13 with EquipNode

use of pcgen.facade.core.EquipmentSetFacade.EquipNode 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 14 with EquipNode

use of pcgen.facade.core.EquipmentSetFacade.EquipNode 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)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