Search in sources :

Example 1 with LoadInfo

use of pcgen.core.system.LoadInfo in project pcgen by PCGen.

the class AbstractJunit4CharacterTestCase method setUp.

/**
	 * Sets up the absolute minimum amount of data to create a PlayerCharacter
	 * Object.
	 * @throws Exception
	 */
@Before
public void setUp() throws Exception {
    TestHelper.loadPlugins();
    final GameMode gamemode = new GameMode("3.5");
    gamemode.setBonusFeatLevels("3|3");
    gamemode.setAlignmentText("Alignment");
    final LevelInfo levelInfo = new LevelInfo();
    levelInfo.setLevelString("LEVEL");
    levelInfo.setMaxClassSkillString("LEVEL+3");
    levelInfo.setMaxCrossClassSkillString("(LEVEL+3)/2");
    gamemode.addLevelInfo("Normal", levelInfo);
    gamemode.addXPTableName("Normal");
    gamemode.setDefaultXPTableName("Normal");
    LoadInfo loadable = gamemode.getModeContext().getReferenceContext().constructNowIfNecessary(LoadInfo.class, gamemode.getName());
    loadable.addLoadScoreValue(0, BigDecimal.ONE);
    GameModeFileLoader.addDefaultTabInfo(gamemode);
    SystemCollections.addToGameModeList(gamemode);
    SettingsHandler.setGame("3.5");
    Globals.setUseGUI(false);
    Globals.emptyLists();
    str = BuildUtilities.createStat("Strength", "STR");
    str.put(VariableKey.getConstant("LOADSCORE"), FormulaFactory.getFormulaFor("STRSCORE"));
    str.put(VariableKey.getConstant("OFFHANDLIGHTBONUS"), FormulaFactory.getFormulaFor(2));
    str.put(FormulaKey.STAT_MOD, FormulaFactory.getFormulaFor("floor(SCORE/2)-5"));
    str.put(VariableKey.getConstant("MAXLEVELSTAT=" + str.getKeyName()), FormulaFactory.getFormulaFor(str.getKeyName() + "SCORE-10"));
    dex = BuildUtilities.createStat("Dexterity", "DEX");
    dex.put(FormulaKey.STAT_MOD, FormulaFactory.getFormulaFor("floor(SCORE/2)-5"));
    dex.put(VariableKey.getConstant("MAXLEVELSTAT=" + dex.getKeyName()), FormulaFactory.getFormulaFor(dex.getKeyName() + "SCORE-10"));
    PCStat con = BuildUtilities.createStat("Constitution", "CON");
    con.put(FormulaKey.STAT_MOD, FormulaFactory.getFormulaFor("floor(SCORE/2)-5"));
    con.put(VariableKey.getConstant("MAXLEVELSTAT=" + con.getKeyName()), FormulaFactory.getFormulaFor(con.getKeyName() + "SCORE-10"));
    intel = BuildUtilities.createStat("Intelligence", "INT");
    intel.put(FormulaKey.STAT_MOD, FormulaFactory.getFormulaFor("floor(SCORE/2)-5"));
    intel.put(VariableKey.getConstant("MAXLEVELSTAT=" + intel.getKeyName()), FormulaFactory.getFormulaFor(intel.getKeyName() + "SCORE-10"));
    wis = BuildUtilities.createStat("Wisdom", "WIS");
    wis.put(FormulaKey.STAT_MOD, FormulaFactory.getFormulaFor("floor(SCORE/2)-5"));
    wis.put(VariableKey.getConstant("MAXLEVELSTAT=" + wis.getKeyName()), FormulaFactory.getFormulaFor(wis.getKeyName() + "SCORE-10"));
    cha = BuildUtilities.createStat("Charisma", "CHA");
    cha.put(FormulaKey.STAT_MOD, FormulaFactory.getFormulaFor("floor(SCORE/2)-5"));
    cha.put(VariableKey.getConstant("MAXLEVELSTAT=" + cha.getKeyName()), FormulaFactory.getFormulaFor(cha.getKeyName() + "SCORE-10"));
    gamemode.setBonusFeatLevels("3|3");
    SettingsHandler.setGame("3.5");
    LoadContext context = Globals.getContext();
    AbstractReferenceContext ref = context.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"));
    GameModeFileLoader.addDefaultWieldCategories(context);
    ref.importObject(str);
    ref.importObject(dex);
    ref.importObject(con);
    ref.importObject(intel);
    ref.importObject(wis);
    ref.importObject(cha);
    ref.constructCDOMObject(Language.class, "All Language For Test");
    BuildUtilities.createFact(context, "ClassType", PCClass.class);
    FactDefinition<?, String> fd = BuildUtilities.createFact(context, "SpellType", PCClass.class);
    fd.setSelectable(true);
    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);
    SourceFileLoader.createLangBonusObject(context);
    GameModeFileLoader.addDefaultUnitSet(SettingsHandler.getGame());
    SettingsHandler.getGame().selectDefaultUnitSet();
    ref.importObject(AbilityCategory.FEAT);
    SourceFileLoader.processFactDefinitions(context);
    additionalSetUp();
    if (!ref.resolveReferences(null)) {
        fail("Unconstructed References");
    }
    context.resolvePostValidationTokens();
    context.resolvePostDeferredTokens();
    context.loadCampaignFacets();
    character = new PlayerCharacter();
}
Also used : GameMode(pcgen.core.GameMode) LoadInfo(pcgen.core.system.LoadInfo) PlayerCharacter(pcgen.core.PlayerCharacter) AbstractReferenceContext(pcgen.rules.context.AbstractReferenceContext) LevelInfo(pcgen.core.LevelInfo) LoadContext(pcgen.rules.context.LoadContext) PCStat(pcgen.core.PCStat) Before(org.junit.Before)

