Search in sources :

Example 21 with LevelCommandFactory

use of pcgen.cdom.content.LevelCommandFactory in project pcgen by PCGen.

the class AddLevelToken method unparse.

@Override
public String[] unparse(LoadContext context, PCTemplate pct) {
    Changes<LevelCommandFactory> changes = context.getObjectContext().getListChanges(pct, ListKey.ADD_LEVEL);
    Collection<LevelCommandFactory> added = changes.getAdded();
    if (added == null || added.isEmpty()) {
        return null;
    }
    List<String> list = new ArrayList<>();
    for (LevelCommandFactory lcf : added) {
        StringBuilder sb = new StringBuilder();
        sb.append(lcf.getLSTformat()).append(Constants.PIPE).append(lcf.getLevelCount().toString());
        list.add(sb.toString());
    }
    return list.toArray(new String[list.size()]);
}
Also used : LevelCommandFactory(pcgen.cdom.content.LevelCommandFactory) ArrayList(java.util.ArrayList)

Example 22 with LevelCommandFactory

use of pcgen.cdom.content.LevelCommandFactory in project pcgen by PCGen.

the class AddLevelFacet method dataAdded.

/**
	 * Drives the necessary results of an ADDLEVEL: token to apply the results
	 * to a Player Character.
	 * 
	 * Triggered when one of the Facets to which AddLevelFacet listens fires a
	 * DataFacetChangeEvent to indicate a CDOMObject was added to a Player
	 * Character.
	 * 
	 * @param dfce
	 *            The DataFacetChangeEvent containing the information about the
	 *            change
	 * 
	 * @see pcgen.cdom.facet.event.DataFacetChangeListener#dataAdded(pcgen.cdom.facet.event.DataFacetChangeEvent)
	 */
@Override
public void dataAdded(DataFacetChangeEvent<CharID, PCTemplate> dfce) {
    PCTemplate template = dfce.getCDOMObject();
    CharID id = dfce.getCharID();
    PlayerCharacter pc = trackingFacet.getPC(id);
    // character so don't apply them again.
    if (!pc.isImporting()) {
        for (LevelCommandFactory lcf : template.getSafeListFor(ListKey.ADD_LEVEL)) {
            add(lcf.getLevelCount(), lcf.getPCClass(), pc);
        }
    }
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) LevelCommandFactory(pcgen.cdom.content.LevelCommandFactory) PCTemplate(pcgen.core.PCTemplate) CharID(pcgen.cdom.enumeration.CharID)

Example 23 with LevelCommandFactory

use of pcgen.cdom.content.LevelCommandFactory in project pcgen by PCGen.

the class Gui2InfoFactory method getHTMLInfo.

/**
	 * @see pcgen.core.facade.InfoFactory#getHTMLInfo(pcgen.core.facade.RaceFacade)
	 */
@Override
public String getHTMLInfo(RaceFacade raceFacade) {
    if (!(raceFacade instanceof Race)) {
        return EMPTY_STRING;
    }
    Race race = (Race) raceFacade;
    final HtmlInfoBuilder infoText = new HtmlInfoBuilder();
    if (!race.getKeyName().startsWith("<none")) {
        infoText.appendTitleElement(OutputNameFormatting.piString(race, false));
        infoText.appendLineBreak();
        RaceType rt = race.get(ObjectKey.RACETYPE);
        if (rt != null) {
            //$NON-NLS-1$
            infoText.appendI18nElement("in_irInfoRaceType", rt.toString());
        }
        List<RaceSubType> rst = race.getListFor(ListKey.RACESUBTYPE);
        if (rst != null) {
            infoText.appendSpacer();
            //$NON-NLS-1$
            infoText.appendI18nElement("in_irInfoSubType", StringUtil.join(rst, ", "));
        }
        if (!race.getType().isEmpty()) {
            infoText.appendSpacer();
            //$NON-NLS-1$
            infoText.appendI18nElement("in_irInfoType", race.getType());
        }
        appendFacts(infoText, race);
        infoText.appendLineBreak();
        String size = race.getSize();
        if (StringUtils.isNotEmpty(size)) {
            //$NON-NLS-1$
            infoText.appendI18nElement("in_size", size);
        }
        String movement = getMovement(raceFacade);
        if (!movement.isEmpty()) {
            infoText.appendSpacer();
            //$NON-NLS-1$
            infoText.appendI18nElement("in_movement", movement);
        }
        String vision = getVision(raceFacade);
        if (!vision.isEmpty()) {
            infoText.appendSpacer();
            //$NON-NLS-1$
            infoText.appendI18nElement("in_vision", vision);
        }
        String bString = PrerequisiteUtilities.preReqHTMLStringsForList(pc, null, race.getPrerequisiteList(), false);
        if (!bString.isEmpty()) {
            infoText.appendLineBreak();
            //$NON-NLS-1$
            infoText.appendI18nElement("in_requirements", bString);
        }
        String desc = pc.getDescription(race);
        if (!desc.isEmpty()) {
            infoText.appendLineBreak();
            //$NON-NLS-1$
            infoText.appendI18nFormattedElement(//$NON-NLS-1$
            "in_InfoDescription", DescriptionFormatting.piWrapDesc(race, desc, false));
        }
        String statAdjustments = getStatAdjustments(raceFacade);
        if (StringUtils.isNotEmpty(statAdjustments)) {
            infoText.appendLineBreak();
            //$NON-NLS-1$
            infoText.appendI18nElement("in_irTableStat", statAdjustments);
        }
        LevelCommandFactory levelCommandFactory = race.get(ObjectKey.MONSTER_CLASS);
        if (levelCommandFactory != null) {
            infoText.appendLineBreak();
            //$NON-NLS-1$
            infoText.appendI18nFormattedElement(//$NON-NLS-1$
            "in_irInfoMonsterClass", String.valueOf(levelCommandFactory.getLevelCount()), OutputNameFormatting.piString(levelCommandFactory.getPCClass(), false));
        }
        String favoredClass = getFavoredClass(raceFacade);
        if (StringUtils.isNotEmpty(favoredClass)) {
            infoText.appendLineBreak();
            //$NON-NLS-1$
            infoText.appendI18nElement("in_favoredClass", favoredClass);
        }
        bString = race.getSource();
        if (!bString.isEmpty()) {
            infoText.appendLineBreak();
            //$NON-NLS-1$
            infoText.appendI18nElement("in_sourceLabel", bString);
        }
    }
    return infoText.toString();
}
Also used : RaceSubType(pcgen.cdom.enumeration.RaceSubType) LevelCommandFactory(pcgen.cdom.content.LevelCommandFactory) Race(pcgen.core.Race) RaceType(pcgen.cdom.enumeration.RaceType) HtmlInfoBuilder(pcgen.gui2.util.HtmlInfoBuilder)

