use of pcgen.core.Skill in project pcgen by PCGen.
the class ExportHandlerTest method setUp.
/**
* @see pcgen.AbstractCharacterTestCase#setUp()
*/
@Override
protected void setUp() throws Exception {
super.setUp();
PlayerCharacter character = getCharacter();
LoadContext context = Globals.getContext();
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);
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);
character.setSkillOrder(knowledge[0], 2);
Globals.getContext().getReferenceContext().importObject(knowledge[0]);
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);
character.setSkillOrder(knowledge[1], 3);
Globals.getContext().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"));
CDOMDirectSingleRef<PCStat> dexRef = CDOMDirectSingleRef.getRef(dex);
tumble.put(ObjectKey.KEY_STAT, dexRef);
character.setSkillOrder(tumble, 4);
Globals.getContext().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.put(ObjectKey.KEY_STAT, dexRef);
character.setSkillOrder(balance, 1);
aBonus = Bonus.newBonus(context, "SKILL|Balance|2|PRESKILL:1,Tumble=5|TYPE=Synergy.STACK");
if (aBonus != null) {
balance.addToListFor(ListKey.BONUS, aBonus);
}
Globals.getContext().getReferenceContext().importObject(balance);
SkillRankControl.modRanks(4.0, myClass, true, character, balance);
character.calcActiveBonuses();
weapon = new Equipment();
weapon.setName("TestWpn");
weapon.addToListFor(ListKey.TYPE, Type.WEAPON);
gem = new Equipment();
gem.setName("TestGem");
gem.addToListFor(ListKey.TYPE, Type.getConstant("gem"));
gem.setQty(1);
armor = new Equipment();
armor.setName("TestArmorSuit");
TestHelper.addType(armor, "armor.suit");
context.getReferenceContext().buildDerivedObjects();
context.getReferenceContext().resolveReferences(null);
}
use of pcgen.core.Skill in project pcgen by PCGen.
the class ClassSkillsLevelTokenTest method testUnparseSingleRanked.
@Test
public void testUnparseSingleRanked() throws PersistenceLayerException {
List<CDOMReference<Skill>> refs = new ArrayList<>();
addSingleRef(refs, "TestWP1");
ReferenceChoiceSet<Skill> rcs = new ReferenceChoiceSet<>(refs);
ChoiceSet<Skill> cs = new ChoiceSet<>(getSubToken().getTokenName(), rcs);
PersistentTransitionChoice<Skill> tc = new ConcretePersistentTransitionChoice<>(cs, FormulaFactory.ONE);
primaryProf.addToListFor(ListKey.ADD, tc);
tc.setChoiceActor(new ClassSkillChoiceActor(fighter, 3));
String[] unparsed = getToken().unparse(primaryContext, primaryProf);
expectSingle(unparsed, getSubTokenName() + '|' + "TestWP1,AUTORANK=3");
}
use of pcgen.core.Skill in project pcgen by PCGen.
the class ClassSkillsLevelTokenTest method testUnparseExclusive.
@Test
public void testUnparseExclusive() throws PersistenceLayerException {
List<CDOMReference<Skill>> refs = new ArrayList<>();
ObjectMatchingReference<Skill, Boolean> omr = new ObjectMatchingReference<>("EXCLUSIVE", Skill.class, getAllRef(), ObjectKey.EXCLUSIVE, Boolean.TRUE);
omr.returnIncludesNulls(true);
refs.add(omr);
ReferenceChoiceSet<Skill> rcs = new ReferenceChoiceSet<>(refs);
ChoiceSet<Skill> cs = new ChoiceSet<>(getSubToken().getTokenName(), rcs);
PersistentTransitionChoice<Skill> tc = new ConcretePersistentTransitionChoice<>(cs, FormulaFactory.ONE);
primaryProf.addToListFor(ListKey.ADD, tc);
tc.setChoiceActor(new ClassSkillChoiceActor(fighter, null));
String[] unparsed = getToken().unparse(primaryContext, primaryProf);
expectSingle(unparsed, getSubTokenName() + '|' + "EXCLUSIVE");
}
use of pcgen.core.Skill in project pcgen by PCGen.
the class ClassSkillsLevelTokenTest method testUnparseUntrained.
@Test
public void testUnparseUntrained() throws PersistenceLayerException {
List<CDOMReference<Skill>> refs = new ArrayList<>();
ObjectMatchingReference<Skill, Boolean> omr = new ObjectMatchingReference<>("UNTRAINED", Skill.class, getAllRef(), ObjectKey.USE_UNTRAINED, Boolean.TRUE);
omr.returnIncludesNulls(true);
refs.add(omr);
ReferenceChoiceSet<Skill> rcs = new ReferenceChoiceSet<>(refs);
ChoiceSet<Skill> cs = new ChoiceSet<>(getSubToken().getTokenName(), rcs);
PersistentTransitionChoice<Skill> tc = new ConcretePersistentTransitionChoice<>(cs, FormulaFactory.ONE);
primaryProf.addToListFor(ListKey.ADD, tc);
tc.setChoiceActor(new ClassSkillChoiceActor(fighter, null));
String[] unparsed = getToken().unparse(primaryContext, primaryProf);
expectSingle(unparsed, getSubTokenName() + '|' + "UNTRAINED");
}
use of pcgen.core.Skill in project pcgen by PCGen.
the class ClassSkillsTokenTest method testUnparseUntrained.
@Test
public void testUnparseUntrained() throws PersistenceLayerException {
List<CDOMReference<Skill>> refs = new ArrayList<>();
ObjectMatchingReference<Skill, Boolean> omr = new ObjectMatchingReference<>("UNTRAINED", Skill.class, getAllRef(), ObjectKey.USE_UNTRAINED, Boolean.TRUE);
omr.returnIncludesNulls(true);
refs.add(omr);
ReferenceChoiceSet<Skill> rcs = new ReferenceChoiceSet<>(refs);
ChoiceSet<Skill> cs = new ChoiceSet<>(getSubToken().getTokenName(), rcs);
PersistentTransitionChoice<Skill> tc = new ConcretePersistentTransitionChoice<>(cs, FormulaFactory.ONE);
primaryProf.addToListFor(ListKey.ADD, tc);
tc.setChoiceActor(new ClassSkillChoiceActor(fighter, null));
String[] unparsed = getToken().unparse(primaryContext, primaryProf);
expectSingle(unparsed, getSubTokenName() + '|' + "UNTRAINED");
}
Aggregations