Search in sources :

Example 21 with SizeAdjustment

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

the class PreSizeParser method parse.

/**
	 * Parse the pre req list
	 *
	 * @param kind The kind of the prerequisite (less the "PRE" prefix)
	 * @param formula The body of the prerequisite.
	 * @param invertResult Whether the prerequisite should invert the result.
	 * @param overrideQualify
	 *           if set true, this prerequisite will be enforced in spite
	 *           of any "QUALIFY" tag that may be present.
	 * @return PreReq
	 * @throws PersistenceLayerException
	 */
@Override
public Prerequisite parse(String kind, String formula, boolean invertResult, boolean overrideQualify) throws PersistenceLayerException {
    Prerequisite prereq = super.parse(kind, formula, invertResult, overrideQualify);
    try {
        prereq.setKind("size");
        // Get the comparator type SIZEGTEQ, BSIZE, SIZENEQ etc.
        String compType = kind.substring(4);
        if (compType.isEmpty()) {
            compType = "gteq";
        }
        prereq.setOperator(compType);
        String abb = formula.substring(0, 1);
        LoadContext context = Globals.getContext();
        CDOMSingleRef<SizeAdjustment> ref = context.getReferenceContext().getCDOMReference(SizeAdjustment.class, abb);
        context.forgetMeNot(ref);
        prereq.setOperand(formula);
        if (invertResult) {
            prereq.setOperator(prereq.getOperator().invert());
        }
    } catch (PrerequisiteException pe) {
        throw new PersistenceLayerException("Unable to parse the prerequisite :'" + kind + ':' + formula + "'. " + pe.getLocalizedMessage());
    }
    return prereq;
}
Also used : PrerequisiteException(pcgen.core.prereq.PrerequisiteException) PersistenceLayerException(pcgen.persistence.PersistenceLayerException) LoadContext(pcgen.rules.context.LoadContext) SizeAdjustment(pcgen.core.SizeAdjustment) Prerequisite(pcgen.core.prereq.Prerequisite)

Example 22 with SizeAdjustment

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

the class SizeToken method parseNonEmptyToken.

@Override
public ParseResult parseNonEmptyToken(LoadContext context, Race race, String value) {
    CDOMSingleRef<SizeAdjustment> size = context.getReferenceContext().getCDOMReference(SizeAdjustment.class, value);
    Formula sizeFormula = new FixedSizeFormula(size);
    context.getObjectContext().put(race, FormulaKey.SIZE, sizeFormula);
    return ParseResult.SUCCESS;
}
Also used : FixedSizeFormula(pcgen.cdom.formula.FixedSizeFormula) Formula(pcgen.base.formula.Formula) SizeAdjustment(pcgen.core.SizeAdjustment) FixedSizeFormula(pcgen.cdom.formula.FixedSizeFormula)

Example 23 with SizeAdjustment

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

the class ClassLevelCommandTest method setUp.

/**
	 * @throws Exception
	 * @see pcgen.AbstractCharacterTestCase#setUp()
	 */
@Override
protected void setUp() throws Exception {
    super.setUp();
    Campaign customCampaign = new Campaign();
    customCampaign.setName("Unit Test");
    customCampaign.setName("KEY_Unit Test");
    customCampaign.addToListFor(ListKey.DESCRIPTION, new Description("Unit Test data"));
    // Create the monseter class type
    GameMode gamemode = SettingsHandler.getGame();
    gamemode.addClassType("Monster		CRFORMULA:0			ISMONSTER:YES	XPPENALTY:NO");
    gamemode.setSkillMultiplierLevels("4");
    gamemode.setMaxNonEpicLevel(20);
    CDOMDirectSingleRef<SizeAdjustment> mediumRef = CDOMDirectSingleRef.getRef(medium);
    // Create the Nymph race
    nymphRace = new Race();
    nymphRace.setName("Nymph");
    nymphRace.addToListFor(ListKey.HITDICE_ADVANCEMENT, Integer.MAX_VALUE);
    nymphRace.put(FormulaKey.SIZE, new FixedSizeFormula(mediumRef));
    Globals.getContext().getReferenceContext().importObject(nymphRace);
    // Create the humanoid class
    humanoidClass = new PCClass();
    humanoidClass.setName("Humanoid");
    humanoidClass.addToListFor(ListKey.TYPE, Type.getConstant("Monster"));
    Globals.getContext().getReferenceContext().importObject(humanoidClass);
    nymphClass = new PCClass();
    nymphClass.setName("Nymph");
    nymphClass.addToListFor(ListKey.TYPE, Type.getConstant("Monster"));
    Globals.getContext().getReferenceContext().importObject(nymphClass);
    megaCasterClass = new PCClass();
    megaCasterClass.setName("MegaCaster");
    BuildUtilities.setFact(megaCasterClass, "SpellType", "Arcane");
    Globals.getContext().unconditionallyProcess(megaCasterClass, "SPELLSTAT", "CHA");
    megaCasterClass.put(ObjectKey.SPELLBOOK, false);
    megaCasterClass.put(ObjectKey.MEMORIZE_SPELLS, false);
    Globals.getContext().getReferenceContext().importObject(megaCasterClass);
}
Also used : GameMode(pcgen.core.GameMode) Campaign(pcgen.core.Campaign) Description(pcgen.core.Description) Race(pcgen.core.Race) PCClass(pcgen.core.PCClass) SizeAdjustment(pcgen.core.SizeAdjustment) FixedSizeFormula(pcgen.cdom.formula.FixedSizeFormula)

Example 24 with SizeAdjustment

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

the class BuildUtilities method createSize.

public static SizeAdjustment createSize(String name, int order) {
    final String abb = name.substring(0, 1);
    final SizeAdjustment sa = new SizeAdjustment();
    sa.setName(name);
    sa.setKeyName(abb);
    sa.put(IntegerKey.SIZEORDER, order);
    Globals.getContext().getReferenceContext().importObject(sa);
    return sa;
}
Also used : SizeAdjustment(pcgen.core.SizeAdjustment)

Example 25 with SizeAdjustment

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

the class BaseSizeTokenTest method setUp.

@Override
public void setUp() throws PersistenceLayerException, URISyntaxException {
    super.setUp();
    TokenRegistration.register(BASESIZE_TOKEN);
    SizeAdjustment ps = BuildUtilities.createSize("Small", 0);
    primaryContext.getReferenceContext().importObject(ps);
    SizeAdjustment ss = BuildUtilities.createSize("Small", 0);
    secondaryContext.getReferenceContext().importObject(ss);
}
Also used : SizeAdjustment(pcgen.core.SizeAdjustment)

Aggregations

SizeAdjustment (pcgen.core.SizeAdjustment)43 FixedSizeFormula (pcgen.cdom.formula.FixedSizeFormula)14 Equipment (pcgen.core.Equipment)11 Race (pcgen.core.Race)10 LoadContext (pcgen.rules.context.LoadContext)10 PlayerCharacter (pcgen.core.PlayerCharacter)8 Before (org.junit.Before)7 WieldCategory (pcgen.core.character.WieldCategory)7 Formula (pcgen.base.formula.Formula)3 LevelCommandFactory (pcgen.cdom.content.LevelCommandFactory)3 Campaign (pcgen.core.Campaign)3 Description (pcgen.core.Description)3 GameMode (pcgen.core.GameMode)3 PCClass (pcgen.core.PCClass)3 Prerequisite (pcgen.core.prereq.Prerequisite)3 AbstractReferenceContext (pcgen.rules.context.AbstractReferenceContext)3 BigDecimal (java.math.BigDecimal)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 StringTokenizer (java.util.StringTokenizer)2