use of pcgen.io.exporttoken.StatToken in project pcgen by PCGen.
the class ExportHandler method populateTokenMap.
/**
* Populate the token map (if not already done so), e.g. Add all
* of the types of Output Tokens to the map
*/
private static void populateTokenMap() {
if (!tokenMapPopulated) {
addToTokenMap(new AbilityToken());
addToTokenMap(new AbilityListToken());
addToTokenMap(new BonusToken());
addToTokenMap(new EqToken());
addToTokenMap(new EqTypeToken());
addToTokenMap(new GameModeToken());
addToTokenMap(new MovementToken());
addToTokenMap(new SkillToken());
addToTokenMap(new SkillpointsToken());
addToTokenMap(new StatToken());
addToTokenMap(new TotalToken());
addToTokenMap(new WeaponToken());
addToTokenMap(new WeaponhToken());
tokenMapPopulated = true;
}
}
use of pcgen.io.exporttoken.StatToken in project pcgen by PCGen.
the class PlayerCharacterTest method testMaxValue.
/**
* Test the processing of the MAX function with respect to character stats.
*/
public void testMaxValue() {
readyToRun();
PlayerCharacter pc = getCharacter();
LoadContext context = Globals.getContext();
setPCStat(pc, str, 8);
setPCStat(pc, dex, 14);
pc.setUseTempMods(true);
assertEquals("STR", -1.0, pc.getVariableValue("STR", ""), 0.1);
assertEquals("DEX", 2.0, pc.getVariableValue("DEX", ""), 0.1);
assertEquals("max(STR,DEX)", 2.0, pc.getVariableValue("max(STR,DEX)", ""), 0.1);
StatToken statTok = new StatToken();
assertEquals("Total stat.", "14", statTok.getToken("STAT.1", pc, null));
assertEquals("Temp stat.", "14", statTok.getToken("STAT.1.NOEQUIP", pc, null));
assertEquals("Equip stat.", "14", statTok.getToken("STAT.1.NOTEMP", pc, null));
assertEquals("No equip/temp stat.", "14", statTok.getToken("STAT.1.NOEQUIP.NOTEMP", pc, null));
assertEquals("Base stat.", "14", statTok.getToken("STAT.1.NOEQUIP.NOTEMP", pc, null));
final BonusObj raceBonus = Bonus.newBonus(context, "STAT|DEX|-2");
giantClass.addToListFor(ListKey.BONUS, raceBonus);
pc.setRace(giantRace);
pc.incrementClassLevel(4, giantClass, true);
assertEquals("Total stat.", "12", statTok.getToken("STAT.1", pc, null));
assertEquals("Temp stat.", "12", statTok.getToken("STAT.1.NOEQUIP", pc, null));
assertEquals("Base stat.", "12", statTok.getToken("STAT.1.NOEQUIP.NOTEMP", pc, null));
assertEquals("DEX", 1.0, pc.getVariableValue("DEX", ""), 0.1);
assertEquals("max(STR,DEX)", 1.0, pc.getVariableValue("max(STR,DEX)", ""), 0.1);
Spell spell2 = new Spell();
spell2.setName("Concrete Boots");
final BonusObj aBonus = Bonus.newBonus(context, "STAT|DEX|-2");
if (aBonus != null) {
spell2.addToListFor(ListKey.BONUS, aBonus);
}
BonusObj penalty = spell2.getRawBonusList(pc).get(0);
pc.addTempBonus(penalty, spell2, pc);
pc.calcActiveBonuses();
assertEquals("Total stat.", "10", statTok.getToken("STAT.1", pc, null));
assertEquals("Temp stat.", "10", statTok.getToken("STAT.1.NOEQUIP", pc, null));
assertEquals("Base stat.", "12", statTok.getToken("STAT.1.NOEQUIP.NOTEMP", pc, null));
assertEquals("DEX", 0.0, pc.getVariableValue("DEX", ""), 0.1);
assertEquals("max(STR,DEX)-STR", 1.0, pc.getVariableValue("max(STR,DEX)-STR", ""), 0.1);
}
Aggregations