Search in sources :

Example 6 with ChallengeRating

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");
}
Also used : ChallengeRating(pcgen.cdom.content.ChallengeRating) Test(org.junit.Test)

Example 7 with ChallengeRating

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);
}
Also used : ChallengeRating(pcgen.cdom.content.ChallengeRating) Race(pcgen.core.Race)

Aggregations

ChallengeRating (pcgen.cdom.content.ChallengeRating)7 Formula (pcgen.base.formula.Formula)3 Test (org.junit.Test)2 Race (pcgen.core.Race)2 ReadXML (gmgen.io.ReadXML)1 VectorTable (gmgen.io.VectorTable)1 File (java.io.File)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 OrderedPairManager (pcgen.base.format.OrderedPairManager)1 StringManager (pcgen.base.format.StringManager)1 UnreachableError (pcgen.base.lang.UnreachableError)1 CampaignSourceEntry (pcgen.persistence.lst.CampaignSourceEntry)1 GenericLoader (pcgen.persistence.lst.GenericLoader)1 PCClassLoader (pcgen.persistence.lst.PCClassLoader)1 LoadContext (pcgen.rules.context.LoadContext)1 ParseResult (pcgen.rules.persistence.token.ParseResult)1