Search in sources :

Example 41 with BonusObj

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

Example 42 with BonusObj

use of pcgen.core.bonus.BonusObj 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 43 with BonusObj

use of pcgen.core.bonus.BonusObj 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);
}
Also used : GameMode(pcgen.core.GameMode) Skill(pcgen.core.Skill) PlayerCharacter(pcgen.core.PlayerCharacter) BonusObj(pcgen.core.bonus.BonusObj) Equipment(pcgen.core.Equipment) LevelInfo(pcgen.core.LevelInfo) Race(pcgen.core.Race) LoadContext(pcgen.rules.context.LoadContext) PCClass(pcgen.core.PCClass) PCStat(pcgen.core.PCStat)

Example 44 with BonusObj

use of pcgen.core.bonus.BonusObj 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)

Example 45 with BonusObj

use of pcgen.core.bonus.BonusObj in project pcgen by PCGen.

the class AbilityTokenTest method setUp.

/*
	 * @see TestCase#setUp()
	 */
@Override
protected void setUp() throws Exception {
    super.setUp();
    PlayerCharacter character = getCharacter();
    // Make some ability categories and add them to the game mode
    Ability ab1 = TestHelper.makeAbility("Perform (Dance)", AbilityCategory.FEAT, "General.Fighter");
    ab1.put(ObjectKey.MULTIPLE_ALLOWED, Boolean.FALSE);
    ab1.put(ObjectKey.VISIBILITY, Visibility.DEFAULT);
    List<Aspect> colourList = new ArrayList<>();
    colourList.add(new Aspect("Colour", "Green"));
    ab1.addToMapFor(MapKey.ASPECT, AspectName.getConstant("Colour"), colourList);
    List<Aspect> sizeList = new ArrayList<>();
    sizeList.add(new Aspect("Size", "L"));
    ab1.addToMapFor(MapKey.ASPECT, AspectName.getConstant("Size"), sizeList);
    List<Aspect> shapeList = new ArrayList<>();
    Aspect cube = new Aspect("Shape", "Cube");
    Prerequisite prereq = new Prerequisite();
    prereq.setKind("ALIGN");
    prereq.setKey("LG");
    prereq.setOperator(PrerequisiteOperator.EQ);
    cube.addPrerequisite(prereq);
    shapeList.add(cube);
    shapeList.add(new Aspect("Shape", "Icosahedron"));
    ab1.addToMapFor(MapKey.ASPECT, AspectName.getConstant("Shape"), shapeList);
    List<Aspect> sidesList = new ArrayList<>();
    sidesList.add(new Aspect("Sides", "20"));
    ab1.addToMapFor(MapKey.ASPECT, AspectName.getConstant("Sides"), sidesList);
    List<Aspect> ageList = new ArrayList<>();
    ageList.add(new Aspect("Age In Years", "2000"));
    ab1.addToMapFor(MapKey.ASPECT, AspectName.getConstant("Age In Years"), ageList);
    addAbility(AbilityCategory.FEAT, ab1);
    TestHelper.makeSkill("Bluff", "Charisma", cha, true, SkillArmorCheck.NONE);
    TestHelper.makeSkill("Listen", "Wisdom", wis, true, SkillArmorCheck.NONE);
    skillFocus = TestHelper.makeAbility("Skill Focus", AbilityCategory.FEAT, "General");
    BonusObj aBonus = Bonus.newBonus(Globals.getContext(), "SKILL|LIST|3");
    if (aBonus != null) {
        skillFocus.addToListFor(ListKey.BONUS, aBonus);
    }
    skillFocus.put(ObjectKey.MULTIPLE_ALLOWED, true);
    Globals.getContext().unconditionallyProcess(skillFocus, "CHOOSE", "SKILL|ALL");
    AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, skillFocus, "KEY_Bluff");
    AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, skillFocus, "KEY_Listen");
    character.calcActiveBonuses();
}
Also used : Ability(pcgen.core.Ability) PlayerCharacter(pcgen.core.PlayerCharacter) BonusObj(pcgen.core.bonus.BonusObj) ArrayList(java.util.ArrayList) Aspect(pcgen.cdom.helper.Aspect) Prerequisite(pcgen.core.prereq.Prerequisite)

Aggregations

BonusObj (pcgen.core.bonus.BonusObj)126 LoadContext (pcgen.rules.context.LoadContext)48 PlayerCharacter (pcgen.core.PlayerCharacter)29 ArrayList (java.util.ArrayList)22 CDOMObject (pcgen.cdom.base.CDOMObject)18 PCClass (pcgen.core.PCClass)14 Prerequisite (pcgen.core.prereq.Prerequisite)13 PreParserFactory (pcgen.persistence.lst.prereq.PreParserFactory)13 EquipSet (pcgen.core.character.EquipSet)11 IdentityHashMap (java.util.IdentityHashMap)10 Map (java.util.Map)10 TreeSet (java.util.TreeSet)10 Ability (pcgen.core.Ability)10 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)8 TempBonusInfo (pcgen.core.BonusManager.TempBonusInfo)8 Equipment (pcgen.core.Equipment)8 HashMap (java.util.HashMap)7 Race (pcgen.core.Race)7 StringTokenizer (java.util.StringTokenizer)6 CNAbility (pcgen.cdom.content.CNAbility)6