Search in sources :

Example 61 with BonusObj

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

the class ACTokenTest method setUp.

/*
	 * @see TestCase#setUp()
	 */
@Override
protected void setUp() throws Exception {
    super.setUp();
    LoadContext context = Globals.getContext();
    PlayerCharacter character = getCharacter();
    setPCStat(character, dex, 14);
    dex.removeListFor(ListKey.BONUS);
    BonusObj aBonus = Bonus.newBonus(context, "COMBAT|AC|10|TYPE=Base");
    if (aBonus != null) {
        dex.addToListFor(ListKey.BONUS, aBonus);
    }
    // Ignoring max dex
    aBonus = Bonus.newBonus(context, "COMBAT|AC|DEX|TYPE=Ability");
    if (aBonus != null) {
        dex.addToListFor(ListKey.BONUS, aBonus);
    }
    EquipSet def = new EquipSet("0.1", "Default");
    character.addEquipSet(def);
    character.setCalcEquipmentList();
    character.calcActiveBonuses();
    // Create non magic armor
    chainShirt = new Equipment();
    chainShirt.setName("Chain Shirt");
    chainShirt.put(StringKey.KEY_NAME, "KEY_Chain_Shirt");
    TestHelper.addType(chainShirt, "Armor.Light.Suit.Standard");
    chainShirt.put(IntegerKey.AC_CHECK, -2);
    aBonus = Bonus.newBonus(context, "COMBAT|AC|4|TYPE=Armor.REPLACE");
    if (aBonus != null) {
        chainShirt.addToListFor(ListKey.BONUS, aBonus);
    }
    // Create magic armor enhancement
    masterwork = new EquipmentModifier();
    masterwork.setName("Masterwork");
    masterwork.put(StringKey.KEY_NAME, "MWORKA");
    TestHelper.addType(masterwork, "Armor.Shield");
    masterwork.addToListFor(ListKey.ITEM_TYPES, "Masterwork");
    aBonus = Bonus.newBonus(context, "EQMARMOR|ACCHECK|1|TYPE=Enhancement");
    if (aBonus != null) {
        masterwork.addToListFor(ListKey.BONUS, aBonus);
    }
    context.getReferenceContext().importObject(masterwork);
    plus1 = new EquipmentModifier();
    plus1.setName("Plus 1 Enhancement");
    plus1.put(StringKey.KEY_NAME, "PLUS1A");
    TestHelper.addType(plus1, "Armor.Shield");
    plus1.put(IntegerKey.PLUS, 1);
    plus1.addToListFor(ListKey.ITEM_TYPES, "Enhancement");
    plus1.addToListFor(ListKey.ITEM_TYPES, "Magic");
    plus1.addToListFor(ListKey.ITEM_TYPES, "Plus1");
    aBonus = Bonus.newBonus(context, "COMBAT|AC|1|TYPE=Armor.REPLACE");
    if (aBonus != null) {
        plus1.addToListFor(ListKey.BONUS, aBonus);
    }
    Globals.getContext().getReferenceContext().importObject(plus1);
    // Load AC definitions - but only once
    final GameMode gamemode = SettingsHandler.getGame();
    if (!gamemode.isValidACType("Total")) {
        gamemode.addACAdds("Total", Collections.singletonList(new ACControl("TOTAL")));
        gamemode.addACAdds("Armor", Collections.singletonList(new ACControl("Armor")));
        gamemode.addACAdds("Ability", Collections.singletonList(new ACControl("Ability")));
    }
}
Also used : GameMode(pcgen.core.GameMode) EquipmentModifier(pcgen.core.EquipmentModifier) PlayerCharacter(pcgen.core.PlayerCharacter) BonusObj(pcgen.core.bonus.BonusObj) Equipment(pcgen.core.Equipment) ACControl(pcgen.cdom.content.ACControl) EquipSet(pcgen.core.character.EquipSet) LoadContext(pcgen.rules.context.LoadContext)

Example 62 with BonusObj

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

the class TokenLibrary method addBonusClass.

