use of pcgen.core.Ability in project pcgen by PCGen.
the class AbilityTokenTest method testRoundRobinType.
@Test
public void testRoundRobinType() throws PersistenceLayerException {
Ability ab = primaryContext.getReferenceContext().constructCDOMObject(Ability.class, "Fireball");
primaryContext.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, ab);
ab.addToListFor(ListKey.TYPE, Type.getConstant("Test"));
ab = secondaryContext.getReferenceContext().constructCDOMObject(Ability.class, "Fireball");
secondaryContext.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, ab);
ab.addToListFor(ListKey.TYPE, Type.getConstant("Test"));
runRoundRobin("CATEGORY=FEAT|TYPE=Test");
}
use of pcgen.core.Ability in project pcgen by PCGen.
the class PCQualifierTokenTest method construct.
@Override
protected CDOMObject construct(LoadContext loadContext, String one) {
Ability a = (Ability) super.construct(loadContext, one);
loadContext.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, a);
return a;
}
use of pcgen.core.Ability in project pcgen by PCGen.
the class AbilityToken method removeChoice.
@Override
public void removeChoice(PlayerCharacter pc, CDOMObject owner, CNAbilitySelection choice) {
CNAbility cna = choice.getCNAbility();
Ability ab = cna.getAbility();
AbilityCategory cat = (AbilityCategory) cna.getAbilityCategory();
if (cna.getNature().equals(Nature.NORMAL)) {
pc.adjustAbilities(cat, ab.getSafe(ObjectKey.SELECTION_COST).negate());
pc.removeAbility(choice, UserSelection.getInstance(), UserSelection.getInstance());
} else {
pc.removeSavedAbility(choice, UserSelection.getInstance(), UserSelection.getInstance());
}
}
use of pcgen.core.Ability in project pcgen by PCGen.
the class AbilityToken method applyChoice.
@Override
public void applyChoice(CDOMObject owner, CNAbilitySelection choice, PlayerCharacter pc) {
CNAbility cna = choice.getCNAbility();
Ability ab = cna.getAbility();
AbilityCategory cat = (AbilityCategory) cna.getAbilityCategory();
boolean isVirtual = Nature.VIRTUAL.equals(cna.getNature());
if (isVirtual) {
pc.addSavedAbility(choice, UserSelection.getInstance(), UserSelection.getInstance());
} else {
pc.addAbility(choice, UserSelection.getInstance(), UserSelection.getInstance());
pc.adjustAbilities(cat, ab.getSafe(ObjectKey.SELECTION_COST));
}
}
use of pcgen.core.Ability in project pcgen by PCGen.
the class AbilityToken method allow.
@Override
public boolean allow(CNAbilitySelection choice, PlayerCharacter pc, boolean allowStack) {
CNAbility cna = choice.getCNAbility();
Ability ability = cna.getAbility();
if (!ability.getSafe(ObjectKey.VISIBILITY).equals(Visibility.DEFAULT)) {
return false;
}
boolean isVirtual = Nature.VIRTUAL.equals(cna.getNature());
if (!isVirtual && !ability.qualifies(pc, ability)) {
return false;
}
String selection = choice.getSelection();
// Avoid any already selected
return !AbilityUtilities.alreadySelected(pc, ability, selection, allowStack);
}
Aggregations