Search in sources :

Example 1 with AbilityFacade

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

the class AbilityChooserTab method initComponents.

private void initComponents() {
    setOrientation(VERTICAL_SPLIT);
    availableTreeViewPanel.setDefaultRenderer(Boolean.class, new BooleanRenderer());
    availableTreeViewPanel.setTreeCellRenderer(qualifiedRenderer);
    selectedTreeViewPanel.setTreeCellRenderer(abilityRenderer);
    FilterBar<CharacterFacade, AbilityFacade> filterBar = new FilterBar<>();
    filterBar.addDisplayableFilter(new SearchFilterPanel());
    //$NON-NLS-1$
    qFilterButton.setText(LanguageBundle.getString("in_igQualFilter"));
    filterBar.addDisplayableFilter(qFilterButton);
    JPanel availPanel = FilterUtilities.configureFilteredTreeViewPane(availableTreeViewPanel, filterBar);
    Box box = Box.createHorizontalBox();
    box.add(Box.createHorizontalGlue());
    addButton.setHorizontalTextPosition(SwingConstants.LEADING);
    box.add(addButton);
    box.add(Box.createHorizontalStrut(5));
    box.setBorder(new EmptyBorder(0, 0, 5, 0));
    availPanel.add(box, BorderLayout.SOUTH);
    JPanel selPanel = new JPanel(new BorderLayout());
    selPanel.add(new JScrollPane(selectedTreeViewPanel), BorderLayout.CENTER);
    AbilityTreeTableModel.initializeTreeTable(selectedTreeViewPanel);
    box = Box.createHorizontalBox();
    box.add(Box.createHorizontalStrut(5));
    box.add(removeButton);
    box.add(Box.createHorizontalGlue());
    box.setBorder(new EmptyBorder(0, 0, 5, 0));
    selPanel.add(box, BorderLayout.SOUTH);
    FlippingSplitPane topPane = new FlippingSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, availPanel, selPanel, "abilityTop");
    setTopComponent(topPane);
    FilterButton<CharacterFacade, AbilityCategoryFacade> gainedFilterButton = new FilterButton<>("AbilityGained", true);
    //$NON-NLS-1$
    gainedFilterButton.setText(LanguageBundle.getString("in_gained"));
    gainedFilterButton.setEnabled(true);
    gainedFilterButton.setFilter(new Filter<CharacterFacade, AbilityCategoryFacade>() {

        @Override
        public boolean accept(CharacterFacade context, AbilityCategoryFacade element) {
            return context.getActiveAbilityCategories().containsElement(element);
        }
    });
    categoryBar.addDisplayableFilter(gainedFilterButton);
    JPanel filterPanel = new JPanel(new BorderLayout());
    filterPanel.add(categoryBar, BorderLayout.NORTH);
    filterPanel.add(new JScrollPane(categoryTable), BorderLayout.CENTER);
    FlippingSplitPane bottomPane = new FlippingSplitPane(JSplitPane.HORIZONTAL_SPLIT, "abilityBottom");
    bottomPane.setLeftComponent(filterPanel);
    bottomPane.setRightComponent(infoPane);
    setBottomComponent(bottomPane);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) AbilityCategoryFacade(pcgen.facade.core.AbilityCategoryFacade) FilterButton(pcgen.gui2.filter.FilterButton) Box(javax.swing.Box) CharacterFacade(pcgen.facade.core.CharacterFacade) FlippingSplitPane(pcgen.gui2.tools.FlippingSplitPane) FilterBar(pcgen.gui2.filter.FilterBar) BorderLayout(java.awt.BorderLayout) AbilityFacade(pcgen.facade.core.AbilityFacade) SearchFilterPanel(pcgen.gui2.filter.SearchFilterPanel) EmptyBorder(javax.swing.border.EmptyBorder)

Example 2 with AbilityFacade

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

the class CharacterAbilities method addElement.

private void addElement(Map<AbilityCategoryFacade, DefaultListFacade<AbilityFacade>> workingAbilityListMap, CNAbilitySelection cnas) {
    CNAbility cas = cnas.getCNAbility();
    Ability ability = cas.getAbility();
    if (!ability.getSafe(ObjectKey.VISIBILITY).isVisibleTo(View.VISIBLE_DISPLAY)) {
        // Filter out hidden abilities
        return;
    }
    AbilityCategoryFacade cat = (AbilityCategoryFacade) cas.getAbilityCategory();
    DefaultListFacade<AbilityFacade> listFacade = workingAbilityListMap.get(cat);
    if (listFacade == null) {
        listFacade = new DefaultListFacade<>();
        workingAbilityListMap.put(cat, listFacade);
    }
    if (!listFacade.containsElement(ability)) {
        listFacade.addElement(ability);
    }
}
Also used : CNAbility(pcgen.cdom.content.CNAbility) Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) AbilityCategoryFacade(pcgen.facade.core.AbilityCategoryFacade) AbilityFacade(pcgen.facade.core.AbilityFacade)

Example 3 with AbilityFacade

use of pcgen.facade.core.AbilityFacade 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 4 with AbilityFacade

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

the class SpellBuilderFacadeImpl method setSelectedMetamagicFeats.

@Override
public void setSelectedMetamagicFeats(Object[] newFeats) {
    List<AbilityFacade> chosenFeats = new ArrayList<>();
    for (Object choice : newFeats) {
        if (choice instanceof AbilityFacade) {
            chosenFeats.add((AbilityFacade) choice);
        }
    }
    selMetamagicFeats.setContents(chosenFeats);
    recalcCasterLevelDetails();
}
Also used : AbilityFacade(pcgen.facade.core.AbilityFacade) ArrayList(java.util.ArrayList) PObject(pcgen.core.PObject)

