Search in sources :

Example 46 with EquipSet

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;
}
Also used : EquipSet(pcgen.core.character.EquipSet)

Example 47 with EquipSet

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());
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) EquipSet(pcgen.core.character.EquipSet) Test(org.junit.Test)

Example 48 with EquipSet

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));
}
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)

Example 49 with EquipSet

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());
}
Also used : EquipSet(pcgen.core.character.EquipSet) EquipNode(pcgen.facade.core.EquipmentSetFacade.EquipNode)

Example 50 with EquipSet

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());
}
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)

Aggregations

EquipSet (pcgen.core.character.EquipSet)79 PlayerCharacter (pcgen.core.PlayerCharacter)32 Equipment (pcgen.core.Equipment)22 ArrayList (java.util.ArrayList)12 BonusObj (pcgen.core.bonus.BonusObj)11 HashMap (java.util.HashMap)9 LoadContext (pcgen.rules.context.LoadContext)8 EquipNode (pcgen.facade.core.EquipmentSetFacade.EquipNode)7 DecimalFormat (java.text.DecimalFormat)4 NumberFormat (java.text.NumberFormat)4 List (java.util.List)4 Map (java.util.Map)4 EquipmentList (pcgen.core.EquipmentList)4 PCTemplate (pcgen.core.PCTemplate)4 EquipSlot (pcgen.core.character.EquipSlot)4 LinkedHashMap (java.util.LinkedHashMap)3 Ability (pcgen.core.Ability)3 EquipmentModifier (pcgen.core.EquipmentModifier)3 StringTokenizer (java.util.StringTokenizer)2 CNAbility (pcgen.cdom.content.CNAbility)2