Search in sources :

Example 6 with GameMode

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

the class GameModePanel method getSelection.

private void getSelection(CDOMObject pc) {
    GameMode gameMode = (GameMode) gameModeCombo.getSelectedItem();
    pc.put(ObjectKey.GAME_MODE, gameMode);
    PCGenSettings context = PCGenSettings.getInstance();
    context.setProperty(PCGenSettings.CONVERT_GAMEMODE, gameMode.getName());
}
Also used : GameMode(pcgen.core.GameMode) PCGenSettings(pcgen.system.PCGenSettings)

Example 7 with GameMode

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

the class PCGVer2Parser method parcePCGSourceOnly.

/**
	 * Check the game mode and then build a list of campaigns the character 
	 * requires to be loaded.
	 *   
	 * @param lines The PCG lines to be parsed.
	 * @return The list of campaigns.
	 * @throws PCGParseException If the lines are invalid 
	 */
@Override
public SourceSelectionFacade parcePCGSourceOnly(String[] lines) throws PCGParseException {
    buildPcgLineCache(lines);
    /*
		 * VERSION:x.x.x
		 */
    if (cache.containsKey(IOConstants.TAG_VERSION)) {
        parseVersionLine(cache.get(IOConstants.TAG_VERSION).get(0));
    }
    if (!cache.containsKey(IOConstants.TAG_GAMEMODE)) {
        Logging.errorPrint("Character does not have game mode information.");
        return null;
    }
    String line = cache.get(IOConstants.TAG_GAMEMODE).get(0);
    String requestedMode = line.substring(IOConstants.TAG_GAMEMODE.length() + 1);
    GameMode mode = SystemCollections.getGameModeNamed(requestedMode);
    if (mode == null) {
        for (GameMode gameMode : SystemCollections.getUnmodifiableGameModeList()) {
            if (gameMode.getAllowedModes().contains(requestedMode)) {
                mode = gameMode;
                break;
            }
        }
    }
    //if mode == null still then a game mode was not found
    if (mode == null) {
        Logging.errorPrint("Character's game mode entry was not valid: " + line);
        return null;
    }
    if (!cache.containsKey(IOConstants.TAG_CAMPAIGN)) {
        Logging.errorPrint("Character does not have campaign information.");
        return FacadeFactory.createSourceSelection(mode, new ArrayList<>());
    }
    /*
		 * #System Information
		 * CAMPAIGN:CMP - Monkey Book I - Book For Monkeys
		 * CAMPAIGN:CMP - Monkey Book II - Book By Monkeys
		 * ...
		 *
		 * first thing to do is checking campaigns - no matter what!
		 */
    List<Campaign> campaigns = getCampaignList(cache.get(IOConstants.TAG_CAMPAIGN), mode.getName());
    if (campaigns.isEmpty()) {
        Logging.errorPrint("Character's campaign entry was empty.");
    }
    return FacadeFactory.createSourceSelection(mode, campaigns);
}
Also used : GameMode(pcgen.core.GameMode) Campaign(pcgen.core.Campaign)

Example 8 with GameMode

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

the class PCGVer2Parser method parseGameMode.

private void parseGameMode(final String line) throws PCGParseException {
    final String requestedMode = line.substring(IOConstants.TAG_GAMEMODE.length() + 1);
    final GameMode currentGameMode = SettingsHandler.getGame();
    final String currentMode = currentGameMode.getName();
    if (!requestedMode.equals(currentMode)) {
        final String msg = LanguageBundle.getFormattedString(//$NON-NLS-1$
        "Exceptions.PCGenParser.WrongGameMode", requestedMode, currentMode);
        //$NON-NLS-1$
        throw new PCGParseException("ParseGameMode", line, msg);
    }
}
Also used : GameMode(pcgen.core.GameMode)

Example 9 with GameMode

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

the class AbstractSaveRestoreTest method setUpBeforeClass.

public static void setUpBeforeClass() throws Exception {
    if (!setup) {
        setup = true;
        TokenRegistration.register(new plugin.lsttokens.level.LevelToken());
        TokenRegistration.register(new plugin.lsttokens.level.MinxpToken());
        TokenRegistration.register(new plugin.lsttokens.level.CskillmaxToken());
        TokenRegistration.register(new plugin.lsttokens.level.CcskillmaxToken());
        SettingsHandler.setGame("3.5");
        GameMode mode = SettingsHandler.getGame();
        mode.setBonusFeatLevels("3|3");
        LevelLoader.parseLine(mode, "LEVEL:LEVEL	MINXP:(LEVEL*LEVEL-LEVEL)*500		CSKILLMAX:LEVEL+ClassSkillMax+3	CCSKILLMAX:(LEVEL+CrossClassSkillMax+3)/2", 0, URI, "Default");
        mode.setAlignmentText("Alignment");
    }
}
Also used : GameMode(pcgen.core.GameMode)