/**
	 * Add a CLASS via a BONUS
	 * 
	 * @return true if successful
	 */
public static boolean addBonusClass(Class bonusClass) throws InstantiationException, IllegalAccessException {
    if (BonusObj.class.isAssignableFrom(bonusClass)) {
        final BonusObj bonusObj = (BonusObj) bonusClass.newInstance();
        BONUS_TAG_MAP.put(bonusObj.getBonusHandled(), bonusClass);
        return true;
    }
    return false;
}
Also used : BonusObj(pcgen.core.bonus.BonusObj)

Example 63 with BonusObj

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

the class SkillCostDisplayTest method setUp.

/**
	 * @see pcgen.AbstractCharacterTestCase#setUp()
	 */
@Override
protected void setUp() throws Exception {
    super.setUp();
    LoadContext context = Globals.getContext();
    if (firstTime) {
        firstTime = false;
        pcClass = new PCClass();
        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(context, "SKILL|LIST|3");
        if (aBonus != null) {
            skillFocus.addToListFor(ListKey.BONUS, aBonus);
        }
        skillFocus.put(ObjectKey.MULTIPLE_ALLOWED, true);
        Globals.getContext().unconditionallyProcess(skillFocus, "CHOOSE", "SKILL|TYPE.Strength|TYPE.Dexterity|TYPE.Constitution|TYPE.Intelligence|TYPE.Wisdom|TYPE.Charisma");
        persuasive = TestHelper.makeAbility("Persuasive", AbilityCategory.FEAT, "General");
        aBonus = Bonus.newBonus(context, "SKILL|KEY_Bluff,KEY_Listen|2");
        if (aBonus != null) {
            persuasive.addToListFor(ListKey.BONUS, aBonus);
        }
        persuasive.put(ObjectKey.MULTIPLE_ALLOWED, false);
    }
    final PlayerCharacter character = getCharacter();
    character.incrementClassLevel(1, pcClass);
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) BonusObj(pcgen.core.bonus.BonusObj) LoadContext(pcgen.rules.context.LoadContext) PCClass(pcgen.core.PCClass)

Example 64 with BonusObj

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

the class PlayerCharacterTest method setUp.

//	/**
//	 * @return Test
//	 */
//	public static Test suite()
//	{
//		return new TestSuite(PlayerCharacterTest.class);
//	}
/**
	 * @see junit.framework.TestCase#setUp()
	 */
