Search in sources :

Example 6 with Description

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

the class PCRacialHDSizeTermEvaluatorTest method 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"));
    CampaignSourceEntry source = new CampaignSourceEntry(customCampaign, new URI("file:/" + getClass().getName() + ".java"));
    LoadContext context = Globals.getContext();
    PCClassLoader classLoader = new PCClassLoader();
    // Create the humanoid monster class
    final String humanoidClassLine = "CLASS:Humanoid	KEY:KEY_Humanoid	HD:8	TYPE:Monster	CLASSTYPE:Monster	" + "STARTSKILLPTS:2	MODTOSKILLS:YES";
    humanoidClass = classLoader.parseLine(context, null, humanoidClassLine, source);
    context.getReferenceContext().importObject(humanoidClass);
    // Create the pc class
    final String pcClassLine = "CLASS:TestPCClass	TYPE:PC		HD:10";
    pcClass = classLoader.parseLine(context, null, pcClassLine, source);
    context.getReferenceContext().importObject(pcClass);
    CDOMDirectSingleRef<SizeAdjustment> mediumRef = CDOMDirectSingleRef.getRef(medium);
    // Create the BugBear race
    bugbearRace.setName("Bugbear");
    bugbearRace.put(StringKey.KEY_NAME, "KEY_Bugbear");
    bugbearRace.put(FormulaKey.SIZE, new FixedSizeFormula(mediumRef));
    bugbearRace.addToListFor(ListKey.HITDICE_ADVANCEMENT, Integer.MAX_VALUE);
    bugbearRace.put(ObjectKey.MONSTER_CLASS, new LevelCommandFactory(CDOMDirectSingleRef.getRef(humanoidClass), FormulaFactory.getFormulaFor(3)));
    context.getReferenceContext().importObject(bugbearRace);
    // Create the human race
    humanRace.setName("Human");
    humanRace.put(StringKey.KEY_NAME, "KEY_Human");
    humanRace.put(FormulaKey.SIZE, new FixedSizeFormula(mediumRef));
    context.getReferenceContext().importObject(humanRace);
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) Campaign(pcgen.core.Campaign) Description(pcgen.core.Description) LevelCommandFactory(pcgen.cdom.content.LevelCommandFactory) LoadContext(pcgen.rules.context.LoadContext) PCClassLoader(pcgen.persistence.lst.PCClassLoader) URI(java.net.URI) SizeAdjustment(pcgen.core.SizeAdjustment) FixedSizeFormula(pcgen.cdom.formula.FixedSizeFormula)

Example 7 with Description

use of pcgen.core.Description 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 8 with Description

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

the class DescLst method unparse.

@Override
public String[] unparse(LoadContext context, CDOMObject obj) {
    PatternChanges<Description> changes = context.getObjectContext().getListPatternChanges(obj, ListKey.DESCRIPTION);
    if (changes == null || changes.isEmpty()) {
        return null;
    }
    List<String> list = new ArrayList<>();
    Collection<String> removedItems = changes.getRemoved();
    if (changes.includesGlobalClear()) {
        if (removedItems != null && !removedItems.isEmpty()) {
            context.addWriteMessage("Non-sensical relationship in " + getTokenName() + ": global .CLEAR and local .CLEAR. performed");
            return null;
        }
        list.add(Constants.LST_DOT_CLEAR);
    }
    if (removedItems != null && !removedItems.isEmpty()) {
        for (String d : removedItems) {
            list.add(Constants.LST_DOT_CLEAR_DOT + d);
        }
    }
    Collection<Description> addedItems = changes.getAdded();
    if (addedItems != null) {
        for (Description d : addedItems) {
            list.add(d.getPCCText());
        }
    }
    if (list.isEmpty()) {
        return null;
    }
    return list.toArray(new String[list.size()]);
}
Also used : Description(pcgen.core.Description) ArrayList(java.util.ArrayList)

Example 9 with Description

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

the class DescLst method parseTokenWithSeparator.

