Search in sources :

Example 61 with PCClass

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

the class KitLevelAbility method doApplication.

private boolean doApplication(PlayerCharacter aPC) {
    PCClass theClass = theClassName.get();
    PCClass classKeyed = aPC.getClassKeyed(theClass.getKeyName());
    if (classKeyed == null) {
    //Error?
    }
    //Look for ADD in class
    List<PersistentTransitionChoice<?>> adds = theClass.getListFor(ListKey.ADD);
    if (adds == null) {
    //Error?
    }
    for (PersistentTransitionChoice<?> ch : adds) {
        if (add.equals(ch)) {
            process(aPC, classKeyed, ch);
            return true;
        }
    }
    return false;
}
Also used : PersistentTransitionChoice(pcgen.cdom.base.PersistentTransitionChoice) PCClass(pcgen.core.PCClass)

Example 62 with PCClass

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

the class GlobalCSkillTest method testList.

@Test
public void testList() throws PersistenceLayerException {
    PCTemplate source = create(PCTemplate.class, "Source");
    ParseResult result = token.parseToken(context, source, "LIST");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    result = CHOOSE_SKILL_TOKEN.parseToken(context, source, "Granted");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    PCClass wizard = create(PCClass.class, "Wizard");
    finishLoad();
    pc.incrementClassLevel(1, wizard);
    assertFalse(globalAddedSkillCostFacet.contains(id, SkillCost.CLASS, granted));
    assertEquals(SkillCost.CROSS_CLASS, pc.getSkillCostForClass(granted, wizard));
    templateInputFacet.directAdd(id, source, granted);
    pc.calcActiveBonuses();
    assertEquals(SkillCost.CLASS, pc.getSkillCostForClass(granted, wizard));
    assertTrue(globalAddedSkillCostFacet.contains(id, SkillCost.CLASS, granted));
    templateInputFacet.remove(id, source);
    pc.calcActiveBonuses();
    assertFalse(globalAddedSkillCostFacet.contains(id, SkillCost.CLASS, granted));
}
Also used : ParseResult(pcgen.rules.persistence.token.ParseResult) PCTemplate(pcgen.core.PCTemplate) PCClass(pcgen.core.PCClass) Test(org.junit.Test) AbstractContentTokenTest(tokencontent.testsupport.AbstractContentTokenTest)

Example 63 with PCClass

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

the class GlobalCcSkillTest method testList.

@Test
public void testList() throws PersistenceLayerException {
    PCTemplate source = create(PCTemplate.class, "Source");
    ParseResult result = token.parseToken(context, source, "LIST");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    result = CHOOSE_SKILL_TOKEN.parseToken(context, source, "Granted");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    PCClass wizard = create(PCClass.class, "Wizard");
    new ExclusiveToken().parseToken(context, granted, "Yes");
    finishLoad();
    pc.incrementClassLevel(1, wizard);
    assertFalse(globalAddedSkillCostFacet.contains(id, SkillCost.CROSS_CLASS, granted));
    assertEquals(SkillCost.EXCLUSIVE, pc.getSkillCostForClass(granted, wizard));
    templateInputFacet.directAdd(id, source, granted);
    pc.calcActiveBonuses();
    assertEquals(SkillCost.CROSS_CLASS, pc.getSkillCostForClass(granted, wizard));
    assertTrue(globalAddedSkillCostFacet.contains(id, SkillCost.CROSS_CLASS, granted));
    templateInputFacet.remove(id, source);
    pc.calcActiveBonuses();
    assertFalse(globalAddedSkillCostFacet.contains(id, SkillCost.CROSS_CLASS, granted));
}
Also used : ParseResult(pcgen.rules.persistence.token.ParseResult) PCTemplate(pcgen.core.PCTemplate) PCClass(pcgen.core.PCClass) ExclusiveToken(plugin.lsttokens.skill.ExclusiveToken) Test(org.junit.Test) AbstractContentTokenTest(tokencontent.testsupport.AbstractContentTokenTest)

Example 64 with PCClass

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

the class CharacterLevelsFacadeImpl method refreshClassList.

/**
	 * Update the list of class levels from scratch to match the current
	 * state of the character. 
	 */
private void refreshClassList() {
    List<PCClass> newClasses = charDisplay.getClassList();
    Collection<PCLevelInfo> levelInfo = charDisplay.getLevelInfo();
    Map<String, Integer> levelCount = new HashMap<>();
    Map<String, PCClass> classMap = new HashMap<>();
    for (PCClass pcClass : newClasses) {
        levelCount.put(pcClass.getKeyName(), 1);
        classMap.put(pcClass.getKeyName(), pcClass);
    }
    classLevels.clear();
    clearContents();
    for (PCLevelInfo lvlInfo : levelInfo) {
        final String classKeyName = lvlInfo.getClassKeyName();
        PCClass currClass = classMap.get(classKeyName);
        if (currClass == null) {
            Logging.errorPrint("No PCClass found for '" + classKeyName + "' in character's class list: " + newClasses);
            return;
        }
        int clsLvlNum = levelCount.get(classKeyName);
        levelCount.put(classKeyName, clsLvlNum + 1);
        classLevels.add(currClass);
        CharacterLevelFacadeImpl levelFI = new CharacterLevelFacadeImpl(currClass, classLevels.size());
        addElement(levelFI);
    //PCClassLevel classLevel = currClass.getClassLevel(clsLvlNum);
    }
    updateSkillsTodo();
}
Also used : HashMap(java.util.HashMap) PCLevelInfo(pcgen.core.pclevelinfo.PCLevelInfo) PCClass(pcgen.core.PCClass)

Example 65 with PCClass

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

the class PCClassLoader method getCopy.

@Override
public PCClass getCopy(LoadContext context, String baseName, String copyName, CampaignSourceEntry source) throws PersistenceLayerException {
    PCClass copy = super.getCopy(context, baseName, copyName, source);
    PCClassKeyChange.changeReferences(baseName, copy);
    return copy;
}
Also used : PCClass(pcgen.core.PCClass)

Aggregations

PCClass (pcgen.core.PCClass)359 Test (org.junit.Test)96 PlayerCharacter (pcgen.core.PlayerCharacter)61 Skill (pcgen.core.Skill)55 ArrayList (java.util.ArrayList)35 Domain (pcgen.core.Domain)30 LoadContext (pcgen.rules.context.LoadContext)28 PCClassLevel (pcgen.cdom.inst.PCClassLevel)26 CDOMObject (pcgen.cdom.base.CDOMObject)23 CharacterSpell (pcgen.core.character.CharacterSpell)20 Spell (pcgen.core.spell.Spell)20 StringTokenizer (java.util.StringTokenizer)19 CharID (pcgen.cdom.enumeration.CharID)19 ClassSource (pcgen.cdom.helper.ClassSource)19 PreClassTester (plugin.pretokens.test.PreClassTester)16 SkillCost (pcgen.cdom.enumeration.SkillCost)15 ParseResult (pcgen.rules.persistence.token.ParseResult)15 Ability (pcgen.core.Ability)14 Race (pcgen.core.Race)14 BonusObj (pcgen.core.bonus.BonusObj)14