Search in sources :

Example 6 with InfoFacade

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

the class SpellBuilderFacadeImpl method processLevelChange.

/**
	 * Update lists that depend on the selected level of spell 
	 * e.g. the list of spells  
	 */
private void processLevelChange() {
    int baseSpellLevel = spellLevel.get();
    // List of available spells
    List<Spell> spellsOfLevel = new ArrayList<>();
    for (AvailableSpell availSpell : classSpells) {
        if (availSpell.getLevel() == baseSpellLevel) {
            spellsOfLevel.add(availSpell.getSpell());
        }
    }
    Globals.sortPObjectListByName(spellsOfLevel);
    availSpells.setContents(spellsOfLevel);
    InfoFacade selSpell = spell.get();
    if (selSpell == null || !spellsOfLevel.contains(selSpell)) {
        Spell newSpell = null;
        if (!spellsOfLevel.isEmpty()) {
            newSpell = spellsOfLevel.get(0);
        }
        selectSpell(newSpell);
    }
    // Spell type
    List<String> spellTypeList = getSpellTypeList();
    availSpellTypes.setContents(spellTypeList);
    spellType.set(spellTypeList.get(0));
}
Also used : AvailableSpell(pcgen.cdom.helper.AvailableSpell) InfoFacade(pcgen.facade.core.InfoFacade) ArrayList(java.util.ArrayList) AvailableSpell(pcgen.cdom.helper.AvailableSpell) Spell(pcgen.core.spell.Spell)

Example 7 with InfoFacade

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

the class SpellBuilderFacadeImpl method recalcCasterLevelDetails.

private void recalcCasterLevelDetails() {
    // Metamagic
    int levelAdjust = 0;
    for (AbilityFacade feat : selMetamagicFeats) {
        levelAdjust += ((Ability) feat).getSafe(IntegerKey.ADD_SPELL_LEVEL);
    }
    // Limit Caster level
    int minClassLevel = 1;
    int maxClassLevel = 20;
    PCClass aClass;
    InfoFacade castingClass = pcClass.get();
    if (castingClass instanceof PCClass) {
        aClass = (PCClass) castingClass;
    } else if (castingClass instanceof Domain) {
        // TODO We should not be hardcoding the link between cleric and domains
        aClass = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(PCClass.class, "Cleric");
    } else {
        Logging.errorPrint("Found Casting Class in recalc that was not a Class or Domain: " + castingClass.getClass());
        return;
    }
    if (aClass != null) {
        minClassLevel = character.getSpellSupport(aClass).getMinLevelForSpellLevel(spellLevel.get() + levelAdjust, true);
        minClassLevel = Math.max(1, minClassLevel);
        if (aClass.hasMaxLevel()) {
            maxClassLevel = aClass.getSafe(IntegerKey.LEVEL_LIMIT);
        }
    }
    updateAvailCasterLevels(minClassLevel, maxClassLevel);
    int currCasterLevel = casterLevel.get() == null ? 0 : casterLevel.get();
    if (currCasterLevel < minClassLevel) {
        casterLevel.set(minClassLevel);
    } else if (currCasterLevel > maxClassLevel) {
        casterLevel.set(maxClassLevel);
    }
}
Also used : InfoFacade(pcgen.facade.core.InfoFacade) AbilityFacade(pcgen.facade.core.AbilityFacade) PCClass(pcgen.core.PCClass) Domain(pcgen.core.Domain)

Example 8 with InfoFacade

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

the class QualifiedSpellTreeCellRenderer method getTreeCellRendererComponent.