@Override
protected void setUp() throws Exception {
    super.setUp();
    LoadContext context = Globals.getContext();
    // Giant Class
    giantClass = new PCClass();
    giantClass.setName("Giant");
    BuildUtilities.setFact(giantClass, "ClassType", "Monster");
    final BonusObj babClassBonus = Bonus.newBonus(context, "COMBAT|BASEAB|CL*3/4");
    giantClass.getOriginalClassLevel(1).addToListFor(ListKey.BONUS, babClassBonus);
    context.getReferenceContext().importObject(giantClass);
    // Human
    human = new Race();
    final BonusObj humanRaceFeatBonus = Bonus.newBonus(context, "FEAT|POOL|2");
    human.addToListFor(ListKey.BONUS, humanRaceFeatBonus);
    human.ownBonuses(human);
    // Giant Race
    giantRace = new Race();
    giantRace.setName("Ogre");
    giantRace.put(ObjectKey.MONSTER_CLASS, new LevelCommandFactory(CDOMDirectSingleRef.getRef(giantClass), FormulaFactory.getFormulaFor(4)));
    giantRace.addToListFor(ListKey.HITDICE_ADVANCEMENT, 100);
    final BonusObj giantRaceFeatBonus = Bonus.newBonus(context, "FEAT|POOL|1");
    giantRace.addToListFor(ListKey.BONUS, giantRaceFeatBonus);
    giantRace.ownBonuses(giantRace);
    context.getReferenceContext().importObject(giantRace);
    // Create the monster class type
    SettingsHandler.getGame().addClassType("Monster		CRFORMULA:0			ISMONSTER:YES	XPPENALTY:NO");
    pcClass = new PCClass();
    pcClass.setName("MyClass");
    BuildUtilities.setFact(pcClass, "SpellType", "Arcane");
    context.getReferenceContext().importObject(pcClass);
    classMemDivine = new PCClass();
    classMemDivine.setName("MemDivine");
    BuildUtilities.setFact(classMemDivine, "SpellType", "Divine");
    classMemDivine.put(ObjectKey.MEMORIZE_SPELLS, true);
    context.unconditionallyProcess(classMemDivine, "SPELLSTAT", "WIS");
    context.unconditionallyProcess(classMemDivine.getOriginalClassLevel(1), "CAST", "3,2,2");
    context.unconditionallyProcess(classMemDivine, "BONUS", "DOMAIN|NUMBER|1");
    context.getReferenceContext().importObject(classMemDivine);
    classWarmind = new PCClass();
    classWarmind.setName("Warmind");
    context.getReferenceContext().importObject(classWarmind);
    class2LpfM = new PCClass();
    class2LpfM.setName("2LpfM");
    BuildUtilities.setFact(class2LpfM, "ClassType", "Monster");
    class2LpfM.put(IntegerKey.LEVELS_PER_FEAT, 2);
    class2LpfM.put(StringKey.LEVEL_TYPE, "MONSTER");
    context.getReferenceContext().importObject(class2LpfM);
    class3LpfM = new PCClass();
    class3LpfM.setName("3LpfM");
    BuildUtilities.setFact(class3LpfM, "ClassType", "Monster");
    class3LpfM.put(IntegerKey.LEVELS_PER_FEAT, 3);
    class3LpfM.put(StringKey.LEVEL_TYPE, "MONSTER");
    context.getReferenceContext().importObject(class3LpfM);
    class3LpfBlank = new PCClass();
    class3LpfBlank.setName("3LpfBlank");
    BuildUtilities.setFact(class3LpfBlank, "ClassType", "Foo");
    class3LpfBlank.put(IntegerKey.LEVELS_PER_FEAT, 3);
    context.getReferenceContext().importObject(class3LpfBlank);
    toughness = new Ability();
    toughness.setName("Toughness");
    toughness.put(ObjectKey.MULTIPLE_ALLOWED, Boolean.TRUE);
    toughness.put(ObjectKey.STACKS, Boolean.TRUE);
    context.unconditionallyProcess(toughness, "CHOOSE", "NOCHOICE");
    toughness.setCDOMCategory(AbilityCategory.FEAT);
    final BonusObj aBonus = Bonus.newBonus(context, "HP|CURRENTMAX|3");
    if (aBonus != null) {
        toughness.addToListFor(ListKey.BONUS, aBonus);
    }
    context.getReferenceContext().importObject(toughness);
    Ability exoticWpnProf = TestHelper.makeAbility("Exotic Weapon Proficiency", AbilityCategory.FEAT, "General.Fighter");
    exoticWpnProf.put(ObjectKey.MULTIPLE_ALLOWED, Boolean.TRUE);
    context.unconditionallyProcess(exoticWpnProf, "CHOOSE", "WEAPONPROFICIENCY|!PC[TYPE.Exotic]");
    context.unconditionallyProcess(exoticWpnProf, "AUTO", "WEAPONPROF|%LIST");
    WeaponProf wpnProfTestA = new WeaponProf();
    wpnProfTestA.setName("Weapon A");
    wpnProfTestA.put(StringKey.KEY_NAME, "Weapon A");
    wpnProfTestA.addToListFor(ListKey.TYPE, Type.getConstant("Exotic"));
    context.getReferenceContext().importObject(wpnProfTestA);
    WeaponProf wpnProfTestB = new WeaponProf();
    wpnProfTestB.setName("Weapon B");
    wpnProfTestB.put(StringKey.KEY_NAME, "Weapon B");
    wpnProfTestB.addToListFor(ListKey.TYPE, Type.getConstant("Exotic"));
    context.getReferenceContext().importObject(wpnProfTestB);
    WeaponProf wpnProfTestC = new WeaponProf();
    wpnProfTestC.setName("Weapon C");
    wpnProfTestC.put(StringKey.KEY_NAME, "Weapon C");
    wpnProfTestC.addToListFor(ListKey.TYPE, Type.getConstant("Exotic"));
    context.getReferenceContext().importObject(wpnProfTestC);
    UIPropertyContext.setSingleChoiceAction(Constants.CHOOSER_SINGLE_CHOICE_METHOD_SELECT_EXIT);
    ChooserFactory.pushChooserClassname(RandomChooser.class.getName());
    context.unconditionallyProcess(pcClass.getOriginalClassLevel(1), "ADD", "FEAT|KEY_Exotic Weapon Proficiency (Weapon B)");
    context.unconditionallyProcess(pcClass.getOriginalClassLevel(2), "ADD", "FEAT|KEY_Exotic Weapon Proficiency (Weapon A)");
    context.unconditionallyProcess(pcClass.getOriginalClassLevel(3), "ADD", "FEAT|KEY_Exotic Weapon Proficiency (Weapon C)");
    specialFeatCat = Globals.getContext().getReferenceContext().constructNowIfNecessary(AbilityCategory.class, "Special Feat");
    specialFeatCat.setAbilityCategory(CDOMDirectSingleRef.getRef(AbilityCategory.FEAT));
    specialAbilityCat = Globals.getContext().getReferenceContext().constructNowIfNecessary(AbilityCategory.class, "Special Ability");
    luckDomain = TestHelper.makeDomain("Luck");
    context.getReferenceContext().buildDerivedObjects();
    luckDomainLvl1Spell = TestHelper.makeSpell("true strike");
    luckDomainLvl2Spell = TestHelper.makeSpell("aid");
    TestHelper.makeSpell("protection from energy");
    context.unconditionallyProcess(luckDomain, "SPELLLEVEL", "DOMAIN|Luck=1|KEY_True Strike|Luck=2|KEY_Aid|Luck=3|KEY_Protection from Energy");
}
Also used : LevelCommandFactory(pcgen.cdom.content.LevelCommandFactory) BonusObj(pcgen.core.bonus.BonusObj) LoadContext(pcgen.rules.context.LoadContext) RandomChooser(pcgen.util.chooser.RandomChooser)

