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;
}
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();
}
}
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;
}
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());
}
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());
}
Aggregations