@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean focus) {
    Object obj = ((DefaultMutableTreeNode) value).getUserObject();
    if (//$NON-NLS-1$
    "".equals(obj)) {
        //$NON-NLS-1$
        obj = LanguageBundle.getString("in_none");
    }
    super.getTreeCellRendererComponent(tree, obj, sel, expanded, leaf, row, focus);
    if (obj instanceof SpellNode) {
        SpellNode spellNode = (SpellNode) obj;
        SpellFacade spell = spellNode.getSpell();
        ClassFacade pcClass = spellNode.getSpellcastingClass();
        if (!character.isQualifiedFor(spell, pcClass)) {
            setForeground(UIPropertyContext.getNotQualifiedColor());
        }
    }
    if (obj instanceof InfoFacade && ((InfoFacade) obj).isNamePI()) {
        setFont(FontManipulation.bold_italic(getFont()));
    } else {
        setFont(FontManipulation.plain(getFont()));
    }
    return this;
}
Also used : SpellNode(pcgen.facade.core.SpellSupportFacade.SpellNode) ClassFacade(pcgen.facade.core.ClassFacade) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) InfoFacade(pcgen.facade.core.InfoFacade) SpellFacade(pcgen.facade.core.SpellFacade)

Example 9 with InfoFacade

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

the class TempBonusTest method testEquipmentTemporaryBonus.

public void testEquipmentTemporaryBonus() throws PersistenceLayerException {
    PlayerCharacter character = getCharacter();
    LoadContext context = Globals.getContext();
    BonusObj bonus = Bonus.newBonus(context, "WEAPON|DAMAGE,TOHIT|1|TYPE=Enhancement");
    EquipBonus tb = new EquipBonus(bonus, "MARTIAL;SIMPLE;EXOTIC");
    Spell spell = context.getReferenceContext().constructNowIfNecessary(Spell.class, "PCTempBonusItem");
    spell.addToListFor(ListKey.BONUS_EQUIP, tb);
    assertFalse(TempBonusHelper.hasAnyPCTempBonus(spell));
    assertFalse(TempBonusHelper.hasPCTempBonus(spell));
    assertTrue(TempBonusHelper.hasNonPCTempBonus(spell));
    assertFalse(TempBonusHelper.hasCharacterTempBonus(spell));
    assertTrue(TempBonusHelper.hasEquipmentTempBonus(spell));
    Set<String> eaStringSet = TempBonusHelper.getEquipmentApplyString(spell);
    assertFalse(eaStringSet.isEmpty());
    assertEquals(1, eaStringSet.size());
    assertEquals("MARTIAL;SIMPLE;EXOTIC", eaStringSet.iterator().next());
    Equipment dagger = context.getReferenceContext().constructNowIfNecessary(Equipment.class, "Dagger");
    dagger.addToListFor(ListKey.TYPE, Type.WEAPON);
    dagger.addToListFor(ListKey.TYPE, Type.getConstant("Martial"));
    character.addEquipment(dagger);
    List<InfoFacade> eList = TempBonusHelper.getListOfApplicableEquipment(spell, character);
    assertEquals(1, eList.size());
    assertEquals("Dagger", eList.iterator().next().getKeyName());
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) Equipment(pcgen.core.Equipment) InfoFacade(pcgen.facade.core.InfoFacade) LoadContext(pcgen.rules.context.LoadContext) Spell(pcgen.core.spell.Spell)

Example 10 with InfoFacade

use of pcgen.facade.core.InfoFacade 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

InfoFacade (pcgen.facade.core.InfoFacade)16 ArrayList (java.util.ArrayList)7 Spell (pcgen.core.spell.Spell)4 Ability (pcgen.core.Ability)3 Domain (pcgen.core.Domain)3 Equipment (pcgen.core.Equipment)3 PCClass (pcgen.core.PCClass)3 CNAbility (pcgen.cdom.content.CNAbility)2 AvailableSpell (pcgen.cdom.helper.AvailableSpell)2 PObject (pcgen.core.PObject)2 AbilityFacade (pcgen.facade.core.AbilityFacade)2 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 ButtonGroup (javax.swing.ButtonGroup)1 JPanel (javax.swing.JPanel)1 JRadioButton (javax.swing.JRadioButton)1 TitledBorder (javax.swing.border.TitledBorder)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 EquipmentModifier (pcgen.core.EquipmentModifier)1 PlayerCharacter (pcgen.core.PlayerCharacter)1