Example 65 with BonusObj

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

the class StatListTest method setUp.

/**
	 * @see pcgen.AbstractCharacterTestCase#setUp()
	 */
@Override
protected void setUp() throws Exception {
    super.setUp();
    PlayerCharacter pc = getCharacter();
    LoadContext context = Globals.getContext();
    locker = new PCTemplate();
    locker.setName("locker");
    CDOMDirectSingleRef<PCStat> strRef = CDOMDirectSingleRef.getRef(str);
    locker.addToListFor(ListKey.STAT_LOCKS, new StatLock(strRef, FormulaFactory.getFormulaFor(12)));
    unlocker = new PCTemplate();
    unlocker.setName("unlocker");
    unlocker.addToListFor(ListKey.UNLOCKED_STATS, strRef);
    bonus = TestHelper.makeAbility("Bonus", AbilityCategory.FEAT, "General.Fighter");
    BonusObj aBonus = Bonus.newBonus(context, "STAT|STR|7|TYPE=Enhancement");
    if (aBonus != null) {
        bonus.addToListFor(ListKey.BONUS, aBonus);
    }
    lockedBonus = TestHelper.makeAbility("LockedBonus", AbilityCategory.FEAT, "General.Fighter");
    aBonus = Bonus.newBonus(context, "LOCKEDSTAT|STR|3|TYPE=Morale");
    if (aBonus != null) {
        lockedBonus.addToListFor(ListKey.BONUS, aBonus);
    }
    setPCStat(pc, str, 6);
}
Also used : BonusObj(pcgen.core.bonus.BonusObj) LoadContext(pcgen.rules.context.LoadContext) StatLock(pcgen.cdom.helper.StatLock)

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