Search in sources :

Example 1 with BonusCheckingFacet

use of pcgen.cdom.facet.BonusCheckingFacet in project pcgen by PCGen.

the class ReachFacetTest method getMockFacet.

public ReachFacet getMockFacet() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
    ReachFacet f = new ReachFacet();
    Field field = ReachFacet.class.getDeclaredField("bonusCheckingFacet");
    field.setAccessible(true);
    BonusCheckingFacet fakeFacet = new BonusCheckingFacet() {

        @Override
        public double getBonus(CharID cid, String bonusType, String bonusName) {
            if ("COMBAT".equals(bonusType) && "REACH".equals(bonusName)) {
                Double d = bonusInfo.get(cid);
                return d == null ? 0 : d;
            }
            return 0;
        }
    };
    field.set(f, fakeFacet);
    return f;
}
Also used : Field(java.lang.reflect.Field) BonusCheckingFacet(pcgen.cdom.facet.BonusCheckingFacet) CharID(pcgen.cdom.enumeration.CharID)

Example 2 with BonusCheckingFacet

use of pcgen.cdom.facet.BonusCheckingFacet in project pcgen by PCGen.

the class SizeFacetTest method getMockFacet.

public SizeFacet getMockFacet() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
    SizeFacet f = new SizeFacet();
    Field field = SizeFacet.class.getDeclaredField("bonusCheckingFacet");
    field.setAccessible(true);
    BonusCheckingFacet fakeFacet = new BonusCheckingFacet() {

        @Override
        public double getBonus(CharID cid, String bonusType, String bonusName) {
            if ("SIZEMOD".equals(bonusType) && "NUMBER".equals(bonusName)) {
                Double d = bonusInfo.get(cid);
                return d == null ? 0 : d;
            }
            return 0;
        }
    };
    field.set(f, fakeFacet);
    field = SizeFacet.class.getDeclaredField("levelFacet");
    field.setAccessible(true);
    LevelFacet fakeLevelFacet = new LevelFacet() {

        @Override
        public int getMonsterLevelCount(CharID cid) {
            return fakeLevels;
        }
    };
    field.set(f, fakeLevelFacet);
    return f;
}
Also used : Field(java.lang.reflect.Field) BonusCheckingFacet(pcgen.cdom.facet.BonusCheckingFacet) LevelFacet(pcgen.cdom.facet.analysis.LevelFacet) CharID(pcgen.cdom.enumeration.CharID)

Example 3 with BonusCheckingFacet

use of pcgen.cdom.facet.BonusCheckingFacet in project pcgen by PCGen.

the class InitiativeFacetTest method getMockFacet.

public InitiativeFacet getMockFacet() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
    InitiativeFacet f = new InitiativeFacet();
    Field field = InitiativeFacet.class.getDeclaredField("bonusCheckingFacet");
    field.setAccessible(true);
    BonusCheckingFacet fakeFacet = new BonusCheckingFacet() {

        @Override
        public double getBonus(CharID cid, String bonusType, String bonusName) {
            if ("COMBAT".equals(bonusType) && "Initiative".equals(bonusName)) {
                Double d = bonusInfo.get(cid);
                return d == null ? 0 : d;
            }
            return 0;
        }
    };
    field.set(f, fakeFacet);
    Field field2 = InitiativeFacet.class.getDeclaredField("initcomp");
    field2.setAccessible(true);
    field2.set(f, FormulaFactory.getFormulaFor("2"));
    return f;
}
Also used : Field(java.lang.reflect.Field) BonusCheckingFacet(pcgen.cdom.facet.BonusCheckingFacet) CharID(pcgen.cdom.enumeration.CharID)

Aggregations

Field (java.lang.reflect.Field)3 CharID (pcgen.cdom.enumeration.CharID)3 BonusCheckingFacet (pcgen.cdom.facet.BonusCheckingFacet)3 LevelFacet (pcgen.cdom.facet.analysis.LevelFacet)1