Search in sources :

Example 16 with PCClass

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

the class DomainSpellsFacet method dataAdded.

/**
	 * Adds Domain Spells allowed / granted to the Player Character due to the
	 * Domain selections of the Player Character.
	 * 
	 * Triggered when one of the Facets to which DomainSpellsFacet listens fires
	 * a DataFacetChangeEvent to indicate a Domain was added to a Player
	 * Character.
	 * 
	 * @param dfce
	 *            The DataFacetChangeEvent containing the information about the
	 *            change
	 * 
	 * @see pcgen.cdom.facet.event.DataFacetChangeListener#dataAdded(pcgen.cdom.facet.event.DataFacetChangeEvent)
	 */
@Override
public void dataAdded(DataFacetChangeEvent<CharID, Domain> dfce) {
    Domain domain = dfce.getCDOMObject();
    CharID id = dfce.getCharID();
    ClassSource source = domainFacet.getSource(id, domain);
    if (source != null) {
        String classKey = source.getPcclass().getKeyName();
        PCClass domainClass = getClassKeyed(id, classKey);
        if (domainClass != null) {
            PlayerCharacter pc = trackingFacet.getPC(id);
            final int maxLevel = pc.getSpellSupport(domainClass).getMaxCastLevel();
            DomainApplication.addSpellsToClassForLevels(pc, domain, domainClass, 0, maxLevel);
        }
    }
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) Domain(pcgen.core.Domain) PCClass(pcgen.core.PCClass) CharID(pcgen.cdom.enumeration.CharID) ClassSource(pcgen.cdom.helper.ClassSource)

Example 17 with PCClass

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

the class PCLevelInfo method getBonusSkillPool.

/**
	 * Calculate the number of bonus skill points added by this level.
	 *
	 * @return  the number of bonus skill points added by this level
	 */
private int getBonusSkillPool(PlayerCharacter aPC) {
    int returnValue = 0;
    final PCClass aClass = aPC.getClassKeyed(classKeyName);
    final String purchaseName = SettingsHandler.getGame().getPurchaseModeMethodName();
    if (purchaseName != null) {
        PointBuyMethod pbm = SettingsHandler.getGame().getContext().getReferenceContext().silentlyGetConstructedCDOMObject(PointBuyMethod.class, purchaseName);
        List<BonusObj> bonusList = BonusUtilities.getBonusFromList(pbm.getBonuses(), "SKILLPOOL", "NUMBER");
        returnValue += (int) aPC.calcBonusFromList(bonusList, null);
    }
    if (aClass != null) {
        // These bonuses apply to the level or higher. We have to add and then remove
        // the previous to get the effective level bonus
        returnValue += (int) aClass.getBonusTo("SKILLPOOL", "NUMBER", classLevel, aPC);
        returnValue -= (int) aClass.getBonusTo("SKILLPOOL", "NUMBER", classLevel - 1, aPC);
    }
    if (classLevel == 1) {
        returnValue += (int) aPC.getTotalBonusTo("SKILLPOOL", "CLASS." + classKeyName);
    }
    returnValue += (int) aPC.getTotalBonusTo("SKILLPOOL", "CLASS." + classKeyName + ";LEVEL." + Integer.toString(classLevel));
    returnValue += (int) aPC.getTotalBonusTo("SKILLPOOL", "LEVEL." + aPC.getCharacterLevel(this));
    return returnValue;
}
Also used : BonusObj(pcgen.core.bonus.BonusObj) PointBuyMethod(pcgen.core.PointBuyMethod) PCClass(pcgen.core.PCClass)

Example 18 with PCClass

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

the class PCMaxCastableDomainTermEvaluator method resolve.

@Override
public Float resolve(PlayerCharacter pc) {
    Domain domain = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Domain.class, domainKey);
    if (domain == null) {
        return 0.0f;
    }
    ClassSource source = pc.getDomainSource(domain);
    if (source == null) {
        return 0.0f;
    }
    String classKey = source.getPcclass().getKeyName();
    PCClass spClass = pc.getClassKeyed(classKey);
    int cutoff = pc.getSpellSupport(spClass).getHighestLevelSpell();
    Float max = 0.0f;
    if (pc.getSpellSupport(spClass).hasCastList()) {
        for (int i = 0; i < cutoff; i++) {
            if (pc.getSpellSupport(spClass).getCastForLevel(i, pc) != 0) {
                max = Math.max(max, i);
            }
        }
    } else {
        for (int i = 0; i < cutoff; i++) {
            if (pc.getSpellSupport(spClass).getKnownForLevel(i, pc) != 0) {
                max = Math.max(max, i);
            }
        }
    }
    return max;
}
Also used : Domain(pcgen.core.Domain) PCClass(pcgen.core.PCClass) ClassSource(pcgen.cdom.helper.ClassSource)

Example 19 with PCClass

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

the class PCMaxLevelTermEvaluator method resolve.

@Override
public Float resolve(PlayerCharacter pc) {
    if (classKey.isEmpty()) {
        return 0.0f;
    }
    PCClass aClass = pc.getClassKeyed(classKey);
    if (aClass == null) {
        //PC Doesn't have class
        return 0.0f;
    }
    int level = pc.getSpellSupport(aClass).getMaxSpellLevelForClassLevel(pc.getDisplay().getLevel(aClass));
    return Integer.valueOf(level).floatValue();
}
Also used : PCClass(pcgen.core.PCClass)

Example 20 with PCClass

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

the class PCSPellBaseStatScoreEvaluatorTermEvaluator method resolve.

@Override
public Float resolve(PlayerCharacter pc) {
    final PCClass aClass = pc.getClassKeyed(classKey);
    if (aClass == null) {
        return 0.0f;
    }
    CDOMSingleRef<PCStat> ss = aClass.get(ObjectKey.SPELL_STAT);
    if (ss == null) {
        return 10.0f;
    }
    return (float) pc.getDisplay().getStatModFor(ss.get());
}
Also used : PCClass(pcgen.core.PCClass) PCStat(pcgen.core.PCStat)

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