Search in sources :

Example 36 with EquipSet

use of pcgen.core.character.EquipSet 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 37 with EquipSet

use of pcgen.core.character.EquipSet in project pcgen by PCGen.

the class EquipSetMigrationTest method testRenumberEquipmentSetsMultipleEquipSet.

/**
	 * Test method for {@link pcgen.io.migration.EquipSetMigration#renumberEquipmentSets(pcgen.core.PlayerCharacter)}.
	 */
public void testRenumberEquipmentSetsMultipleEquipSet() {
    PlayerCharacter pc = getCharacter();
    EquipSet eSet = new EquipSet("0.1", "Battle gear");
    pc.addEquipSet(eSet);
    pc.setCalcEquipSetId("0.1");
    eSet = new EquipSet("0.3", "Around Town");
    pc.addEquipSet(eSet);
    Equipment eqItemOne = EquipmentList.getEquipmentFromName("Item One", pc);
    eqItemOne.setOutputIndex(1);
    Equipment eqItemTwo = EquipmentList.getEquipmentFromName("Item Two", pc);
    eqItemTwo.setOutputIndex(2);
    Equipment eqItemThree = EquipmentList.getEquipmentFromName("Item Three", pc);
    eqItemThree.setOutputIndex(3);
    Equipment eqBackpack = EquipmentList.getEquipmentFromName("Backpack", pc);
    eqBackpack.setOutputIndex(4);
    equipItem(pc, eqItemOne, 1.0f, "Carried", "0.1.1");
    equipItem(pc, eqItemTwo, 1.0f, "Carried", "0.1.6");
    equipItem(pc, eqItemThree, 1.0f, "Carried", "0.1.4");
    equipItem(pc, eqItemOne, 1.0f, "Carried", "0.3.6");
    equipItem(pc, eqItemTwo, 1.0f, "Backpack", "0.3.4.1");
    equipItem(pc, eqItemThree, 1.0f, "Backpack", "0.3.4.2");
    equipItem(pc, eqBackpack, 1.0f, "Carried", "0.3.4");
    EquipSetMigration.renumberEquipmentSets(pc);
    List<EquipSet> migratedList = (List<EquipSet>) pc.getDisplay().getEquipSet();
    assertEquals("Unexpected number of equipsets", 9, migratedList.size());
    verifyEquipSet(migratedList.get(0), "0.1", null);
    verifyEquipSet(migratedList.get(2), "0.1.01", eqItemOne);
    verifyEquipSet(migratedList.get(3), "0.1.02", eqItemTwo);
    verifyEquipSet(migratedList.get(4), "0.1.03", eqItemThree);
    verifyEquipSet(migratedList.get(1), "0.3", null);
    verifyEquipSet(migratedList.get(5), "0.3.01", eqItemOne);
    verifyEquipSet(migratedList.get(6), "0.3.02.01", eqItemTwo);
    verifyEquipSet(migratedList.get(7), "0.3.02.02", eqItemThree);
    verifyEquipSet(migratedList.get(8), "0.3.02", eqBackpack);
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) Equipment(pcgen.core.Equipment) EquipSet(pcgen.core.character.EquipSet) EquipmentList(pcgen.core.EquipmentList) List(java.util.List)

Example 38 with EquipSet

use of pcgen.core.character.EquipSet in project pcgen by PCGen.

the class CharacterFacadeImpl method createEquipmentSet.

/**
	 * @see pcgen.core.facade.CharacterFacade#createEquipmentSet(java.lang.String)
	 */
@Override
public EquipmentSetFacade createEquipmentSet(String setName) {
    String id = EquipmentSetFacadeImpl.getNewIdPath(charDisplay, null);
    EquipSet eSet = new EquipSet(id, setName);
    theCharacter.addEquipSet(eSet);
    final EquipmentSetFacadeImpl facade = new EquipmentSetFacadeImpl(delegate, theCharacter, eSet, dataSet, purchasedEquip, todoManager, this);
    equipmentSets.addElement(facade);
    return facade;
}
Also used : EquipSet(pcgen.core.character.EquipSet)

Example 39 with EquipSet

