Search in sources :

Example 11 with GameMode

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

the class BasicSaveRestoreTest method testCharacterType.

@Test
public void testCharacterType() {
    GameMode mode = SettingsHandler.getGame();
    mode.setCharacterTypeList(Arrays.asList("Default", "MyType"));
    finishLoad();
    pc.setCharacterType("MyType");
    runRoundRobin(null);
}
Also used : GameMode(pcgen.core.GameMode) Test(org.junit.Test) AbstractSaveRestoreTest(pcgen.io.testsupport.AbstractSaveRestoreTest)

Example 12 with GameMode

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

the class CharacterFacadeImpl method refreshRollMethod.

@Override
public void refreshRollMethod() {
    if (!canChangePurchasePool()) {
        return;
    }
    GameMode game = (GameMode) dataSet.getGameMode();
    rollMethodRef.set(game.getRollMethod());
    if (SettingsHandler.getGame().isPurchaseStatMode()) {
        int availablePool = RollingMethods.roll(SettingsHandler.getGame().getPurchaseModeMethodPoolFormula());
        theCharacter.setPointBuyPoints(availablePool);
        // Make sure all scores are within the valid range
        for (StatFacade stat : statScoreMap.keySet()) {
            WriteableReferenceFacade<Number> score = statScoreMap.get(stat);
            if (score.get().intValue() < SettingsHandler.getGame().getPurchaseScoreMin(theCharacter) && stat instanceof PCStat) {
                setStatToPurchaseNeutral((PCStat) stat, score);
            }
        }
    }
    hpRef.set(theCharacter.hitPoints());
    updateScorePurchasePool(false);
}
Also used : GameMode(pcgen.core.GameMode) StatFacade(pcgen.facade.core.StatFacade) PCStat(pcgen.core.PCStat)

Example 13 with GameMode

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

the class CharacterFacadeImpl method rollStats.

/**
	 * @see pcgen.core.facade.CharacterFacade#rollStats()
	 */
@Override
public void rollStats() {
    GameMode game = (GameMode) dataSet.getGameMode();
    int rollMethod = game.getRollMethod();
    if (rollMethod == Constants.CHARACTER_STAT_METHOD_ROLLED && game.getCurrentRollingMethod() == null) {
        return;
    }
    if (rollMethod == Constants.CHARACTER_STAT_METHOD_USER) {
        // If a user asks to roll in user mode, set it to the current all same value.
        rollMethod = Constants.CHARACTER_STAT_METHOD_ALL_THE_SAME;
    }
    theCharacter.rollStats(rollMethod);
    //XXX This is here to stop the stat mod from being stale. Can be removed once we merge with CDOM
    theCharacter.calcActiveBonuses();
    refreshStatScores();
    updateScorePurchasePool(true);
}
Also used : GameMode(pcgen.core.GameMode)

Example 14 with GameMode

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

the class GameModeFileLoader method loadGameModes.