Example 10 with GameMode

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

the class AbstractSaveRestoreTest method setUpContext.

protected void setUpContext() throws PersistenceLayerException {
    ChooserFactory.pushChooserClassname(RandomChooser.class.getName());
    TokenRegistration.clearTokens();
    TokenRegistration.register(AUTO_LANG_TOKEN);
    TokenRegistration.register(ABILITY_VISIBLE_TOKEN);
    TokenRegistration.register(AUTO_TOKEN);
    TokenRegistration.register(CHOOSE_TOKEN);
    TokenRegistration.register(CHOOSE_LANG_TOKEN);
    TokenRegistration.register(ABILITY_MULT_TOKEN);
    TokenRegistration.register(EQUIP_TYPE_TOKEN);
    TokenRegistration.register(EQUIP_PROFICIENCY_TOKEN);
    TokenRegistration.register(LANGBONUS_PRIM);
    TokenRegistration.register(PC_QUAL);
    TokenRegistration.register(Feat.class);
    directAbilityFacet = FacetLibrary.getFacet(DirectAbilityFacet.class);
    activeEqModFacet = FacetLibrary.getFacet(ActiveEqModFacet.class);
    alignmentFacet = FacetLibrary.getFacet(AlignmentFacet.class);
    bioSetFacet = FacetLibrary.getFacet(BioSetFacet.class);
    checkFacet = FacetLibrary.getFacet(CheckFacet.class);
    classFacet = FacetLibrary.getFacet(ClassFacet.class);
    classLevelFacet = FacetLibrary.getFacet(ClassLevelFacet.class);
    companionModFacet = FacetLibrary.getFacet(CompanionModFacet.class);
    deityFacet = FacetLibrary.getFacet(DeityFacet.class);
    domainFacet = FacetLibrary.getFacet(DomainFacet.class);
    expandedCampaignFacet = FacetLibrary.getFacet(ExpandedCampaignFacet.class);
    languageFacet = FacetLibrary.getFacet(LanguageFacet.class);
    raceFacet = FacetLibrary.getFacet(RaceSelectionFacet.class);
    sizeFacet = FacetLibrary.getFacet(SizeFacet.class);
    skillFacet = FacetLibrary.getFacet(SkillFacet.class);
    statFacet = FacetLibrary.getFacet(StatFacet.class);
    templateFacet = FacetLibrary.getFacet(TemplateSelectionFacet.class);
    templateConsolidationFacet = FacetLibrary.getFacet(TemplateFacet.class);
    weaponProfFacet = FacetLibrary.getFacet(WeaponProfFacet.class);
    Globals.createEmptyRace();
    Globals.setUseGUI(false);
    Globals.emptyLists();
    GameMode gamemode = SettingsHandler.getGame();
    gamemode.clearLoadContext();
    str = BuildUtilities.createStat("Strength", "STR");
    str.put(VariableKey.getConstant("LOADSCORE"), FormulaFactory.getFormulaFor("STRSCORE"));
    str.put(VariableKey.getConstant("OFFHANDLIGHTBONUS"), FormulaFactory.getFormulaFor(2));
    dex = BuildUtilities.createStat("Dexterity", "DEX");
    con = BuildUtilities.createStat("Constitution", "CON");
    intel = BuildUtilities.createStat("Intelligence", "INT");
    wis = BuildUtilities.createStat("Wisdom", "WIS");
    cha = BuildUtilities.createStat("Charisma", "CHA");
    AbstractReferenceContext ref = Globals.getContext().getReferenceContext();
    lg = BuildUtilities.createAlignment("Lawful Good", "LG");
    ref.importObject(lg);
    ln = BuildUtilities.createAlignment("Lawful Neutral", "LN");
    ref.importObject(ln);
    le = BuildUtilities.createAlignment("Lawful Evil", "LE");
    ref.importObject(le);
    ng = BuildUtilities.createAlignment("Neutral Good", "NG");
    ref.importObject(ng);
    tn = BuildUtilities.createAlignment("True Neutral", "TN");
    ref.importObject(tn);
    ne = BuildUtilities.createAlignment("Neutral Evil", "NE");
    ref.importObject(ne);
    cg = BuildUtilities.createAlignment("Chaotic Good", "CG");
    ref.importObject(cg);
    cn = BuildUtilities.createAlignment("Chaotic Neutral", "CN");
    ref.importObject(cn);
    ce = BuildUtilities.createAlignment("Chaotic Evil", "CE");
    ref.importObject(ce);
    ref.importObject(BuildUtilities.createAlignment("None", "NONE"));
    ref.importObject(BuildUtilities.createAlignment("Deity's", "Deity"));
    ref.importObject(str);
    ref.importObject(dex);
    ref.importObject(con);
    ref.importObject(intel);
    ref.importObject(wis);
    ref.importObject(cha);
    fine = BuildUtilities.createSize("Fine", 0);
    diminutive = BuildUtilities.createSize("Diminutive", 1);
    tiny = BuildUtilities.createSize("Tiny", 2);
    small = BuildUtilities.createSize("Small", 3);
    medium = BuildUtilities.createSize("Medium", 4);
    medium.put(ObjectKey.IS_DEFAULT_SIZE, true);
    large = BuildUtilities.createSize("Large", 5);
    huge = BuildUtilities.createSize("Huge", 6);
    gargantuan = BuildUtilities.createSize("Gargantuan", 7);
    colossal = BuildUtilities.createSize("Colossal", 8);
    context = Globals.getContext();
    create(Language.class, "Common");
    human = create(Race.class, "Human");
    BuildUtilities.createFact(context, "ClassType", PCClass.class);
    FactDefinition<?, String> fd = BuildUtilities.createFact(context, "SpellType", PCClass.class);
    fd.setSelectable(true);
    context.getReferenceContext().importObject(AbilityCategory.FEAT);
    SourceFileLoader.createLangBonusObject(Globals.getContext());
    ChooserFactory.setDelegate(new MockUIDelegate());
}
Also used : AbstractReferenceContext(pcgen.rules.context.AbstractReferenceContext) TemplateFacet(pcgen.cdom.facet.model.TemplateFacet) MockUIDelegate(pcgen.gui2.facade.MockUIDelegate) RandomChooser(pcgen.util.chooser.RandomChooser) CompanionModFacet(pcgen.cdom.facet.model.CompanionModFacet) DomainFacet(pcgen.cdom.facet.model.DomainFacet) StatFacet(pcgen.cdom.facet.model.StatFacet) AlignmentFacet(pcgen.cdom.facet.model.AlignmentFacet) Race(pcgen.core.Race) ActiveEqModFacet(pcgen.cdom.facet.model.ActiveEqModFacet) TemplateSelectionFacet(pcgen.cdom.facet.TemplateSelectionFacet) ClassFacet(pcgen.cdom.facet.model.ClassFacet) ClassLevelFacet(pcgen.cdom.facet.model.ClassLevelFacet) CheckFacet(pcgen.cdom.facet.model.CheckFacet) BioSetFacet(pcgen.cdom.facet.model.BioSetFacet) RaceSelectionFacet(pcgen.cdom.facet.RaceSelectionFacet) GameMode(pcgen.core.GameMode) SizeFacet(pcgen.cdom.facet.model.SizeFacet) ExpandedCampaignFacet(pcgen.cdom.facet.model.ExpandedCampaignFacet) DeityFacet(pcgen.cdom.facet.model.DeityFacet) WeaponProfFacet(pcgen.cdom.facet.WeaponProfFacet) DirectAbilityFacet(pcgen.cdom.facet.DirectAbilityFacet) LanguageFacet(pcgen.cdom.facet.model.LanguageFacet) SkillFacet(pcgen.cdom.facet.model.SkillFacet)

Aggregations

GameMode (pcgen.core.GameMode)58 PCStat (pcgen.core.PCStat)10 PlayerCharacter (pcgen.core.PlayerCharacter)8 File (java.io.File)7 Campaign (pcgen.core.Campaign)7 LoadContext (pcgen.rules.context.LoadContext)7 LevelInfo (pcgen.core.LevelInfo)6 Race (pcgen.core.Race)6 AbstractReferenceContext (pcgen.rules.context.AbstractReferenceContext)6 ArrayList (java.util.ArrayList)5 PCClass (pcgen.core.PCClass)5 BonusObj (pcgen.core.bonus.BonusObj)4 Before (org.junit.Before)3 Equipment (pcgen.core.Equipment)3 CampaignFacade (pcgen.facade.core.CampaignFacade)3 FileWriter (java.io.FileWriter)2 IOException (java.io.IOException)2 Writer (java.io.Writer)2 HashMap (java.util.HashMap)2 JLabel (javax.swing.JLabel)2