Search in sources :

Example 11 with AbilityFacade

use of pcgen.facade.core.AbilityFacade in project pcgen by PCGen.

the class CharacterAbilitiesTest method testRebuildAbilityListsNoMult.

/**
	 * Test method for {@link pcgen.gui2.facade.CharacterAbilities#rebuildAbilityLists()}.
	 */
@Test
public final void testRebuildAbilityListsNoMult() {
    PlayerCharacter pc = getCharacter();
    CharacterAbilities ca = new CharacterAbilities(pc, uiDelegate, dataset, todoManager);
    ca.rebuildAbilityLists();
    ListFacade<AbilityCategoryFacade> categories = ca.getActiveAbilityCategories();
    assertNotNull("Categories should not be null", categories);
    assertTrue("Feat should be active", categories.containsElement(AbilityCategory.FEAT));
    ListFacade<AbilityFacade> abilities = ca.getAbilities(AbilityCategory.FEAT);
    assertNotNull("Feat list should not be null", abilities);
    assertTrue("Feat list should be empty", abilities.isEmpty());
    // Add an entry - note rebuild is implicit
    Ability fencing = TestHelper.makeAbility("fencing", AbilityCategory.FEAT, "sport");
    addAbility(AbilityCategory.FEAT, fencing);
    abilities = ca.getAbilities(AbilityCategory.FEAT);
    assertEquals("Feat list should have one entry", 1, abilities.getSize());
    Ability abilityFromList = (Ability) abilities.getElementAt(0);
    assertEquals("Should have found fencing", fencing, abilityFromList);
}
Also used : Ability(pcgen.core.Ability) PlayerCharacter(pcgen.core.PlayerCharacter) AbilityCategoryFacade(pcgen.facade.core.AbilityCategoryFacade) AbilityFacade(pcgen.facade.core.AbilityFacade) Test(org.junit.Test)

Example 12 with AbilityFacade

use of pcgen.facade.core.AbilityFacade in project pcgen by PCGen.

the class DataSet method getPrereqAbilities.

/* (non-Javadoc)
	 * @see pcgen.core.facade.DataSetFacade#getPrereqAbilities(pcgen.core.facade.AbilityFacade)
	 */
@Override
public List<AbilityFacade> getPrereqAbilities(AbilityFacade abilityFacade) {
    if (abilityFacade == null || !(abilityFacade instanceof Ability)) {
        return Collections.emptyList();
    }
    Ability ability = (Ability) abilityFacade;
    List<AbilityFacade> prereqList = new ArrayList<>();
    for (Prerequisite prereq : ability.getPrerequisiteList()) {
        prereqList.addAll(getAbilitiesFromPrereq(prereq, ability.getCDOMCategory()));
    }
    return prereqList;
}
Also used : AbilityFacade(pcgen.facade.core.AbilityFacade) ArrayList(java.util.ArrayList) Prerequisite(pcgen.core.prereq.Prerequisite)

Example 13 with AbilityFacade

use of pcgen.facade.core.AbilityFacade in project pcgen by PCGen.

the class EquipmentBuilderFacadeImpl method getSpellChoiceForEqMod.

private boolean getSpellChoiceForEqMod(EquipmentModifier eqMod) {
    String choiceValue = eqMod.getSafe(StringKey.CHOICE_STRING).substring(15);
    SpellBuilderFacadeImpl spellBuilderFI = new SpellBuilderFacadeImpl(choiceValue, character, equip);
    if (!delegate.showCustomSpellDialog(spellBuilderFI)) {
        return false;
    }
    InfoFacade castingClass = spellBuilderFI.getClassRef().get();
    Spell theSpell = (Spell) spellBuilderFI.getSpellRef().get();
    String variant = spellBuilderFI.getVariantRef().get();
    if (variant == null) {
        variant = "";
    }
    String spellType = spellBuilderFI.getSpellTypeRef().get();
    int baseSpellLevel = spellBuilderFI.getSpellLevelRef().get();
    int casterLevel = spellBuilderFI.getCasterLevelRef().get();
    ListFacade<AbilityFacade> metamagicFeatsList = spellBuilderFI.getSelectedMetamagicFeats();
    Object[] metamagicFeats = new Object[metamagicFeatsList.getSize()];
    for (int i = 0; i < metamagicFeats.length; i++) {
        metamagicFeats[i] = metamagicFeatsList.getElementAt(i);
    }
    int charges = getNumCharges(eqMod);
    EquipmentModifier existingEqMod = equip.getEqModifierKeyed(eqMod.getKeyName(), true);
    if (existingEqMod == null) {
        equip.addEqModifier(eqMod, true, character);
    }
    existingEqMod = equip.getEqModifierKeyed(eqMod.getKeyName(), true);
    EqModSpellInfo.setSpellInfo(equip, existingEqMod, (PObject) castingClass, theSpell, variant, spellType, baseSpellLevel, casterLevel, metamagicFeats, charges);
    return true;
}
Also used : EquipmentModifier(pcgen.core.EquipmentModifier) InfoFacade(pcgen.facade.core.InfoFacade) AbilityFacade(pcgen.facade.core.AbilityFacade) PObject(pcgen.core.PObject) Spell(pcgen.core.spell.Spell)

Aggregations

AbilityFacade (pcgen.facade.core.AbilityFacade)13 AbilityCategoryFacade (pcgen.facade.core.AbilityCategoryFacade)6 Ability (pcgen.core.Ability)4 ArrayList (java.util.ArrayList)3 CNAbility (pcgen.cdom.content.CNAbility)3 Test (org.junit.Test)2 PObject (pcgen.core.PObject)2 PlayerCharacter (pcgen.core.PlayerCharacter)2 Prerequisite (pcgen.core.prereq.Prerequisite)2 InfoFacade (pcgen.facade.core.InfoFacade)2 DefaultListFacade (pcgen.facade.util.DefaultListFacade)2 BorderLayout (java.awt.BorderLayout)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 Box (javax.swing.Box)1 JPanel (javax.swing.JPanel)1 JScrollPane (javax.swing.JScrollPane)1 EmptyBorder (javax.swing.border.EmptyBorder)1 Type (pcgen.cdom.enumeration.Type)1