Search in sources :

Example 21 with EquipSet

use of pcgen.core.character.EquipSet 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));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) BonusObj(pcgen.core.bonus.BonusObj) EquipSet(pcgen.core.character.EquipSet)

Example 22 with EquipSet

use of pcgen.core.character.EquipSet in project pcgen by PCGen.

the class ExportHandlerTest method testWpnLoop.

/**
	 * Test the behaviour of the weapon loop
	 * @throws IOException
	 */
public void testWpnLoop() throws IOException {
    PlayerCharacter character = getCharacter();
    // Test each token for old and new syntax processing.
    assertEquals("New format SKILL Token", "****", evaluateToken("FOR.0,100,1,**\\WEAPON.%.NAME\\**,NONE,NONE,1", character));
    // Now assign a weapon
    character.addEquipment(weapon);
    EquipSet es = new EquipSet("1", "Default", "", weapon);
    character.addEquipSet(es);
    assertEquals("New format SKILL Token", "**TestWpn**", evaluateToken("FOR.0,100,1,**\\WEAPON.%.NAME\\**,NONE,NONE,1", character));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) EquipSet(pcgen.core.character.EquipSet)

Example 23 with EquipSet

use of pcgen.core.character.EquipSet in project pcgen by PCGen.

the class ExportHandlerTest method testEqtypeLoop.

/**
	 * Test the export of equipment using the eqtype token in a loop.
	 * 
	 * @throws Exception
	 */
public void testEqtypeLoop() throws Exception {
    PlayerCharacter character = getCharacter();
    final String gemLoop = "FOR.0,COUNT[EQTYPE.Gem],1,\\EQTYPE.Gem.%.NAME\\: \\EQTYPE.Gem.%.QTY\\, ,<br/>,1";
    assertEquals("Gem Loop - no gems", "", evaluateToken(gemLoop, character));
    // Now assign a gem
    character.addEquipment(gem);
    EquipSet es = new EquipSet("1", "Default", "", gem);
    character.addEquipSet(es);
    character.setDirty(true);
    assertEquals("Gem loop - 1 gem", " TestGem: 1<br/>", evaluateToken(gemLoop, character));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) EquipSet(pcgen.core.character.EquipSet)

Example 24 with EquipSet

use of pcgen.core.character.EquipSet in project pcgen by PCGen.

the class ExportHandlerTest method testForNoMoreItems.

public void testForNoMoreItems() throws IOException {
    PlayerCharacter pc = getCharacter();
    assertEquals("Test for evaluates correctly", "SF", evaluateToken("FOR.0,100,1,\\ARMOR.SUIT.ALL.%.NAME\\,S,F,1", pc));
    // Now assign a gem
    pc.addEquipment(armor);
    EquipSet es = new EquipSet("1", "Default", "", armor);
    pc.addEquipSet(es);
    assertEquals("Test for evaluates correctly", "STestArmorSuitFSF", evaluateToken("FOR.0,100,1,\\ARMOR.SUIT.ALL.%.NAME\\,S,F,1", pc));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) EquipSet(pcgen.core.character.EquipSet)

Example 25 with EquipSet

use of pcgen.core.character.EquipSet in project pcgen by PCGen.

the class WeaponTokenTest method testWpnFinesse.

/**
	 * Test the processing of a finesseable weapon both with and without weapon finesse
	 * and temporary bonuses.
	 */
public void testWpnFinesse() {
    PlayerCharacter character = getCharacter();
    assertEquals("Prof should be longsword", "KEY_LONGSWORD", fineSword.get(ObjectKey.WEAPON_PROF).get().getKeyName());
    LoadContext context = Globals.getContext();
    character.addEquipment(fineSword);
    EquipSet es = new EquipSet("0.1.3", "Longsword (Fine)", fineSword.getName(), fineSword);
    character.addEquipSet(es);
    character.setCalcEquipmentList();
    // Test weapon profs effects on large weapons
    WeaponToken token = new WeaponToken();
    assertEquals("Fine sword", "+18/+13/+8/+3", token.getToken("WEAPON.3.BASEHIT", character, null));
    // Now apply weapon finess and check dex is used rather than str
    Ability wpnFinesse = new Ability();
    wpnFinesse.setName("Weapon Finesse");
    wpnFinesse.setCDOMCategory(AbilityCategory.FEAT);
    wpnFinesse.put(StringKey.KEY_NAME, "Weapon Finesse");
    final BonusObj wfBonus = Bonus.newBonus(context, "COMBAT|TOHIT.Finesseable|((max(STR,DEX)-STR)+SHIELDACCHECK)|TYPE=NotRanged");
    wpnFinesse.addToListFor(ListKey.BONUS, wfBonus);
    addAbility(AbilityCategory.FEAT, wpnFinesse);
    assertEquals("Fine sword", "+19/+14/+9/+4", token.getToken("WEAPON.3.BASEHIT", character, null));
    // Add a temp penalty to dex and check that it is applied
    character.setUseTempMods(true);
    Spell spell2 = new Spell();
    spell2.setName("Concrete Boots");
    final BonusObj aBonus = Bonus.newBonus(context, "STAT|DEX|-4");
    if (aBonus != null) {
        spell2.addToListFor(ListKey.BONUS, aBonus);
    }
    BonusObj penalty = spell2.getRawBonusList(character).get(0);
    character.addTempBonus(penalty, spell2, character);
    character.calcActiveBonuses();
    assertEquals("Fine sword", "+18/+13/+8/+3", token.getToken("WEAPON.3.BASEHIT", character, null));
}
Also used : Ability(pcgen.core.Ability) PlayerCharacter(pcgen.core.PlayerCharacter) BonusObj(pcgen.core.bonus.BonusObj) EquipSet(pcgen.core.character.EquipSet) LoadContext(pcgen.rules.context.LoadContext) Spell(pcgen.core.spell.Spell)

Aggregations

EquipSet (pcgen.core.character.EquipSet)79 PlayerCharacter (pcgen.core.PlayerCharacter)32 Equipment (pcgen.core.Equipment)22 ArrayList (java.util.ArrayList)12 BonusObj (pcgen.core.bonus.BonusObj)11 HashMap (java.util.HashMap)9 LoadContext (pcgen.rules.context.LoadContext)8 EquipNode (pcgen.facade.core.EquipmentSetFacade.EquipNode)7 DecimalFormat (java.text.DecimalFormat)4 NumberFormat (java.text.NumberFormat)4 List (java.util.List)4 Map (java.util.Map)4 EquipmentList (pcgen.core.EquipmentList)4 PCTemplate (pcgen.core.PCTemplate)4 EquipSlot (pcgen.core.character.EquipSlot)4 LinkedHashMap (java.util.LinkedHashMap)3 Ability (pcgen.core.Ability)3 EquipmentModifier (pcgen.core.EquipmentModifier)3 StringTokenizer (java.util.StringTokenizer)2 CNAbility (pcgen.cdom.content.CNAbility)2