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