private void loadGameModes(String[] gameFiles) {
    SystemCollections.clearGameModeList();
    File gameModeDir = new File(ConfigurationSettings.getSystemsDir(), "gameModes");
    int progress = 0;
    for (final String gameFile : gameFiles) {
        File specGameModeDir = new File(gameModeDir, gameFile);
        File miscInfoFile = new File(specGameModeDir, "miscinfo.lst");
        final GameMode gm = GameModeFileLoader.loadGameModeMiscInfo(gameFile, miscInfoFile.toURI());
        if (gm != null) {
            String gmName = gm.getName();
            //SettingsHandler.setGame(gmName);
            LoadContext context = gm.getModeContext();
            loadGameModeInfoFile(gm, new File(specGameModeDir, "level.lst").toURI(), "level");
            loadGameModeInfoFile(gm, new File(specGameModeDir, "rules.lst").toURI(), "rules");
            // Load equipmentslot.lst
            GameModeFileLoader.loadGameModeLstFile(context, eqSlotLoader, gmName, gameFile, "equipmentslots.lst");
            // Load paperInfo.lst
            GameModeFileLoader.loadGameModeLstFile(context, paperLoader, gmName, gameFile, "paperInfo.lst");
            // Load bio files
            GameModeFileLoader.loadGameModeLstFile(context, traitLoader, gmName, gameFile, "bio" + File.separator + "traits.lst");
            GameModeFileLoader.loadGameModeLstFile(context, locationLoader, gmName, gameFile, "bio" + File.separator + "locations.lst");
            // Load load.lst and check for completeness
            GameModeFileLoader.loadGameModeLstFile(context, loadInfoLoader, gmName, gameFile, "load.lst");
            // Load sizeAdjustment.lst
            GameModeFileLoader.loadGameModeLstFile(context, sizeLoader, gmName, gameFile, "sizeAdjustment.lst");
            // Load statsandchecks.lst
            GameModeFileLoader.loadGameModeLstFile(context, statCheckLoader, gmName, gameFile, "statsandchecks.lst");
            // Load equipIcons.lst
            GameModeFileLoader.loadGameModeLstFile(context, equipIconLoader, gmName, gameFile, "equipIcons.lst");
            GameModeFileLoader.loadGameModeLstFile(context, codeControlLoader, gmName, gameFile, "codeControl.lst");
            // Load pointbuymethods.lst
            loadPointBuyFile(context, gameFile, gmName);
            for (final PointBuyCost pbc : context.getReferenceContext().getConstructedCDOMObjects(PointBuyCost.class)) {
                gm.addPointBuyStatCost(pbc);
            }
            // Load migration.lst
            GameModeFileLoader.loadGameModeLstFile(context, migrationLoader, gmName, gameFile, "migration.lst");
            GameModeFileLoader.loadGameModeLstFile(context, bioLoader, gmName, gameFile, "bio" + File.separator + "biosettings.lst");
        }
        try {
            GameModeFileLoader.addDefaultWieldCategories(gm.getModeContext());
        } catch (final PersistenceLayerException ple) {
            Logging.errorPrint("Error Initializing PreParserFactory");
            Logging.errorPrint("  " + ple.getMessage(), ple);
            throw new UnreachableError();
        }
        progress++;
        setProgress(progress);
    }
    SystemCollections.sortGameModeList();
}
Also used : GameMode(pcgen.core.GameMode) LoadContext(pcgen.rules.context.LoadContext) PointBuyCost(pcgen.core.PointBuyCost) UnreachableError(pcgen.base.lang.UnreachableError) File(java.io.File)

Example 15 with GameMode

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

the class GameModeFileLoader method loadGameModeMiscInfo.

private static GameMode loadGameModeMiscInfo(String aName, URI uri) {
    GameMode gameMode = null;
    String data;
    try {
        data = LstFileLoader.readFromURI(uri).toString();
    } catch (final PersistenceLayerException ple) {
        Logging.errorPrint(LanguageBundle.getFormattedString(//$NON-NLS-1$
        "Errors.LstSystemLoader.loadGameModeInfoFile", uri, ple.getMessage()));
        return gameMode;
    }
    String[] fileLines = data.split(LstFileLoader.LINE_SEPARATOR_REGEXP);
    for (int i = 0; i < fileLines.length; i++) {
        String aLine = fileLines[i];
        // Ignore commented-out and empty lines
        if (((!aLine.isEmpty()) && (aLine.charAt(0) == '#')) || aLine.isEmpty()) {
            continue;
        }
        if (gameMode == null) {
            gameMode = new GameMode(aName);
            SystemCollections.addToGameModeList(gameMode);
            gameMode.getModeContext().getReferenceContext().importObject(AbilityCategory.FEAT);
        }
        GameModeLoader.parseMiscGameInfoLine(gameMode, aLine, uri, i + 1);
    }
    // Record how the FEAT category was configured
    AbilityCategory feat = new AbilityCategory();
    feat.copyFields(AbilityCategory.FEAT);
    gameMode.setFeatTemplate(feat);
    int[] dieSizes = gameMode.getDieSizes();
    if (dieSizes == null || dieSizes.length == 0) {
        final int[] defaultDieSizes = { 1, 2, 3, 4, 6, 8, 10, 12, 20, 100, 1000 };
        gameMode.setDieSizes(defaultDieSizes);
        Logging.log(Logging.LST_ERROR, "GameMode (" + gameMode.getName() + ") : MiscInfo.lst did not contain any valid DIESIZES. " + "Using the system default DIESIZES.");
    }
    addDefaultUnitSet(gameMode);
    addDefaultTabInfo(gameMode);
    gameMode.applyPreferences();
    return gameMode;
}
Also used : GameMode(pcgen.core.GameMode) AbilityCategory(pcgen.core.AbilityCategory)

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