Search in sources :

Example 1 with StatToken

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;
    }
}
Also used : AbilityListToken(pcgen.io.exporttoken.AbilityListToken) SkillpointsToken(pcgen.io.exporttoken.SkillpointsToken) EqTypeToken(pcgen.io.exporttoken.EqTypeToken) MovementToken(pcgen.io.exporttoken.MovementToken) AbilityToken(pcgen.io.exporttoken.AbilityToken) SkillToken(pcgen.io.exporttoken.SkillToken) GameModeToken(pcgen.io.exporttoken.GameModeToken) WeaponhToken(pcgen.io.exporttoken.WeaponhToken) EqToken(pcgen.io.exporttoken.EqToken) BonusToken(pcgen.io.exporttoken.BonusToken) TotalToken(pcgen.io.exporttoken.TotalToken) WeaponToken(pcgen.io.exporttoken.WeaponToken) StatToken(pcgen.io.exporttoken.StatToken)

Example 2 with StatToken

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);
}
Also used : BonusObj(pcgen.core.bonus.BonusObj) LoadContext(pcgen.rules.context.LoadContext) Spell(pcgen.core.spell.Spell) CharacterSpell(pcgen.core.character.CharacterSpell) StatToken(pcgen.io.exporttoken.StatToken)

Aggregations

StatToken (pcgen.io.exporttoken.StatToken)2 BonusObj (pcgen.core.bonus.BonusObj)1 CharacterSpell (pcgen.core.character.CharacterSpell)1 Spell (pcgen.core.spell.Spell)1 AbilityListToken (pcgen.io.exporttoken.AbilityListToken)1 AbilityToken (pcgen.io.exporttoken.AbilityToken)1 BonusToken (pcgen.io.exporttoken.BonusToken)1 EqToken (pcgen.io.exporttoken.EqToken)1 EqTypeToken (pcgen.io.exporttoken.EqTypeToken)1 GameModeToken (pcgen.io.exporttoken.GameModeToken)1 MovementToken (pcgen.io.exporttoken.MovementToken)1 SkillToken (pcgen.io.exporttoken.SkillToken)1 SkillpointsToken (pcgen.io.exporttoken.SkillpointsToken)1 TotalToken (pcgen.io.exporttoken.TotalToken)1 WeaponToken (pcgen.io.exporttoken.WeaponToken)1 WeaponhToken (pcgen.io.exporttoken.WeaponhToken)1 LoadContext (pcgen.rules.context.LoadContext)1