Search in sources :

Example 6 with PCCheck

use of pcgen.core.PCCheck in project pcgen by PCGen.

the class PreCheckBaseTester method passes.

/**
	 * @see pcgen.core.prereq.PrerequisiteTest#passes(pcgen.core.prereq.Prerequisite, pcgen.core.PlayerCharacter)
	 */
@Override
public int passes(final Prerequisite prereq, final PlayerCharacter character, CDOMObject source) {
    int runningTotal = 0;
    final String checkName = prereq.getKey();
    final int operand = //$NON-NLS-1$
    character.getVariableValue(prereq.getOperand(), "").intValue();
    PCCheck check = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(PCCheck.class, checkName);
    if (check != null) {
        final int characterCheckBonus = character.getBaseCheck(check);
        runningTotal = prereq.getOperator().compare(characterCheckBonus, operand) > 0 ? 1 : 0;
    }
    return countedTotal(prereq, runningTotal);
}
Also used : PCCheck(pcgen.core.PCCheck)

Example 7 with PCCheck

use of pcgen.core.PCCheck in project pcgen by PCGen.

the class CheckFacetTest method getObject.

@Override
protected PCCheck getObject() {
    PCCheck t = new PCCheck();
    t.setName("PCCheck" + n++);
    return t;
}
Also used : PCCheck(pcgen.core.PCCheck)

Example 8 with PCCheck

use of pcgen.core.PCCheck in project pcgen by PCGen.

the class SavingThrowDialog method setDefaults.

/**
	 * <p>
	 * Sets all field defaults based on the combatant, dc, save type, etc.
	 * </p>
	 * @param saveType
	 */
private void setDefaults(int saveType) {
    int base = 0;
    int ability = 0;
    int magic = 0;
    int misc = 0;
    if (cbt instanceof PcgCombatant) {
        PcgCombatant pcgcbt = (PcgCombatant) cbt;
        PlayerCharacter pc = pcgcbt.getPC();
        new PlayerCharacterOutput(pc);
        List<PCCheck> checkList = Globals.getContext().getReferenceContext().getOrderSortedCDOMObjects(PCCheck.class);
        if (saveType == FORT_SAVE) {
            PCCheck fort = checkList.get(0);
            base = pc.calculateSaveBonus(fort, "BASE");
            ability = pc.calculateSaveBonus(fort, "STATMOD");
            magic = pc.calculateSaveBonus(fort, "MAGIC");
            misc = pc.calculateSaveBonus(fort, "MISC.NOMAGIC.NOSTAT");
        } else if (saveType == REF_SAVE) {
            PCCheck ref = checkList.get(1);
            base = pc.calculateSaveBonus(ref, "BASE");
            ability = pc.calculateSaveBonus(ref, "STATMOD");
            magic = pc.calculateSaveBonus(ref, "MAGIC");
            misc = pc.calculateSaveBonus(ref, "MISC.NOMAGIC.NOSTAT");
        } else if (saveType == WILL_SAVE) {
            PCCheck will = checkList.get(2);
            base = pc.calculateSaveBonus(will, "BASE");
            ability = pc.calculateSaveBonus(will, "STATMOD");
            magic = pc.calculateSaveBonus(will, "MAGIC");
            misc = pc.calculateSaveBonus(will, "MISC.NOMAGIC.NOSTAT");
        }
    } else if (cbt instanceof XMLCombatant) {
        XMLCombatant xmlcbt = (XMLCombatant) cbt;
        if (saveType == FORT_SAVE) {
            int mod = new SystemAttribute("Constitution", xmlcbt.getAttribute("Constitution")).getModifier();
            ability = mod;
            base = xmlcbt.getSave("Fortitude") - mod;
        } else if (saveType == REF_SAVE) {
            int mod = new SystemAttribute("Dexterity", xmlcbt.getAttribute("Dexterity")).getModifier();
            ability = mod;
            base = xmlcbt.getSave("Reflex") - mod;
        } else if (saveType == WILL_SAVE) {
            int mod = new SystemAttribute("Wisdom", xmlcbt.getAttribute("Wisdom")).getModifier();
            ability = mod;
            base = xmlcbt.getSave("Will") - mod;
        }
        magic = parseInt(saveMagic.getText());
        misc = parseInt(saveMisc.getText());
    }
    setDefaults(base, ability, magic, misc, parseInt(saveTemp.getText()));
}
Also used : SystemAttribute(gmgen.plugin.SystemAttribute) PlayerCharacterOutput(gmgen.plugin.PlayerCharacterOutput) PcgCombatant(gmgen.plugin.PcgCombatant) PlayerCharacter(pcgen.core.PlayerCharacter) PCCheck(pcgen.core.PCCheck) XMLCombatant(plugin.initiative.XMLCombatant)

Example 9 with PCCheck

use of pcgen.core.PCCheck in project pcgen by PCGen.

the class GlobalQualifyTest method testFromCheck.

@Override
@Test
public void testFromCheck() throws PersistenceLayerException {
    PCCheck source = create(PCCheck.class, "Source");
    ParseResult result = token.parseToken(context, source, "RACE|Dwarf");
    assertFalse(result.passed());
}
Also used : ParseResult(pcgen.rules.persistence.token.ParseResult) PCCheck(pcgen.core.PCCheck) Test(org.junit.Test) AbstractContentTokenTest(tokencontent.testsupport.AbstractContentTokenTest)

Example 10 with PCCheck

use of pcgen.core.PCCheck in project pcgen by PCGen.

the class AbstractContentTokenTest method testFromCheck.

@Test
public void testFromCheck() throws PersistenceLayerException {
    PCCheck source = create(PCCheck.class, "Source");
    processToken(source);
    assertTrue(containsExpected());
    assertEquals(baseCount() + 1, targetFacetCount());
    checkFacet.remove(id, source);
    assertEquals(baseCount(), targetFacetCount());
}
Also used : PCCheck(pcgen.core.PCCheck) Test(org.junit.Test) AbstractTokenModelTest(tokenmodel.testsupport.AbstractTokenModelTest)

Aggregations

PCCheck (pcgen.core.PCCheck)11 Test (org.junit.Test)3 BonusObj (pcgen.core.bonus.BonusObj)3 LoadContext (pcgen.rules.context.LoadContext)2 PcgCombatant (gmgen.plugin.PcgCombatant)1 PlayerCharacterOutput (gmgen.plugin.PlayerCharacterOutput)1 SystemAttribute (gmgen.plugin.SystemAttribute)1 StringManager (pcgen.base.format.StringManager)1 PlayerCharacter (pcgen.core.PlayerCharacter)1 FactKeyActor (pcgen.output.actor.FactKeyActor)1 ParseResult (pcgen.rules.persistence.token.ParseResult)1 XMLCombatant (plugin.initiative.XMLCombatant)1 AbstractContentTokenTest (tokencontent.testsupport.AbstractContentTokenTest)1 AbstractTokenModelTest (tokenmodel.testsupport.AbstractTokenModelTest)1