use of pcgen.cdom.content.ChallengeRating in project pcgen by PCGen.
the class CRTokenTest method testUnparseFraction.
@Test
public void testUnparseFraction() throws PersistenceLayerException {
ChallengeRating cr = new ChallengeRating(FormulaFactory.getFormulaFor("1/2"));
primaryProf.put(ObjectKey.CHALLENGE_RATING, cr);
expectSingle(getToken().unparse(primaryContext, primaryProf), "1/2");
}
use of pcgen.cdom.content.ChallengeRating in project pcgen by PCGen.
the class EncounterModel method getCR.
/**
* Gets the challenge rating of the group of characters.
* @return the challenge rating.
*/
public int getCR() {
float cr = 0;
for (int i = 0; i < size(); i++) {
Race aRace = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Race.class, (String) elementAt(i));
ChallengeRating rcr = aRace.get(ObjectKey.CHALLENGE_RATING);
if (rcr != null) {
/*
* CrLst enforces a certain structure x or 1/x where x is an integer,
* so we KNOW this is a fixed value. We skip the isStatic() test.
*/
cr += mCRtoPL(rcr.getRating().resolveStatic().floatValue());
}
}
cr = mPLtoCR(cr);
if (cr < 0) {
cr = 0;
}
return (int) (cr + 0.5);
}
Aggregations