use of pcgen.core.Equipment in project pcgen by PCGen.
the class EquipSetMigrationTest method testRenumberEquipmentSetsNestedEquipSet.
/**
* Test method for {@link pcgen.io.migration.EquipSetMigration#renumberEquipmentSets(pcgen.core.PlayerCharacter)}.
*/
public void testRenumberEquipmentSetsNestedEquipSet() {
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(4);
Equipment eqBackpack = EquipmentList.getEquipmentFromName("Backpack", pc);
eqBackpack.setOutputIndex(1);
Equipment eqItemTwo = EquipmentList.getEquipmentFromName("Item Two", pc);
eqItemTwo.setOutputIndex(3);
Equipment eqItemThree = EquipmentList.getEquipmentFromName("Item Three", pc);
eqItemThree.setOutputIndex(2);
equipItem(pc, eqItemOne, 1.0f, "Carried", "0.1.1");
equipItem(pc, eqBackpack, 1.0f, "Carried", "0.1.2");
equipItem(pc, eqItemTwo, 1.0f, "Carried", "0.1.2.1");
equipItem(pc, eqItemThree, 1.0f, "Carried", "0.1.2.2");
EquipSetMigration.renumberEquipmentSets(pc);
List<EquipSet> migratedList = (List<EquipSet>) pc.getDisplay().getEquipSet();
assertEquals("Unexpected number of equipsets", 5, migratedList.size());
verifyEquipSet(migratedList.get(0), "0.1", null);
verifyEquipSet(migratedList.get(1), "0.1.02", eqItemOne);
verifyEquipSet(migratedList.get(2), "0.1.01", eqBackpack);
verifyEquipSet(migratedList.get(3), "0.1.01.02", eqItemTwo);
verifyEquipSet(migratedList.get(4), "0.1.01.01", eqItemThree);
}
use of pcgen.core.Equipment in project pcgen by PCGen.
the class EquipmentSetFacadeImplTest method prepareEquipmentSet.
private EquipmentSetFacadeImpl prepareEquipmentSet() {
PlayerCharacter pc = getCharacter();
EquipSet es = new EquipSet("0.1", "Unit Test Equip");
pc.addEquipSet(es);
Equipment item = new Equipment();
item.setName(SATCHEL);
Equipment item2 = new Equipment();
item2.setName(BOOK);
Equipment item3 = new Equipment();
item3.setName(QUARTERSTAFF);
Equipment item4 = new Equipment();
item4.setName(BEDROLL);
EquipSet satchelEs = addEquipToEquipSet(pc, es, item, 1.0f);
addEquipToEquipSet(pc, satchelEs, item2, 1.0f);
addEquipToEquipSet(pc, es, item3, 1.0f);
addEquipToEquipSet(pc, es, item4, 1.0f);
return new EquipmentSetFacadeImpl(uiDelegate, getCharacter(), es, dataset, equipmentList, todoManager, null);
}
use of pcgen.core.Equipment in project pcgen by PCGen.
the class EquipmentSetFacadeImplTest method testSlotManagementOnInitWithEquipment.
/**
* Check that EquipmentSetFacadeImpl when initialised with a dataset
* containing equipment hides and shows the correct weapon slots.
*/
public void testSlotManagementOnInitWithEquipment() {
PlayerCharacter pc = getCharacter();
EquipSet es = new EquipSet("0.1", "Unit Test Equip");
Equipment weapon = new Equipment();
weapon.setName("Morningstar");
addEquipToEquipSet(pc, es, weapon, 1.0f, LOC_PRIMARY);
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("Morningstar");
assertNotNull("Morningstar should be present", testNode);
assertEquals("Morningstar type", EquipNode.NodeType.EQUIPMENT, testNode.getNodeType());
assertEquals("Morningstar location", LOC_PRIMARY, esfi.getLocation(testNode));
// Test for removed slots
String[] removedSlots = { "Primary Hand", "Double Weapon", "Both Hands" };
for (String slotName : removedSlots) {
testNode = nodeMap.get(slotName);
assertNull(slotName + " should not be present", testNode);
}
// Test for still present slots
String[] retainedSlots = { "Secondary Hand", "Ring" };
for (String slotName : retainedSlots) {
testNode = nodeMap.get(slotName);
assertNotNull(slotName + " should be present", testNode);
}
}
use of pcgen.core.Equipment in project pcgen by PCGen.
the class PreArmorTypeTest method testPassesPrerequisitePlayerCharacter.
/*
* Class under test for int passes(Prerequisite, PlayerCharacter)
*/
public void testPassesPrerequisitePlayerCharacter() {
final PlayerCharacter character = getCharacter();
final Equipment armor = new Equipment();
armor.setName("Leather");
armor.addToListFor(ListKey.TYPE, Type.getConstant("ARMOR"));
character.addEquipment(armor);
final Prerequisite prereq = new Prerequisite();
prereq.setKind("armortype");
prereq.setKey("CHAINMAIL");
prereq.setOperand("1");
prereq.setOperator(PrerequisiteOperator.EQ);
assertFalse("Doesn't have chainmail equipped", PrereqHandler.passes(prereq, character, null));
armor.setName("Chainmail");
assertFalse("Chainmail is not equipped", PrereqHandler.passes(prereq, character, null));
armor.setIsEquipped(true, character);
character.doAfavorForAunitTestThatIgnoresEquippingRules();
assertTrue("Chainmail is equipped", PrereqHandler.passes(prereq, character, null));
armor.setName("Chainmail (Masterwork)");
assertFalse("Should be an exact match only", PrereqHandler.passes(prereq, character, null));
prereq.setKey("CHAINMAIL%");
assertTrue("Should be allow wildcard match", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.core.Equipment in project pcgen by PCGen.
the class PreArmorTypeTest method testType.
/**
* Test armor type tests
* @throws Exception
*/
public void testType() throws Exception {
final PlayerCharacter character = getCharacter();
final Equipment armor = new Equipment();
armor.setName("Chainmail");
character.addEquipment(armor);
armor.setIsEquipped(true, character);
character.doAfavorForAunitTestThatIgnoresEquippingRules();
Prerequisite prereq = new Prerequisite();
prereq.setKind("armortype");
prereq.setKey("TYPE=Medium");
prereq.setOperand("1");
prereq.setOperator(PrerequisiteOperator.EQ);
assertFalse("Equipment has no type", PrereqHandler.passes(prereq, character, null));
armor.addType(Type.getConstant("ARMOR"));
armor.addType(Type.getConstant("MEDIUM"));
assertTrue("Armor is medium", PrereqHandler.passes(prereq, character, null));
prereq.setKey("TYPE.Heavy");
assertFalse("Armor is not heavy", PrereqHandler.passes(prereq, character, null));
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREARMORTYPE:2,TYPE=Medium,Full%");
assertFalse("Armor is not Full something", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREARMORTYPE:2,TYPE=Medium,Chain%");
assertTrue("Armor is medium and Chain", PrereqHandler.passes(prereq, character, null));
}
Aggregations