Search in sources :

Example 1 with PCStat

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

the class SkillModifier method modifier.

public static Integer modifier(Skill sk, PlayerCharacter aPC) {
    int bonus = 0;
    if (aPC == null) {
        return 0;
    }
    String keyName = sk.getKeyName();
    CDOMSingleRef<PCStat> statref = sk.get(ObjectKey.KEY_STAT);
    if (statref != null) {
        PCStat stat = statref.get();
        bonus = aPC.getStatModFor(stat);
        bonus += aPC.getTotalBonusTo("SKILL", "STAT." + stat.getKeyName());
    }
    bonus += aPC.getTotalBonusTo("SKILL", keyName);
    // loop through all current skill types checking for boni
    for (Type singleType : sk.getTrueTypeList(false)) {
        bonus += aPC.getTotalBonusTo("SKILL", "TYPE." + singleType);
    }
    // now check for any lists of skills, etc
    bonus += aPC.getTotalBonusTo("SKILL", "LIST");
    // now check for ALL
    bonus += aPC.getTotalBonusTo("SKILL", "ALL");
    // function
    if (aPC.isClassSkill(sk)) {
        bonus += aPC.getTotalBonusTo("CSKILL", keyName);
        // loop through all current skill types checking for boni
        for (Type singleType : sk.getTrueTypeList(false)) {
            bonus += aPC.getTotalBonusTo("CSKILL", "TYPE." + singleType);
        }
        bonus += aPC.getTotalBonusTo("CSKILL", "LIST");
    }
    if (!aPC.isClassSkill(sk) && !sk.getSafe(ObjectKey.EXCLUSIVE)) {
        bonus += aPC.getTotalBonusTo("CCSKILL", keyName);
        // loop through all current skill types checking for boni
        for (Type singleType : sk.getTrueTypeList(false)) {
            bonus += aPC.getTotalBonusTo("CCSKILL", "TYPE." + singleType);
        }
        bonus += aPC.getTotalBonusTo("CCSKILL", "LIST");
    }
    // the above two if-blocks try to get
    // BONUS:[C]CSKILL|TYPE=xxx|y to function
    int aCheckBonus = sk.getSafe(ObjectKey.ARMOR_CHECK).calculateBonus(aPC);
    bonus += aCheckBonus;
    String aString = SettingsHandler.getGame().getRankModFormula();
    if (!aString.isEmpty()) {
        aString = aString.replaceAll(Pattern.quote("$$RANK$$"), SkillRankControl.getTotalRank(aPC, sk).toString());
        bonus += aPC.getVariableValue(aString, "").intValue();
    }
    return bonus;
}
Also used : Type(pcgen.cdom.enumeration.Type) PCStat(pcgen.core.PCStat)

Example 2 with PCStat

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

the class SkillInfoUtilities method getKeyStatFromStats.

/**
	 * Get the key attribute's description
	 * 
	 * @return description
	 */
public static String getKeyStatFromStats(PlayerCharacter pc, Skill sk) {
    CDOMSingleRef<PCStat> stat = sk.get(ObjectKey.KEY_STAT);
    if (stat == null) {
        if (Globals.getGameModeHasPointPool()) {
            List<PCStat> statList = SkillInfoUtilities.getKeyStatList(pc, sk, null);
            StringBuilder sb = new StringBuilder(50);
            boolean needSlash = false;
            for (PCStat s : statList) {
                if (needSlash) {
                    sb.append('/');
                }
                sb.append(s.getKeyName());
            }
            return sb.toString();
        } else {
            return "";
        }
    } else {
        return stat.get().getKeyName();
    }
}
Also used : PCStat(pcgen.core.PCStat)

Example 3 with PCStat

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

the class NPCGenerator method getStatWeights.

private List<PCStat> getStatWeights(PlayerCharacter pc, final PCClass aClass) {
    final WeightedCollection<PCStat> stats = new WeightedCollection<>(theConfiguration.getStatWeights(aClass.getKeyName()));
    final List<PCStat> ret = new ArrayList<>();
    for (int i = 0; i < pc.getDisplay().getStatCount(); i++) {
        final PCStat stat = stats.getRandomValue();
        ret.add(stat);
        stats.remove(stat);
    }
    return ret;
}
Also used : WeightedCollection(pcgen.base.util.WeightedCollection) ArrayList(java.util.ArrayList) PCStat(pcgen.core.PCStat)

Example 4 with PCStat

use of pcgen.core.PCStat 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)

Example 5 with PCStat

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

the class AbstractGrantedListTokenTest method testFromStat.

//Language not *supposed* to do things like this
//TODO SizeFacet is not a very good model for doing this by hand :(
//Need to separate the setting of size from the facet that holds it
//Skill not *supposed* to do things like this
@Test
public void testFromStat() throws PersistenceLayerException {
    PCStat source = create(PCStat.class, "Source");
    T granted = createGrantedObject();
    processToken(source);
    /*
		 * We never get a chance to test zero since the Stats are added at
		 * Player Character Construction :)
		 */
    assertTrue(containsExpected(granted));
    assertEquals(1, getCount());
    statFacet.remove(id, source);
    assertEquals(0, getCount());
    assertTrue(cleanedSideEffects());
}
Also used : PCStat(pcgen.core.PCStat) Test(org.junit.Test)

Aggregations

PCStat (pcgen.core.PCStat)78 CDOMObject (pcgen.cdom.base.CDOMObject)10 GameMode (pcgen.core.GameMode)10 Before (org.junit.Before)9 Race (pcgen.core.Race)9 PCClass (pcgen.core.PCClass)7 PlayerCharacter (pcgen.core.PlayerCharacter)7 AbstractReferenceContext (pcgen.rules.context.AbstractReferenceContext)7 CDOMSingleRef (pcgen.cdom.reference.CDOMSingleRef)6 PCTemplate (pcgen.core.PCTemplate)6 Skill (pcgen.core.Skill)6 ArrayList (java.util.ArrayList)5 StatLock (pcgen.cdom.helper.StatLock)5 BonusObj (pcgen.core.bonus.BonusObj)5 Test (org.junit.Test)4 Formula (pcgen.base.formula.Formula)4 CharID (pcgen.cdom.enumeration.CharID)4 LoadContext (pcgen.rules.context.LoadContext)4 StringTokenizer (java.util.StringTokenizer)3 Type (pcgen.cdom.enumeration.Type)3