Search in sources :

Example 86 with PlayerCharacter

use of pcgen.core.PlayerCharacter 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);
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) Equipment(pcgen.core.Equipment) EquipSet(pcgen.core.character.EquipSet) EquipmentList(pcgen.core.EquipmentList) List(java.util.List)

Example 87 with PlayerCharacter

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

Example 88 with PlayerCharacter

use of pcgen.core.PlayerCharacter 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);
    }
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) Equipment(pcgen.core.Equipment) HashMap(java.util.HashMap) EquipSet(pcgen.core.character.EquipSet) EquipNode(pcgen.facade.core.EquipmentSetFacade.EquipNode)

Example 89 with PlayerCharacter

use of pcgen.core.PlayerCharacter in project pcgen by PCGen.

the class Gui2InfoFactoryTest method testGetChoices.

/**
	 * Test the getChoices method with text choices. 
	 */
public void testGetChoices() {
    PlayerCharacter pc = getCharacter();
    Gui2InfoFactory ca = new Gui2InfoFactory(pc);
    Ability choiceAbility = TestHelper.makeAbility("Skill Focus", AbilityCategory.FEAT, "General");
    choiceAbility.put(ObjectKey.MULTIPLE_ALLOWED, Boolean.TRUE);
    StringToken st = new plugin.lsttokens.choose.StringToken();
    ParseResult pr = st.parseToken(Globals.getContext(), choiceAbility, "SKILL|Perception|Acrobatics");
    assertTrue(pr.passed());
    Globals.getContext().commit();
    pcgenFinalize(choiceAbility, "Perception", pc, AbilityCategory.FEAT);
    assertEquals("Incorrect single choice", "Perception", ca.getChoices(choiceAbility));
    pcgenFinalize(choiceAbility, "Acrobatics", pc, AbilityCategory.FEAT);
    assertEquals("Incorrect multiple choice", "Acrobatics, Perception", ca.getChoices(choiceAbility));
}
Also used : Ability(pcgen.core.Ability) PlayerCharacter(pcgen.core.PlayerCharacter) ParseResult(pcgen.rules.persistence.token.ParseResult) StringToken(plugin.lsttokens.choose.StringToken)

Example 90 with PlayerCharacter

use of pcgen.core.PlayerCharacter in project pcgen by PCGen.

the class AbilityTokenTest method setUp.

/*
	 * @see TestCase#setUp()
	 */
@Override
protected void setUp() throws Exception {
    super.setUp();
    PlayerCharacter character = getCharacter();
    // Make some ability categories and add them to the game mode
    Ability ab1 = TestHelper.makeAbility("Perform (Dance)", AbilityCategory.FEAT, "General.Fighter");
    ab1.put(ObjectKey.MULTIPLE_ALLOWED, Boolean.FALSE);
    ab1.put(ObjectKey.VISIBILITY, Visibility.DEFAULT);
    List<Aspect> colourList = new ArrayList<>();
    colourList.add(new Aspect("Colour", "Green"));
    ab1.addToMapFor(MapKey.ASPECT, AspectName.getConstant("Colour"), colourList);
    List<Aspect> sizeList = new ArrayList<>();
    sizeList.add(new Aspect("Size", "L"));
    ab1.addToMapFor(MapKey.ASPECT, AspectName.getConstant("Size"), sizeList);
    List<Aspect> shapeList = new ArrayList<>();
    Aspect cube = new Aspect("Shape", "Cube");
    Prerequisite prereq = new Prerequisite();
    prereq.setKind("ALIGN");
    prereq.setKey("LG");
    prereq.setOperator(PrerequisiteOperator.EQ);
    cube.addPrerequisite(prereq);
    shapeList.add(cube);
    shapeList.add(new Aspect("Shape", "Icosahedron"));
    ab1.addToMapFor(MapKey.ASPECT, AspectName.getConstant("Shape"), shapeList);
    List<Aspect> sidesList = new ArrayList<>();
    sidesList.add(new Aspect("Sides", "20"));
    ab1.addToMapFor(MapKey.ASPECT, AspectName.getConstant("Sides"), sidesList);
    List<Aspect> ageList = new ArrayList<>();
    ageList.add(new Aspect("Age In Years", "2000"));
    ab1.addToMapFor(MapKey.ASPECT, AspectName.getConstant("Age In Years"), ageList);
    addAbility(AbilityCategory.FEAT, ab1);
    TestHelper.makeSkill("Bluff", "Charisma", cha, true, SkillArmorCheck.NONE);
    TestHelper.makeSkill("Listen", "Wisdom", wis, true, SkillArmorCheck.NONE);
    skillFocus = TestHelper.makeAbility("Skill Focus", AbilityCategory.FEAT, "General");
    BonusObj aBonus = Bonus.newBonus(Globals.getContext(), "SKILL|LIST|3");
    if (aBonus != null) {
        skillFocus.addToListFor(ListKey.BONUS, aBonus);
    }
    skillFocus.put(ObjectKey.MULTIPLE_ALLOWED, true);
    Globals.getContext().unconditionallyProcess(skillFocus, "CHOOSE", "SKILL|ALL");
    AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, skillFocus, "KEY_Bluff");
    AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, skillFocus, "KEY_Listen");
    character.calcActiveBonuses();
}
Also used : Ability(pcgen.core.Ability) PlayerCharacter(pcgen.core.PlayerCharacter) BonusObj(pcgen.core.bonus.BonusObj) ArrayList(java.util.ArrayList) Aspect(pcgen.cdom.helper.Aspect) Prerequisite(pcgen.core.prereq.Prerequisite)

Aggregations

PlayerCharacter (pcgen.core.PlayerCharacter)438 PreParserFactory (pcgen.persistence.lst.prereq.PreParserFactory)89 PCClass (pcgen.core.PCClass)61 LoadContext (pcgen.rules.context.LoadContext)58 Ability (pcgen.core.Ability)54 Equipment (pcgen.core.Equipment)41 PCTemplate (pcgen.core.PCTemplate)38 EquipSet (pcgen.core.character.EquipSet)32 BonusObj (pcgen.core.bonus.BonusObj)29 Race (pcgen.core.Race)28 CharID (pcgen.cdom.enumeration.CharID)25 ExportHandler (pcgen.io.ExportHandler)24 Test (org.junit.Test)20 ArrayList (java.util.ArrayList)16 PreClassTester (plugin.pretokens.test.PreClassTester)16 CDOMObject (pcgen.cdom.base.CDOMObject)15 Skill (pcgen.core.Skill)14 CNAbility (pcgen.cdom.content.CNAbility)13 URI (java.net.URI)11 URISyntaxException (java.net.URISyntaxException)11