@Override
protected ParseResult parseTokenWithSeparator(LoadContext context, CDOMObject obj, String aDesc) {
    if (Constants.LST_DOT_CLEAR.equals(aDesc)) {
        context.getObjectContext().removeList(obj, ListKey.DESCRIPTION);
        return ParseResult.SUCCESS;
    }
    if (aDesc.startsWith(Constants.LST_DOT_CLEAR_DOT)) {
        context.getObjectContext().removePatternFromList(obj, ListKey.DESCRIPTION, aDesc.substring(7));
        return ParseResult.SUCCESS;
    }
    StringTokenizer tok = new StringTokenizer(aDesc, Constants.PIPE);
    String descString = tok.nextToken();
    if (looksLikeAPrerequisite(descString)) {
        return new ParseResult.Fail(getTokenName() + " encountered only a PRExxx: " + aDesc, context);
    }
    String ds = EntityEncoder.decode(descString);
    if (!StringUtil.hasBalancedParens(ds)) {
        return new ParseResult.Fail(getTokenName() + " encountered imbalanced Parenthesis: " + aDesc, context);
    }
    ParseResult pr = checkForInvalidXMLChars(ds);
    if (!pr.passed()) {
        return pr;
    }
    Description desc = new Description(ds);
    if (tok.hasMoreTokens()) {
        String token = tok.nextToken();
        while (true) {
            if (Constants.LST_DOT_CLEAR.equals(token)) {
                return new ParseResult.Fail(getTokenName() + " tag confused by '.CLEAR' as a " + "middle token: " + aDesc, context);
            } else if (looksLikeAPrerequisite(token)) {
                break;
            } else {
                desc.addVariable(token);
            }
            if (!tok.hasMoreTokens()) {
                // No prereqs, so we're done
                context.getObjectContext().addToList(obj, ListKey.DESCRIPTION, desc);
                return ParseResult.SUCCESS;
            }
            token = tok.nextToken();
        }
        while (true) {
            Prerequisite prereq = getPrerequisite(token);
            if (prereq == null) {
                return new ParseResult.Fail("   (Did you put Abilities after the " + "PRExxx tags in " + getTokenName() + ":?)", context);
            }
            desc.addPrerequisite(prereq);
            if (!tok.hasMoreTokens()) {
                break;
            }
            token = tok.nextToken();
        }
    }
    context.getObjectContext().addToList(obj, ListKey.DESCRIPTION, desc);
    return ParseResult.SUCCESS;
}
Also used : StringTokenizer(java.util.StringTokenizer) Description(pcgen.core.Description) ParseResult(pcgen.rules.persistence.token.ParseResult) Prerequisite(pcgen.core.prereq.Prerequisite)

Example 10 with Description

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

the class Gui2InfoFactoryTest method testGetHTMLInfoTempBonus.

/**
	 * Verify getHTMLInfo for a temporary bonus.
	 */
public void testGetHTMLInfoTempBonus() {
    PlayerCharacter pc = getCharacter();
    Gui2InfoFactory infoFactory = new Gui2InfoFactory(pc);
    Ability tbAbility = TestHelper.makeAbility("Combat expertise", AbilityCategory.FEAT, "General");
    tbAbility.put(ObjectKey.MULTIPLE_ALLOWED, Boolean.FALSE);
    final Description desc = new Description("CE Desc");
    tbAbility.addToListFor(ListKey.DESCRIPTION, desc);
    Globals.getContext().commit();
    addAbility(AbilityCategory.FEAT, tbAbility);
    TempBonusFacadeImpl tbf = new TempBonusFacadeImpl(tbAbility);
    assertEquals("Unexpected temp bonus result", "<html><b><font size=+1>Combat expertise</font></b> (Ability)<br>" + "<b>Desc:</b>&nbsp;CE Desc<br><b>Source:</b>&nbsp;</html>", infoFactory.getHTMLInfo(tbf));
}
Also used : Ability(pcgen.core.Ability) PlayerCharacter(pcgen.core.PlayerCharacter) Description(pcgen.core.Description)

Aggregations

Description (pcgen.core.Description)14 Campaign (pcgen.core.Campaign)4 FixedSizeFormula (pcgen.cdom.formula.FixedSizeFormula)3 SizeAdjustment (pcgen.core.SizeAdjustment)3 CampaignSourceEntry (pcgen.persistence.lst.CampaignSourceEntry)3 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 StringTokenizer (java.util.StringTokenizer)2 Ability (pcgen.core.Ability)2 Domain (pcgen.core.Domain)2 PlayerCharacter (pcgen.core.PlayerCharacter)2 Race (pcgen.core.Race)2 Prerequisite (pcgen.core.prereq.Prerequisite)2 PCClassLoader (pcgen.persistence.lst.PCClassLoader)2 LoadContext (pcgen.rules.context.LoadContext)2 File (java.io.File)1 CDOMReference (pcgen.cdom.base.CDOMReference)1 CNAbility (pcgen.cdom.content.CNAbility)1 LevelCommandFactory (pcgen.cdom.content.LevelCommandFactory)1 Nature (pcgen.cdom.enumeration.Nature)1