Example 2 with LoadInfo

use of pcgen.core.system.LoadInfo in project pcgen by PCGen.

the class PCGenTestCase method setUp.

/**
	 * Sets up some basic stuff that must be present for tests to work.
	 */
@Override
protected void setUp() throws Exception {
    super.setUp();
    final GameMode gamemode = new GameMode("3.5");
    gamemode.setBonusFeatLevels("3|3");
    gamemode.setAlignmentText("Alignment");
    gamemode.addLevelInfo("Normal", new LevelInfo());
    gamemode.addXPTableName("Normal");
    gamemode.setDefaultXPTableName("Normal");
    gamemode.clearLoadContext();
    LoadInfo loadable = gamemode.getModeContext().getReferenceContext().constructNowIfNecessary(LoadInfo.class, gamemode.getName());
    loadable.addLoadScoreValue(0, BigDecimal.ONE);
    GameModeFileLoader.addDefaultTabInfo(gamemode);
    SystemCollections.addToGameModeList(gamemode);
    SettingsHandler.setGame("3.5");
    count = 0;
}
Also used : GameMode(pcgen.core.GameMode) LoadInfo(pcgen.core.system.LoadInfo) LevelInfo(pcgen.core.LevelInfo)

Example 3 with LoadInfo

use of pcgen.core.system.LoadInfo in project pcgen by PCGen.

the class PlayerCharacterTest method testAdjustMoveRates.

/**
	 * Test the processing and order of operations of the adjustMoveRates method.
	 */
public void testAdjustMoveRates() {
    Ability quickFlySlowSwim = TestHelper.makeAbility("quickFlySlowSwim", AbilityCategory.FEAT.getKeyName(), "Foo");
    PCTemplate template = TestHelper.makeTemplate("slowFlyQuickSwim");
    PCTemplate template2 = TestHelper.makeTemplate("dig");
    LoadContext context = Globals.getContext();
    final BonusObj digBonus = Bonus.newBonus(context, "MOVEADD|TYPE.Dig|60");
    assertNotNull("Failed to create bonus", digBonus);
    template2.addToListFor(ListKey.BONUS, digBonus);
    //template.addm
    context.getReferenceContext().importObject(quickFlySlowSwim);
    context.getReferenceContext().importObject(template2);
    context.unconditionallyProcess(human, "MOVE", "Walk,30");
    context.unconditionallyProcess(quickFlySlowSwim, "MOVE", "Swim,10,Fly,30");
    context.unconditionallyProcess(template, "MOVE", "Swim,30,Fly,10");
    readyToRun();
    GameMode game = SettingsHandler.getGame();
    LoadInfo li = game.getModeContext().getReferenceContext().constructNowIfNecessary(LoadInfo.class, game.getName());
    li.addLoadScoreValue(0, new BigDecimal("100.0"));
    li.addLoadScoreValue(10, new BigDecimal("100.0"));
    li.addLoadMultiplier("LIGHT", new Float(100), "100", 0);
    PlayerCharacter pc = getCharacter();
    setPCStat(pc, str, 10);
    pc.setRace(human);
    pc.calcActiveBonuses();
    pc.adjustMoveRates();
    CharacterDisplay display = pc.getDisplay();
    assertEquals(0.0, display.movementOfType("Swim"), 0.1);
    assertEquals(0.0, display.movementOfType("Fly"), 0.1);
    addAbility(AbilityCategory.FEAT, quickFlySlowSwim);
    pc.calcActiveBonuses();
    pc.adjustMoveRates();
    assertEquals(10.0, display.movementOfType("Swim"), 0.1);
    assertEquals(30.0, display.movementOfType("Fly"), 0.1);
    pc.addTemplate(template);
    pc.adjustMoveRates();
    assertEquals(30.0, display.movementOfType("Swim"), 0.1);
    assertEquals(30.0, display.movementOfType("Fly"), 0.1);
    pc.addTemplate(template2);
    pc.adjustMoveRates();
    assertEquals(30.0, display.movementOfType("Swim"), 0.1);
    assertEquals(30.0, display.movementOfType("Fly"), 0.1);
    assertEquals(60.0, display.movementOfType("Dig"), 0.1);
}
Also used : LoadInfo(pcgen.core.system.LoadInfo) BonusObj(pcgen.core.bonus.BonusObj) CharacterDisplay(pcgen.core.display.CharacterDisplay) LoadContext(pcgen.rules.context.LoadContext) BigDecimal(java.math.BigDecimal)

Example 4 with LoadInfo

use of pcgen.core.system.LoadInfo in project pcgen by PCGen.

the class LoadInfoLoader method getLoadable.

@Override
protected LoadInfo getLoadable(LoadContext context, String firstToken, URI sourceURI) throws PersistenceLayerException {
    LoadInfo loadable = context.getReferenceContext().constructNowIfNecessary(LoadInfo.class, getGameMode());
    LstUtils.processToken(context, loadable, sourceURI, firstToken);
    return loadable;
}
Also used : LoadInfo(pcgen.core.system.LoadInfo)

Aggregations

LoadInfo (pcgen.core.system.LoadInfo)4 GameMode (pcgen.core.GameMode)2 LevelInfo (pcgen.core.LevelInfo)2 LoadContext (pcgen.rules.context.LoadContext)2 BigDecimal (java.math.BigDecimal)1 Before (org.junit.Before)1 PCStat (pcgen.core.PCStat)1 PlayerCharacter (pcgen.core.PlayerCharacter)1 BonusObj (pcgen.core.bonus.BonusObj)1 CharacterDisplay (pcgen.core.display.CharacterDisplay)1 AbstractReferenceContext (pcgen.rules.context.AbstractReferenceContext)1