Search in sources :

Example 26 with Skill

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

the class MonCSkillToSkillCostFacet method dataAdded.

@Override
public void dataAdded(DataFacetChangeEvent<CharID, PCClass> dfce) {
    PCClass cl = dfce.getCDOMObject();
    if (cl.isMonster()) {
        CharID id = dfce.getCharID();
        SkillCost cost = SkillCost.CLASS;
        for (Skill sk : monsterCSkillFacet.getSet(id)) {
            add(id, cl, cost, sk, monsterCSkillFacet);
        }
    }
}
Also used : Skill(pcgen.core.Skill) SkillCost(pcgen.cdom.enumeration.SkillCost) PCClass(pcgen.core.PCClass) CharID(pcgen.cdom.enumeration.CharID)

Example 27 with Skill

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

the class ChooserUtilities method getConfiguredController.

public static <T> ChoiceManagerList<T> getConfiguredController(final ChooseDriver aPObject, final PlayerCharacter aPC, final AbilityCategory category, List<String> reservedList) {
    ChoiceManagerList aMan = getChoiceManager(aPObject, aPC);
    if (aMan == null) {
        return null;
    }
    if (aPObject instanceof CNAbility) {
        CNAbility driver = (CNAbility) aPObject;
        Ability a = driver.getAbility();
        AbilityCategory cat;
        if (category == null) {
            cat = SettingsHandler.getGame().getAbilityCategory(a.getCategory());
        } else {
            cat = category;
        }
        aMan.setController(new AbilityChooseController(a, cat, aPC, aMan));
        List<CNAbility> abilities = aPC.getMatchingCNAbilities(a);
        for (CNAbility cna : abilities) {
            reservedList.addAll(aPC.getAssociationList(cna));
        }
    } else if (aPObject instanceof Skill) {
        Skill s = (Skill) aPObject;
        aMan.setController(new SkillChooseController(s, aPC));
    }
    return aMan;
}
Also used : CNAbility(pcgen.cdom.content.CNAbility) Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) Skill(pcgen.core.Skill) AbilityCategory(pcgen.core.AbilityCategory)

Example 28 with Skill

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

the class SkillChoice method getSkill.

/**
	 * Gets the skill associated with this chioce.  If this choice is a group
	 * of choices, the specific skill will be selected randomly.
	 * 
	 * @return A <tt>Skill</tt>
	 */
public Skill getSkill() {
    final Skill skill = theSkillList.getRandomValue();
    theSkillList.add(skill, NPCGenerator.getSubSkillWeightAdd());
    return skill;
}
Also used : Skill(pcgen.core.Skill)

Example 29 with Skill

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

the class PCCountSkillsTermEvaluator method resolve.

@Override
public Float resolve(PlayerCharacter pc) {
    int count = 0;
    //TODO This is a bug, it assumes export
    final List<Skill> skills = pc.getDisplay().getPartialSkillList(View.VISIBLE_EXPORT);
    SkillFilter filter = SkillFilter.getByToken(filterToken);
    if (filter == null || filter == SkillFilter.Selected) {
        filter = pc.getSkillFilter();
    }
    for (Skill sk : skills) {
        if (pc.includeSkill(sk, filter) && sk.qualifies(pc, null)) {
            count++;
        }
    }
    return (float) count;
}
Also used : Skill(pcgen.core.Skill) SkillFilter(pcgen.cdom.enumeration.SkillFilter)

Example 30 with Skill

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

the class KitSkill method testApply.

@Override
public boolean testApply(Kit aKit, PlayerCharacter aPC, List<String> warnings) {
    skillsToAdd = new ArrayList<>();
    List<Skill> skillChoices = getSkillChoices(aPC);
    if (skillChoices == null || skillChoices.isEmpty()) {
        // They didn't make a choice so don't add any ranks.
        return false;
    }
    for (Skill skill : skillChoices) {
        BigDecimal ranksLeftToAdd = getRank();
        if (ranksLeftToAdd == null) {
            ranksLeftToAdd = BigDecimal.ONE;
        }
        double ranksLeft = ranksLeftToAdd.doubleValue();
        List<PCClass> classList = new ArrayList<>();
        if (className != null) {
            String classKey = className.get().getKeyName();
            // Make sure if they specified a class to add from we try that
            // class first.
            PCClass pcClass = aPC.getClassKeyed(classKey);
            if (pcClass != null) {
                classList.add(pcClass);
            } else {
                warnings.add("SKILL: Could not find specified class " + classKey + " in PC to add ranks from.");
            }
        }
        for (PCClass pcClass : aPC.getClassSet()) {
            if (!classList.contains(pcClass)) {
                classList.add(pcClass);
            }
        }
        // Try and find a class we can add them from.
        boolean oldImporting = aPC.isImporting();
        aPC.setImporting(true);
        for (PCClass pcClass : classList) {
            final KitSkillAdd sta = addRanks(aPC, pcClass, skill, ranksLeft, isFree(), warnings);
            if (sta != null) {
                skillsToAdd.add(sta);
                ranksLeft -= sta.getRanks();
                if (ranksLeft <= 0.0) {
                    break;
                }
            }
        }
        aPC.setImporting(oldImporting);
        if (ranksLeft > 0.0) {
            warnings.add("SKILL: Could not add " + ranksLeft + " ranks to " + skill.getKeyName() + ". Not enough points.");
        }
    }
    return true;
}
Also used : Skill(pcgen.core.Skill) ArrayList(java.util.ArrayList) PCClass(pcgen.core.PCClass) BigDecimal(java.math.BigDecimal)

Aggregations

Skill (pcgen.core.Skill)165 Test (org.junit.Test)60 PCClass (pcgen.core.PCClass)55 ArrayList (java.util.ArrayList)29 CDOMReference (pcgen.cdom.base.CDOMReference)24 CharID (pcgen.cdom.enumeration.CharID)23 SkillCost (pcgen.cdom.enumeration.SkillCost)16 CDOMObject (pcgen.cdom.base.CDOMObject)15 PlayerCharacter (pcgen.core.PlayerCharacter)14 ChoiceSet (pcgen.cdom.base.ChoiceSet)13 ConcretePersistentTransitionChoice (pcgen.cdom.base.ConcretePersistentTransitionChoice)13 ReferenceChoiceSet (pcgen.cdom.choiceset.ReferenceChoiceSet)13 ClassSkillChoiceActor (pcgen.cdom.helper.ClassSkillChoiceActor)13 StringTokenizer (java.util.StringTokenizer)10 ObjectMatchingReference (pcgen.cdom.reference.ObjectMatchingReference)10 Ability (pcgen.core.Ability)10 LoadContext (pcgen.rules.context.LoadContext)9 ClassSkillList (pcgen.cdom.list.ClassSkillList)8 HashSet (java.util.HashSet)7 CNAbility (pcgen.cdom.content.CNAbility)7