use of pcgen.core.PlayerCharacter in project pcgen by PCGen.
the class StatTokenTest method testStatMods.
/**
* Test out the processing of stat mods, including stacking issues.
*/
public void testStatMods() {
PlayerCharacter pc = getCharacter();
StatToken statTok = new StatToken();
setPCStat(pc, dex, 10);
assertEquals("Stat Name.", "DEX", statTok.getToken("STAT.1.NAME", pc, null));
assertEquals("Total stat.", "+0", statTok.getToken("STAT.1.MOD", pc, null));
assertEquals("Temp stat.", "+0", statTok.getToken("STAT.1.MOD.NOEQUIP", pc, null));
assertEquals("Equip stat.", "+0", statTok.getToken("STAT.1.MOD.NOTEMP", pc, null));
assertEquals("No equip/temp stat.", "+0", statTok.getToken("STAT.1.MOD.NOEQUIP.NOTEMP", pc, null));
assertEquals("Base stat.", "+0", statTok.getToken("STAT.1.MOD.NOEQUIP.NOTEMP", pc, null));
pc.addEquipment(boots);
EquipSet es = new EquipSet("0.1", "Equipped");
pc.addEquipSet(es);
es = new EquipSet("0.1.2", "Feet", boots.getName(), boots);
pc.addEquipSet(es);
pc.setCalcEquipmentList();
pc.calcActiveBonuses();
assertEquals("Total stat.", "+1", statTok.getToken("STAT.1.MOD", pc, null));
assertEquals("Temp stat.", "+0", statTok.getToken("STAT.1.MOD.NOEQUIP", pc, null));
assertEquals("Equip stat.", "+1", statTok.getToken("STAT.1.MOD.NOTEMP", pc, null));
assertEquals("No equip/temp stat.", "+0", statTok.getToken("STAT.1.MOD.NOEQUIP.NOTEMP", pc, null));
assertEquals("Base stat.", "+0", statTok.getToken("STAT.1.BASEMOD", pc, null));
pc.setUseTempMods(true);
BonusObj bonus = spell.getRawBonusList(pc).get(0);
pc.addTempBonus(bonus, spell, pc);
pc.calcActiveBonuses();
assertEquals("Total stat.", "+2", statTok.getToken("STAT.1.MOD", pc, null));
assertEquals("Temp stat.", "+2", statTok.getToken("STAT.1.MOD.NOEQUIP", pc, null));
assertEquals("Equip stat.", "+1", statTok.getToken("STAT.1.MOD.NOTEMP", pc, null));
assertEquals("No equip/temp stat.", "+0", statTok.getToken("STAT.1.MOD.NOEQUIP.NOTEMP", pc, null));
assertEquals("Base stat.", "+0", statTok.getToken("STAT.1.BASEMOD", pc, null));
pc.addTemplate(template1);
pc.calcActiveBonuses();
assertEquals("Total stat.", "+2", statTok.getToken("STAT.1.MOD", pc, null));
assertEquals("Temp stat.", "+2", statTok.getToken("STAT.1.MOD.NOEQUIP", pc, null));
assertEquals("Equip stat.", "+1", statTok.getToken("STAT.1.MOD.NOTEMP", pc, null));
assertEquals("No equip/temp stat.", "+0", statTok.getToken("STAT.1.MOD.NOEQUIP.NOTEMP", pc, null));
assertEquals("Base stat.", "+0", statTok.getToken("STAT.1.BASEMOD", pc, null));
pc.addTemplate(template2);
pc.calcActiveBonuses();
assertEquals("Total stat.", "+2", statTok.getToken("STAT.1.MOD", pc, null));
assertEquals("Temp stat.", "+2", statTok.getToken("STAT.1.MOD.NOEQUIP", pc, null));
assertEquals("Equip stat.", "+1", statTok.getToken("STAT.1.MOD.NOTEMP", pc, null));
assertEquals("No equip/temp stat.", "+1", statTok.getToken("STAT.1.MOD.NOEQUIP.NOTEMP", pc, null));
assertEquals("Base stat.", "+0", statTok.getToken("STAT.1.BASEMOD", pc, null));
}
use of pcgen.core.PlayerCharacter in project pcgen by PCGen.
the class StatTokenTest method testBonusStacking.
/**
* Test out the stacking of bonuses particularly when NOEUIP or NOTEMP
* are used.
*/
public void testBonusStacking() {
PlayerCharacter pc = getCharacter();
StatToken statTok = new StatToken();
setPCStat(pc, dex, 10);
assertEquals("Stat Name.", "DEX", statTok.getToken("STAT.1.NAME", pc, null));
assertEquals("Total stat.", "10", statTok.getToken("STAT.1", pc, null));
assertEquals("Temp stat.", "10", statTok.getToken("STAT.1.NOEQUIP", pc, null));
assertEquals("Equip stat.", "10", statTok.getToken("STAT.1.NOTEMP", pc, null));
assertEquals("No equip/temp stat.", "10", statTok.getToken("STAT.1.NOEQUIP.NOTEMP", pc, null));
assertEquals("Base stat.", "10", statTok.getToken("STAT.1.NOEQUIP.NOTEMP", pc, null));
pc.addEquipment(boots);
EquipSet es = new EquipSet("0.1", "Equipped");
pc.addEquipSet(es);
es = new EquipSet("0.1.2", "Feet", boots.getName(), boots);
pc.addEquipSet(es);
pc.setCalcEquipmentList();
pc.calcActiveBonuses();
assertEquals("Total stat.", "12", statTok.getToken("STAT.1", pc, null));
assertEquals("Temp stat.", "10", statTok.getToken("STAT.1.NOEQUIP", pc, null));
assertEquals("Equip stat.", "12", statTok.getToken("STAT.1.NOTEMP", pc, null));
assertEquals("No equip/temp stat.", "10", statTok.getToken("STAT.1.NOEQUIP.NOTEMP", pc, null));
assertEquals("Base stat.", "10", statTok.getToken("STAT.1.BASE", pc, null));
pc.setUseTempMods(true);
BonusObj bonus = spell.getRawBonusList(pc).get(0);
pc.addTempBonus(bonus, spell, pc);
pc.calcActiveBonuses();
assertEquals("Total stat.", "14", statTok.getToken("STAT.1", pc, null));
assertEquals("Temp stat.", "14", statTok.getToken("STAT.1.NOEQUIP", pc, null));
assertEquals("Equip stat.", "12", statTok.getToken("STAT.1.NOTEMP", pc, null));
assertEquals("No equip/temp stat.", "10", statTok.getToken("STAT.1.NOEQUIP.NOTEMP", pc, null));
assertEquals("Base stat.", "10", statTok.getToken("STAT.1.BASE", pc, null));
pc.addTemplate(template1);
pc.calcActiveBonuses();
assertEquals("Total stat.", "15", statTok.getToken("STAT.1", pc, null));
assertEquals("Temp stat.", "15", statTok.getToken("STAT.1.NOEQUIP", pc, null));
assertEquals("Equip stat.", "13", statTok.getToken("STAT.1.NOTEMP", pc, null));
assertEquals("No equip/temp stat.", "11", statTok.getToken("STAT.1.NOEQUIP.NOTEMP", pc, null));
assertEquals("Base stat.", "10", statTok.getToken("STAT.1.BASE", pc, null));
pc.addTemplate(template2);
pc.calcActiveBonuses();
assertEquals("Total stat.", "15", statTok.getToken("STAT.1", pc, null));
assertEquals("Temp stat.", "15", statTok.getToken("STAT.1.NOEQUIP", pc, null));
assertEquals("Equip stat.", "13", statTok.getToken("STAT.1.NOTEMP", pc, null));
assertEquals("No equip/temp stat.", "12", statTok.getToken("STAT.1.NOEQUIP.NOTEMP", pc, null));
assertEquals("Base stat.", "10", statTok.getToken("STAT.1.BASE", pc, null));
}
use of pcgen.core.PlayerCharacter in project pcgen by PCGen.
the class StatTokenTest method testLockedStats.
/**
* Test out the way in which locked stats are reported.
*/
public void testLockedStats() {
PlayerCharacter pc = getCharacter();
StatToken statTok = new StatToken();
setPCStat(pc, wis, 10);
assertEquals("Stat Name.", "WIS", statTok.getToken("STAT.4.NAME", pc, null));
assertEquals("Total stat.", "10", statTok.getToken("STAT.4", pc, null));
assertEquals("Temp stat.", "10", statTok.getToken("STAT.4.NOEQUIP", pc, null));
assertEquals("Equip stat.", "10", statTok.getToken("STAT.4.NOTEMP", pc, null));
assertEquals("No equip/temp stat.", "10", statTok.getToken("STAT.4.NOEQUIP.NOTEMP", pc, null));
pc.addTemplate(template3);
pc.calcActiveBonuses();
assertEquals("Stat Name.", "WIS", statTok.getToken("STAT.4.NAME", pc, null));
assertEquals("Total stat.", "12", statTok.getToken("STAT.4", pc, null));
assertEquals("Temp stat.", "12", statTok.getToken("STAT.4.NOEQUIP", pc, null));
assertEquals("Equip stat.", "12", statTok.getToken("STAT.4.NOTEMP", pc, null));
assertEquals("No equip/temp stat.", "12", statTok.getToken("STAT.4.NOEQUIP.NOTEMP", pc, null));
pc.addTemplate(template4);
pc.calcActiveBonuses();
assertEquals("Stat Name.", "WIS", statTok.getToken("STAT.4.NAME", pc, null));
assertEquals("Total stat.", "12", statTok.getToken("STAT.4", pc, null));
assertEquals("Temp stat.", "12", statTok.getToken("STAT.4.NOEQUIP", pc, null));
assertEquals("Equip stat.", "12", statTok.getToken("STAT.4.NOTEMP", pc, null));
assertEquals("No equip/temp stat.", "12", statTok.getToken("STAT.4.NOEQUIP.NOTEMP", pc, null));
pc.removeTemplate(template3);
pc.calcActiveBonuses();
assertEquals("Stat Name.", "WIS", statTok.getToken("STAT.4.NAME", pc, null));
assertEquals("Total stat.", "2", statTok.getToken("STAT.4", pc, null));
assertEquals("Temp stat.", "2", statTok.getToken("STAT.4.NOEQUIP", pc, null));
assertEquals("Equip stat.", "2", statTok.getToken("STAT.4.NOTEMP", pc, null));
assertEquals("No equip/temp stat.", "2", statTok.getToken("STAT.4.NOEQUIP.NOTEMP", pc, null));
}
use of pcgen.core.PlayerCharacter in project pcgen by PCGen.
the class ExportHandlerTest method testFor.
public void testFor() throws IOException {
PlayerCharacter pc = getCharacter();
Ability dummyFeat1 = new Ability();
dummyFeat1.setName("1");
dummyFeat1.setCDOMCategory(AbilityCategory.FEAT);
Ability dummyFeat2 = new Ability();
dummyFeat2.setName("2");
dummyFeat2.setCDOMCategory(AbilityCategory.FEAT);
Ability dummyFeat3 = new Ability();
dummyFeat3.setName("3");
dummyFeat3.setCDOMCategory(AbilityCategory.FEAT);
Ability dummyFeat4 = new Ability();
dummyFeat4.setName("4");
dummyFeat4.setCDOMCategory(AbilityCategory.FEAT);
Ability dummyFeat5 = new Ability();
dummyFeat5.setName("5");
dummyFeat5.setCDOMCategory(AbilityCategory.FEAT);
Ability dummyFeat6 = new Ability();
dummyFeat6.setName("6");
dummyFeat6.setCDOMCategory(AbilityCategory.FEAT);
Ability dummyFeat7 = new Ability();
dummyFeat7.setName("7");
dummyFeat7.setCDOMCategory(AbilityCategory.FEAT);
addAbility(AbilityCategory.FEAT, dummyFeat1);
addAbility(AbilityCategory.FEAT, dummyFeat2);
addAbility(AbilityCategory.FEAT, dummyFeat3);
addAbility(AbilityCategory.FEAT, dummyFeat4);
addAbility(AbilityCategory.FEAT, dummyFeat5);
addAbility(AbilityCategory.FEAT, dummyFeat6);
addAbility(AbilityCategory.FEAT, dummyFeat7);
assertEquals("Test for evaluates correctly", "----------------", evaluateToken("FOR.1,((24-STRLEN[SKILL.0])),24,-,NONE,NONE,1", pc));
assertEquals("Test for evaluates correctly", " ", evaluateToken("FOR.1,((24-STRLEN[SKILL.0])),24, ,NONE,NONE,1", pc));
String tok = "DFOR." + "0" + ",${((count(\"ABILITIES\";\"CATEGORY=FEAT\")+1)/2)}" + ",1" + ",${(count(\"ABILITIES\";\"CATEGORY=FEAT\")+1)}" + ",${((count(\"ABILITIES\";\"CATEGORY=FEAT\")+1)/2)}" + ", \\FEAT.%.NAME\\ " + ",[" + ",]" + ",0";
//Logging.errorPrint( "DFOR Test: " + evaluateToken(tok, pc));
// Test DFOR with alternate syntax for jep passthrough. ie, anything
// surrounded by ${x} will tbe sent straight to be processed. We
// will assume that x is a well formed type of value. This was to get around
// the problems with DFOR not taking ((count("ABILITIES";"CATEGORY=FEAT")+1)
// since it could not figure out how to parse it to send to the right place.
assertEquals("Test for DFOR ", "[ 1 5 ][ 2 6 ][ 3 7 ][ 4 ]", evaluateToken(tok, pc));
}
use of pcgen.core.PlayerCharacter 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);
}
Aggregations