Example 24 with LevelCommandFactory

use of pcgen.cdom.content.LevelCommandFactory in project pcgen by PCGen.

the class Gui2InfoFactory method getNumMonsterClassLevels.

@Override
public int getNumMonsterClassLevels(RaceFacade raceFacade) {
    if (!(raceFacade instanceof Race)) {
        return 0;
    }
    Race race = (Race) raceFacade;
    LevelCommandFactory levelCommandFactory = race.get(ObjectKey.MONSTER_CLASS);
    if (levelCommandFactory == null) {
        return 0;
    }
    return levelCommandFactory.getLevelCount().resolve(pc, EMPTY_STRING).intValue();
}
Also used : LevelCommandFactory(pcgen.cdom.content.LevelCommandFactory) Race(pcgen.core.Race)

Example 25 with LevelCommandFactory

use of pcgen.cdom.content.LevelCommandFactory in project pcgen by PCGen.

the class AddLevelTokenTest method testUnparseSingle.

@Test
public void testUnparseSingle() throws PersistenceLayerException {
    primaryContext.getReferenceContext().constructCDOMObject(PCClass.class, "Fighter");
    CDOMSingleRef<PCClass> cl = primaryContext.getReferenceContext().getCDOMReference(PCClass.class, "Fighter");
    primaryProf.addToListFor(ListKey.ADD_LEVEL, new LevelCommandFactory(cl, FormulaFactory.getFormulaFor(4)));
    String[] unparsed = getToken().unparse(primaryContext, primaryProf);
    expectSingle(unparsed, "Fighter|4");
}
Also used : LevelCommandFactory(pcgen.cdom.content.LevelCommandFactory) PCClass(pcgen.core.PCClass) Test(org.junit.Test)

Aggregations

LevelCommandFactory (pcgen.cdom.content.LevelCommandFactory)25 PCClass (pcgen.core.PCClass)10 PlayerCharacter (pcgen.core.PlayerCharacter)7 CharID (pcgen.cdom.enumeration.CharID)4 FixedSizeFormula (pcgen.cdom.formula.FixedSizeFormula)4 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 Race (pcgen.core.Race)3 SizeAdjustment (pcgen.core.SizeAdjustment)3 LoadContext (pcgen.rules.context.LoadContext)3 URI (java.net.URI)2 ParsingSeparator (pcgen.base.text.ParsingSeparator)2 CDOMObject (pcgen.cdom.base.CDOMObject)2 PCTemplate (pcgen.core.PCTemplate)2 BonusObj (pcgen.core.bonus.BonusObj)2 PCLevelInfo (pcgen.core.pclevelinfo.PCLevelInfo)2 CampaignSourceEntry (pcgen.persistence.lst.CampaignSourceEntry)2 PCClassLoader (pcgen.persistence.lst.PCClassLoader)2 PreParserFactory (pcgen.persistence.lst.prereq.PreParserFactory)2 PcgCombatant (gmgen.plugin.PcgCombatant)1