Example 5 with AbilityFacade

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

the class DataSet method initLists.

private void initLists() {
    List<Race> raceList = new ArrayList<>(context.getReferenceContext().getConstructedCDOMObjects(Race.class));
    raceList.sort(new RaceComparator());
    for (Race race : raceList) {
        if (race.getSafe(ObjectKey.VISIBILITY).isVisibleTo(View.VISIBLE_DISPLAY)) {
            races.addElement(race);
        }
    }
    List<PCClass> classList = new ArrayList<>(context.getReferenceContext().getConstructedCDOMObjects(PCClass.class));
    classList.sort(new PCClassComparator());
    for (PCClass pcClass : classList) {
        if (pcClass.getSafe(ObjectKey.VISIBILITY).isVisibleTo(View.VISIBLE_DISPLAY)) {
            classes.addElement(pcClass);
        }
    }
    for (Skill skill : context.getReferenceContext().getConstructedCDOMObjects(Skill.class)) {
        if (skill.getSafe(ObjectKey.VISIBILITY).isVisibleTo(View.VISIBLE_DISPLAY)) {
            skills.addElement(skill);
        }
    }
    for (Deity deity : context.getReferenceContext().getConstructedCDOMObjects(Deity.class)) {
        deities.addElement(deity);
    }
    for (PCTemplate template : context.getReferenceContext().getConstructedCDOMObjects(PCTemplate.class)) {
        if (template.getSafe(ObjectKey.VISIBILITY).isVisibleTo(View.VISIBLE_DISPLAY)) {
            templates.addElement(template);
        }
    }
    for (Kit kit : context.getReferenceContext().getConstructedCDOMObjects(Kit.class)) {
        kits.addElement(kit);
    }
    for (PCAlignment alignment : context.getReferenceContext().getOrderSortedCDOMObjects(PCAlignment.class)) {
        alignments.addElement(alignment);
    }
    for (PCStat stat : context.getReferenceContext().getOrderSortedCDOMObjects(PCStat.class)) {
        stats.addElement(stat);
    }
    //			new AbilityCategoryComparator());
    for (AbilityCategory category : gameMode.getAllAbilityCategories()) {
        if (category.isVisibleTo(View.VISIBLE_DISPLAY)) {
            //				categories.addElement(category);
            List<Ability> abList = new ArrayList<>(Globals.getContext().getReferenceContext().getManufacturer(Ability.class, category).getAllObjects());
            Globals.sortPObjectListByName(abList);
            DefaultListFacade<AbilityFacade> abilityList = new DefaultListFacade<>(abList);
            for (Iterator<AbilityFacade> iterator = abilityList.iterator(); iterator.hasNext(); ) {
                AbilityFacade facade = iterator.next();
                if (facade instanceof Ability) {
                    Ability ability = (Ability) facade;
                    if (!(ability.getSafe(ObjectKey.VISIBILITY).isVisibleTo(View.VISIBLE_DISPLAY))) {
                        iterator.remove();
                    }
                }
            }
            abilityMap.put(category, abilityList);
        }
    }
    Map<String, BodyStructure> structMap = new HashMap<>(SystemCollections.getUnmodifiableBodyStructureList().size() + 3);
    for (String name : SystemCollections.getUnmodifiableBodyStructureList()) {
        // TODO i18n the display name and correct the DataSetTest
        String displayName = name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase();
        final BodyStructure bodyStructure = new BodyStructure(displayName);
        bodyStructures.addElement(bodyStructure);
        structMap.put(name, bodyStructure);
    }
    Set<Type> typesWithDesignatedSlots = buildSlottedTypeList();
    bodyStructures.addElement(new BodyStructure(Constants.EQUIP_LOCATION_EQUIPPED, true, typesWithDesignatedSlots));
    bodyStructures.addElement(new BodyStructure(Constants.EQUIP_LOCATION_CARRIED, true));
    bodyStructures.addElement(new BodyStructure(Constants.EQUIP_LOCATION_NOTCARRIED, true));
    for (EquipSlot es : SystemCollections.getUnmodifiableEquipSlotList()) {
        if (structMap.containsKey(es.getBodyStructureName())) {
            structMap.get(es.getBodyStructureName()).addEquipSlot(es);
        }
    }
    for (Equipment eq : context.getReferenceContext().getConstructedCDOMObjects(Equipment.class)) {
        if (eq.getSafe(ObjectKey.VISIBILITY).isVisibleTo(View.VISIBLE_DISPLAY)) {
            equipment.addElement(eq);
        }
    }
    for (String xpTableName : gameMode.getXPTableNames()) {
        xpTableNames.addElement(xpTableName);
    }
    for (String characterType : gameMode.getCharacterTypeList()) {
        characterTypes.addElement(characterType);
    }
    for (SizeAdjustment size : context.getReferenceContext().getSortedList(SizeAdjustment.class, IntegerKey.SIZEORDER)) {
        sizes.addElement(size);
    }
    createGearBuySellSchemes();
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) EquipSlot(pcgen.core.character.EquipSlot) Type(pcgen.cdom.enumeration.Type) AbilityFacade(pcgen.facade.core.AbilityFacade) DefaultListFacade(pcgen.facade.util.DefaultListFacade)

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