use of pcgen.core.character.EquipSet in project pcgen by PCGen.

the class EquipSetMigrationTest method testMigrateEquipSetsSimpleEquipSet.

/**
	 * Test method for {@link pcgen.io.migration.EquipSetMigration#migrateEquipSets(pcgen.core.PlayerCharacter, int[])}.
	 */
public void testMigrateEquipSetsSimpleEquipSet() {
    PlayerCharacter pc = getCharacter();
    EquipSet eSet = new EquipSet("0.1", "Battle gear");
    pc.addEquipSet(eSet);
    pc.setCalcEquipSetId("0.1");
    Equipment eqItemOne = EquipmentList.getEquipmentFromName("Item One", pc);
    eqItemOne.setOutputIndex(1);
    Equipment eqItemTwo = EquipmentList.getEquipmentFromName("Item Two", pc);
    eqItemTwo.setOutputIndex(2);
    Equipment eqItemThree = EquipmentList.getEquipmentFromName("Item Three", pc);
    eqItemThree.setOutputIndex(3);
    equipItem(pc, eqItemOne, 1.0f, "Carried", "0.1.1");
    equipItem(pc, eqItemTwo, 1.0f, "Carried", "0.1.6");
    equipItem(pc, eqItemThree, 1.0f, "Carried", "0.1.4");
    EquipSetMigration.migrateEquipSets(pc, preOrderedVer);
    List<EquipSet> migratedList = (List<EquipSet>) pc.getDisplay().getEquipSet();
    assertEquals("Unexpected number of equipsets", 4, migratedList.size());
    verifyEquipSet(migratedList.get(0), "0.1", null);
    verifyEquipSet(migratedList.get(1), "0.1.01", eqItemOne);
    verifyEquipSet(migratedList.get(2), "0.1.02", eqItemTwo);
    verifyEquipSet(migratedList.get(3), "0.1.03", eqItemThree);
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) Equipment(pcgen.core.Equipment) EquipSet(pcgen.core.character.EquipSet) EquipmentList(pcgen.core.EquipmentList) List(java.util.List)

Example 40 with EquipSet

use of pcgen.core.character.EquipSet in project pcgen by PCGen.

the class EquipSetMigrationTest method testMigrateEquipSetsNoMigrate.

/**
	 * Test method for {@link pcgen.io.migration.EquipSetMigration#migrateEquipSets(pcgen.core.PlayerCharacter, int[])}.
	 */
public void testMigrateEquipSetsNoMigrate() {
    PlayerCharacter pc = getCharacter();
    EquipSet eSet = new EquipSet("0.1", "Battle gear");
    pc.addEquipSet(eSet);
    pc.setCalcEquipSetId("0.1");
    Equipment eqItemOne = EquipmentList.getEquipmentFromName("Item One", pc);
    eqItemOne.setOutputIndex(1);
    Equipment eqItemTwo = EquipmentList.getEquipmentFromName("Item Two", pc);
    eqItemTwo.setOutputIndex(2);
    Equipment eqItemThree = EquipmentList.getEquipmentFromName("Item Three", pc);
    eqItemThree.setOutputIndex(3);
    equipItem(pc, eqItemOne, 1.0f, "Carried", "0.1.1");
    equipItem(pc, eqItemTwo, 1.0f, "Carried", "0.1.6");
    equipItem(pc, eqItemThree, 1.0f, "Carried", "0.1.4");
    EquipSetMigration.migrateEquipSets(pc, postOrderedVer);
    List<EquipSet> migratedList = (List<EquipSet>) pc.getDisplay().getEquipSet();
    assertEquals("Unexpected number of equipsets", 4, migratedList.size());
    verifyEquipSet(migratedList.get(0), "0.1", null);
    verifyEquipSet(migratedList.get(1), "0.1.1", eqItemOne);
    verifyEquipSet(migratedList.get(2), "0.1.6", eqItemTwo);
    verifyEquipSet(migratedList.get(3), "0.1.4", eqItemThree);
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) Equipment(pcgen.core.Equipment) EquipSet(pcgen.core.character.EquipSet) EquipmentList(pcgen.core.EquipmentList) List(java.util.List)

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