use of pcgen.core.Race in project pcgen by PCGen.
the class SpellListTokenTest method setUp.
/*
* @see TestCase#setUp()
*/
@Override
protected void setUp() throws Exception {
super.setUp();
LoadContext context = Globals.getContext();
SettingsHandler.getGame().setSpellBaseDC("10+SPELLLEVEL+BASESPELLSTAT");
SimpleLoader<BonusSpellInfo> bonusSpellLoader = new SimpleLoader<>(BonusSpellInfo.class);
try {
URI testURI = new URI("file:/" + getClass().getName() + ".java");
bonusSpellLoader.parseLine(context, "1 BASESTATSCORE:12 STATRANGE:8", testURI);
bonusSpellLoader.parseLine(context, "2 BASESTATSCORE:14 STATRANGE:8", testURI);
bonusSpellLoader.parseLine(context, "3 BASESTATSCORE:16 STATRANGE:8", testURI);
} catch (URISyntaxException e) {
throw new UnreachableError(e);
}
// Human
human = new Race();
final BonusObj bon = Bonus.newBonus(context, "FEAT|POOL|2");
human.addToListFor(ListKey.BONUS, bon);
arcaneClass = new PCClass();
arcaneClass.setName("TestArcane");
BuildUtilities.setFact(arcaneClass, "SpellType", "Arcane");
context.unconditionallyProcess(arcaneClass, "SPELLSTAT", "CHA");
arcaneClass.put(ObjectKey.SPELLBOOK, false);
arcaneClass.put(ObjectKey.MEMORIZE_SPELLS, false);
context.unconditionallyProcess(arcaneClass.getOriginalClassLevel(1), "KNOWN", "4,2,1");
context.unconditionallyProcess(arcaneClass.getOriginalClassLevel(1), "CAST", "3,1,0");
context.getReferenceContext().importObject(arcaneClass);
divineClass = new PCClass();
divineClass.setName("TestDivine");
BuildUtilities.setFact(divineClass, "SpellType", "Divine");
context.unconditionallyProcess(divineClass, "SPELLSTAT", "WIS");
divineClass.put(ObjectKey.SPELLBOOK, false);
divineClass.put(ObjectKey.MEMORIZE_SPELLS, true);
context.unconditionallyProcess(divineClass.getOriginalClassLevel(1), "CAST", "3,1,0");
context.unconditionallyProcess(divineClass, "SPELLLEVEL", "CLASS|SPELLCASTER.Divine=1|Cure Light Wounds");
context.getReferenceContext().importObject(divineClass);
context.resolveDeferredTokens();
context.getReferenceContext().buildDerivedObjects();
context.getReferenceContext().resolveReferences(null);
}
use of pcgen.core.Race 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();
}
use of pcgen.core.Race in project pcgen by PCGen.
the class MasterbonusraceToken method parseTokenWithSeparator.
@Override
protected ParseResult parseTokenWithSeparator(LoadContext context, CompanionMod cMod, String value) {
StringTokenizer tok = new StringTokenizer(value, Constants.PIPE);
while (tok.hasMoreTokens()) {
String token = tok.nextToken();
CDOMSingleRef<Race> ref = context.getReferenceContext().getCDOMReference(RACE_CLASS, token);
context.getObjectContext().addToList(cMod, ListKey.APPLIED_RACE, ref);
}
return ParseResult.SUCCESS;
}
use of pcgen.core.Race in project pcgen by PCGen.
the class PJepTest method testJepIf.
public void testJepIf() {
final PlayerCharacter character = new PlayerCharacter();
Float val;
val = character.getVariableValue("var(\"UseAlternateDamage\")", "");
assertEquals("Undefined variable should return 0", 0.0, val.doubleValue(), 0.1);
Race giantRace = TestHelper.makeRace("Ogre");
giantRace.put(VariableKey.getConstant("UseAlternateDamage"), FormulaFactory.getFormulaFor(2));
character.setRace(giantRace);
val = character.getVariableValue("var(\"UseAlternateDamage\")", "");
assertEquals("Variable defined to be 2.", 2.0, val.doubleValue(), 0.1);
val = character.getVariableValue("2==2", "");
assertEquals("Equality test of 2==2 should be true.", 1.0, val.doubleValue(), 0.1);
val = character.getVariableValue("3-1==2", "");
assertEquals("Equality test of 3-1==2 should be true.", 1.0, val.doubleValue(), 0.1);
val = character.getVariableValue("var(\"UseAlternateDamage\")>1", "");
assertEquals("Variable defined to be 2 should be more than 1", 1.0, val.doubleValue(), 0.1);
val = character.getVariableValue("var(\"UseAlternateDamage\")<3", "");
assertEquals("Variable defined to be 2 should be more than 1 be less than 3", 1.0, val.doubleValue(), 0.1);
val = character.getVariableValue("var(\"UseAlternateDamage\")==1", "");
assertEquals("Variable defined to be 2 should not be equal to 1", 0.0, val.doubleValue(), 0.1);
val = character.getVariableValue("var(\"UseAlternateDamage\")>=2", "");
assertEquals("Variable defined to be 2 should be >= 2", 1.0, val.doubleValue(), 0.1);
val = character.getVariableValue("var(\"UseAlternateDamage\")<=2", "");
assertEquals("Variable defined to be 2 should be <= 2", 1.0, val.doubleValue(), 0.1);
val = character.getVariableValue("var(\"UseAlternateDamage\")==2", "");
assertEquals("Variable defined to be 2 should be == 2", 1.0, val.doubleValue(), 0.1);
val = character.getVariableValue("IF(var(\"UseAlternateDamage\")==2,-2,5)", "");
assertEquals("Test should have returned -2", -2, val.doubleValue(), 0.1);
}
use of pcgen.core.Race in project pcgen by PCGen.
the class RaceModel method update.
/**
* Performs an update of the RaceModel.
*/
public void update() {
clear();
for (final Race race : Globals.getContext().getReferenceContext().getConstructedCDOMObjects(Race.class)) {
if (!contains(race.toString())) {
this.addElement(race.toString());
this.removeElement(Globals.s_EMPTYRACE.toString());
}
}
}
Aggregations