use of pcgen.core.character.EquipSet in project pcgen by PCGen.
the class PlayerCharacter method getNewChildId.
/**
* Identify a new id (only the final number in the path) for a child
* equipment set. The id is guarantyeed to be unique and have no siblings
* with higher ids.
*
* @param pid The parent path.
* @return New id for a child node
*/
public int getNewChildId(String pid) {
int newID = 0;
for (EquipSet es : getEquipSet()) {
if (es.getParentIdPath().equals(pid) && (es.getId() > newID)) {
newID = es.getId();
}
}
++newID;
return newID;
}
use of pcgen.core.character.EquipSet in project pcgen by PCGen.
the class CharacterFacadeImplTest method testDefaultEquipSet.
/**
* Check the default equipment set created by CharacterFacadeImpl.
*/
@Test
public void testDefaultEquipSet() {
PlayerCharacter pc = new PlayerCharacter();
CharacterFacadeImpl charFacade = new CharacterFacadeImpl(pc, uiDelegate, dataset);
assertNotNull("Unable to create CharacterFacadeImpl", charFacade);
EquipSet defaultEquipSet = pc.getEquipSetByIdPath(EquipSet.DEFAULT_SET_PATH);
assertNotNull("Unable to find default equip set", defaultEquipSet);
assertEquals("Incorrect id of the default equip set", EquipSet.DEFAULT_SET_PATH, defaultEquipSet.getIdPath());
}
use of pcgen.core.character.EquipSet 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));
}
use of pcgen.core.character.EquipSet in project pcgen by PCGen.
the class EquipmentSetFacadeImplTest method testEmptyInit.
/**
* Check that EquipmentSetFacadeImpl can be initialised with an empty dataset.
*/
public void testEmptyInit() {
EquipSet es = new EquipSet("0.1", "Unit Test Equip");
EquipmentSetFacadeImpl esfi = new EquipmentSetFacadeImpl(uiDelegate, getCharacter(), es, dataset, equipmentList, todoManager, null);
ListFacade<EquipNode> nodeList = esfi.getNodes();
assertFalse("Expected a non empty node set", nodeList.isEmpty());
assertEquals("Incorrect name of base node", Constants.EQUIP_LOCATION_EQUIPPED, nodeList.getElementAt(0).toString());
assertEquals("Incorrect nunber of nodes found", NUM_BASE_NODES, nodeList.getSize());
}
use of pcgen.core.character.EquipSet 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());
}
Aggregations