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);
}
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;
}
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()));
}
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());
}
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());
}
Aggregations