Search in sources :

Example 26 with GameMode

use of pcgen.core.GameMode 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 27 with GameMode

use of pcgen.core.GameMode 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 28 with GameMode

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

the class IconTokenTest method testValidSyntax.

public void testValidSyntax() throws Exception {
    GameMode gameMode = SettingsHandler.getGame();
    assertNull("starting condition, eyegear icon should be null", gameMode.getEquipTypeIcon("Eyegear"));
    IconToken token = new IconToken();
    assertTrue("Parse should succeed", token.parse(gameMode, "Eyegear|preview/summary/images/icon_eye.png", uri));
    assertEquals("Incorrect icon path", "preview/summary/images/icon_eye.png", gameMode.getEquipTypeIcon("Eyegear"));
    assertEquals("Case misimatch fails", "preview/summary/images/icon_eye.png", gameMode.getEquipTypeIcon("EyegeaR"));
    assertNull("Unknown type should be null", gameMode.getEquipTypeIcon("Unknown"));
}
Also used : GameMode(pcgen.core.GameMode)

Example 29 with GameMode

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

the class PrePointBuyMethodTester method passes.

/**
	 * @see pcgen.core.prereq.PrerequisiteTest#passes(pcgen.core.PlayerCharacter)
	 */
@Override
public int passes(final Prerequisite prereq, final CharacterDisplay display, CDOMObject source) {
    int runningTotal = 0;
    final GameMode gm = SettingsHandler.getGame();
    if (gm != null) {
        final String purchaseMode = gm.getPurchaseModeMethodName();
        if ((purchaseMode != null) && purchaseMode.equalsIgnoreCase(prereq.getKey())) {
            ++runningTotal;
        }
    }
    return countedTotal(prereq, runningTotal);
}
Also used : GameMode(pcgen.core.GameMode)

Example 30 with GameMode

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

the class SkillSitTokenTest method setUp.

/**
	 * @see pcgen.AbstractCharacterTestCase#setUp()
	 */
@Override
protected void setUp() throws Exception {
    super.setUp();
    PlayerCharacter character = getCharacter();
    final LevelInfo levelInfo = new LevelInfo();
    levelInfo.setLevelString("LEVEL");
    levelInfo.setMaxClassSkillString("LEVEL+3");
    levelInfo.setMaxCrossClassSkillString("(LEVEL+3)/2");
    GameMode gamemode = SettingsHandler.getGame();
    gamemode.addLevelInfo("Default", levelInfo);
    //Stats
    setPCStat(character, dex, 16);
    setPCStat(character, intel, 17);
    LoadContext context = Globals.getContext();
    BonusObj aBonus = Bonus.newBonus(context, "MODSKILLPOINTS|NUMBER|INT");
    if (aBonus != null) {
        intel.addToListFor(ListKey.BONUS, aBonus);
    }
    // Race
    Race testRace = new Race();
    testRace.setName("TestRace");
    character.setRace(testRace);
    // Class
    PCClass myClass = new PCClass();
    myClass.setName("My Class");
    myClass.put(FormulaKey.START_SKILL_POINTS, FormulaFactory.getFormulaFor(3));
    character.incrementClassLevel(5, myClass, true);
    //Skills
    knowledge = new Skill[2];
    knowledge[0] = new Skill();
    context.unconditionallyProcess(knowledge[0], "CLASSES", "MyClass");
    knowledge[0].setName("KNOWLEDGE (ARCANA)");
    TestHelper.addType(knowledge[0], "KNOWLEDGE.INT");
    CDOMDirectSingleRef<PCStat> intelRef = CDOMDirectSingleRef.getRef(intel);
    knowledge[0].put(ObjectKey.KEY_STAT, intelRef);
    context.getReferenceContext().importObject(knowledge[0]);
    aBonus = Bonus.newBonus(context, "SITUATION|Tumble=On Hot Concrete|2");
    if (aBonus != null) {
        knowledge[0].addToListFor(ListKey.BONUS, aBonus);
    }
    SkillRankControl.modRanks(8.0, myClass, true, character, knowledge[0]);
    knowledge[1] = new Skill();
    context.unconditionallyProcess(knowledge[1], "CLASSES", "MyClass");
    knowledge[1].setName("KNOWLEDGE (RELIGION)");
    TestHelper.addType(knowledge[1], "KNOWLEDGE.INT");
    knowledge[1].put(ObjectKey.KEY_STAT, intelRef);
    aBonus = Bonus.newBonus(context, "SITUATION|Balance=On a Ball|2");
    if (aBonus != null) {
        knowledge[1].addToListFor(ListKey.BONUS, aBonus);
    }
    context.getReferenceContext().importObject(knowledge[1]);
    SkillRankControl.modRanks(5.0, myClass, true, character, knowledge[1]);
    tumble = new Skill();
    context.unconditionallyProcess(tumble, "CLASSES", "MyClass");
    tumble.setName("Tumble");
    tumble.addToListFor(ListKey.TYPE, Type.getConstant("DEX"));
    tumble.addToListFor(ListKey.SITUATION, "On Hot Concrete");
    tumble.addToListFor(ListKey.SITUATION, "Down a Mountain");
    CDOMDirectSingleRef<PCStat> dexRef = CDOMDirectSingleRef.getRef(dex);
    tumble.put(ObjectKey.KEY_STAT, dexRef);
    context.getReferenceContext().importObject(tumble);
    SkillRankControl.modRanks(7.0, myClass, true, character, tumble);
    balance = new Skill();
    context.unconditionallyProcess(balance, "CLASSES", "MyClass");
    balance.setName("Balance");
    balance.addToListFor(ListKey.TYPE, Type.getConstant("DEX"));
    balance.addToListFor(ListKey.SITUATION, "On a Ball");
    balance.put(ObjectKey.KEY_STAT, dexRef);
    aBonus = Bonus.newBonus(context, "SKILL|Balance|2|PRESKILL:1,Tumble=5|TYPE=Synergy.STACK");
    if (aBonus != null) {
        balance.addToListFor(ListKey.BONUS, aBonus);
    }
    context.getReferenceContext().importObject(balance);
    SkillRankControl.modRanks(4.0, myClass, true, character, balance);
    context.getReferenceContext().buildDerivedObjects();
    context.getReferenceContext().resolveReferences(null);
    character.calcActiveBonuses();
}
Also used : GameMode(pcgen.core.GameMode) Skill(pcgen.core.Skill) PlayerCharacter(pcgen.core.PlayerCharacter) BonusObj(pcgen.core.bonus.BonusObj) LevelInfo(pcgen.core.LevelInfo) Race(pcgen.core.Race) LoadContext(pcgen.rules.context.LoadContext) PCClass(pcgen.core.PCClass) PCStat(pcgen.core.PCStat)

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