Search in sources :

Example 66 with PCClass

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

the class ClassSkillListFacet method levelChanged.

@Override
public void levelChanged(ClassLevelChangeEvent lce) {
    if ((lce.getOldLevel() == 0) && (lce.getNewLevel() > 0)) {
        PCClass cl = lce.getPCClass();
        CharID id = lce.getCharID();
        TransitionChoice<ClassSkillList> csc = cl.get(ObjectKey.SKILLLIST_CHOICE);
        if (csc == null) {
            ClassSkillList l = cl.get(ObjectKey.CLASS_SKILLLIST);
            if (l != null) {
                defaultClassSkillListFacet.add(id, cl, l, cl);
            }
        } else {
            PlayerCharacter pc = trackingFacet.getPC(id);
            for (ClassSkillList st : csc.driveChoice(pc)) {
                add(id, cl, st, cl);
            }
        }
    } else if ((lce.getOldLevel() > 0) && (lce.getNewLevel() == 0)) {
        removeAllFromSource(lce.getCharID(), lce.getPCClass());
    }
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PCClass(pcgen.core.PCClass) CharID(pcgen.cdom.enumeration.CharID) ClassSkillList(pcgen.cdom.list.ClassSkillList)

Example 67 with PCClass

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

the class ClassSkillListFacet method dataAdded.

@Override
public void dataAdded(ScopeFacetChangeEvent<CharID, PCClass, String> dfce) {
    PCClass cl = dfce.getScope();
    String subClassKey = dfce.getCDOMObject();
    SubClass subclass = cl.getSubClassKeyed(subClassKey);
    if (subclass != null) {
        ClassSkillList scl = subclass.get(ObjectKey.CLASS_SKILLLIST);
        defaultClassSkillListFacet.add(dfce.getCharID(), cl, scl, subclass);
    }
}
Also used : SubClass(pcgen.core.SubClass) PCClass(pcgen.core.PCClass) ClassSkillList(pcgen.cdom.list.ClassSkillList)

Example 68 with PCClass

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

the class ClassSkillListFacet method dataRemoved.

@Override
public void dataRemoved(ScopeFacetChangeEvent<CharID, PCClass, String> dfce) {
    PCClass cl = dfce.getScope();
    String subClassKey = dfce.getCDOMObject();
    SubClass subclass = cl.getSubClassKeyed(subClassKey);
    if (subclass != null) {
        ClassSkillList scl = subclass.get(ObjectKey.CLASS_SKILLLIST);
        defaultClassSkillListFacet.add(dfce.getCharID(), cl, scl, subclass);
    }
}
Also used : SubClass(pcgen.core.SubClass) PCClass(pcgen.core.PCClass) ClassSkillList(pcgen.cdom.list.ClassSkillList)

Example 69 with PCClass

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

the class ClassSkillChoiceActor method applyChoice.

/**
	 * Applies the given Skill choice to the given PlayerCharacter. The given
	 * Skill is added as a class skill for the PCClass provided during
	 * construction of this ClassSkillChoiceActor. If the number of ranks
	 * provided during construction of this ClassSkillChoiceActor was not null
	 * or zero, then ranks are also applied to the given skill.
	 * 
	 * @param owner
	 *            The owning object for this choice.
	 * @param choice
	 *            The Skill which should be added as a Class Skill for the
	 *            PCClass provided during construction of this
	 *            ClassSkillChoiceActor
	 * @param pc
	 *            The PlayerCharacter to which the changes driven by this
	 *            ClassSkillChoiceActor should be applied.
	 */
@Override
public void applyChoice(CDOMObject owner, Skill choice, PlayerCharacter pc) {
    PCClass pcc = getSourceClass(pc);
    if (pcc == null) {
        Logging.errorPrint("Unable to find the pc's class " + source + " to apply skill choices to.");
        return;
    }
    pc.addLocalCost(pcc, choice, SkillCost.CLASS, owner);
    if (applyRank != null) {
        if (owner instanceof PCClassLevel) {
            // Ensure that the skill points for this level are already calculated.
            PCClassLevel classLevel = (PCClassLevel) owner;
            PCClass pcClass = (PCClass) classLevel.getSafe(ObjectKey.PARENT);
            int levelIndex = 1;
            for (PCLevelInfo lvlInfo : pc.getLevelInfo()) {
                if (lvlInfo.getClassKeyName() == pcClass.getKeyName() && lvlInfo.getClassLevel() == classLevel.getSafe(IntegerKey.LEVEL)) {
                    pc.checkSkillModChangeForLevel(pcClass, lvlInfo, classLevel, levelIndex++);
                    break;
                }
            }
        }
        String result = SkillRankControl.modRanks(applyRank, pcc, false, pc, choice);
        if (StringUtils.isNotEmpty(result)) {
            Logging.errorPrint("Unable to apply {0} ranks of {1}. Error: {2}", applyRank, choice, result);
        }
    }
}
Also used : PCLevelInfo(pcgen.core.pclevelinfo.PCLevelInfo) PCClass(pcgen.core.PCClass) PCClassLevel(pcgen.cdom.inst.PCClassLevel)

Example 70 with PCClass

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

the class SpellLevel method decodeChoice.

public static SpellLevel decodeChoice(String persistentFormat) {
    int loc = persistentFormat.indexOf(";LEVEL.");
    String classString;
    String levelString;
    if (loc == -1) {
        /*
			 * Handle old persistence
			 */
        int spaceLoc = persistentFormat.indexOf(' ');
        classString = persistentFormat.substring(0, spaceLoc);
        levelString = persistentFormat.substring(spaceLoc + 1);
    } else {
        String classText = persistentFormat.substring(0, 6);
        if (!"CLASS.".equals(classText)) {
            return null;
        }
        classString = persistentFormat.substring(6, loc);
        levelString = persistentFormat.substring(loc + 7);
    }
    PCClass pcc = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(PCClass.class, classString);
    try {
        int level = Integer.parseInt(levelString);
        return new SpellLevel(pcc, level);
    } catch (NumberFormatException e) {
        return null;
    }
}
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