Search in sources :

Example 1 with EquipmentChoice

use of pcgen.core.EquipmentChoice in project pcgen by PCGen.

the class EquipmentChoiceDriver method getChoice.

/**
	 * @param pool
	 * @param parent
	 * @param bAdd being added
	 * @return an integer where apparently (from how it's used) only 0 is significant
	 */
public static boolean getChoice(final int pool, final Equipment parent, EquipmentModifier eqMod, final boolean bAdd, PlayerCharacter pc) {
    String choiceString = eqMod.getSafe(StringKey.CHOICE_STRING);
    if (choiceString.isEmpty()) {
        return true;
    }
    final boolean forEqBuilder = choiceString.startsWith("EQBUILDER.");
    if (bAdd && forEqBuilder) {
        return true;
    }
    List<Object> selectedList = new ArrayList<>(parent.getAssociationList(eqMod));
    final EquipmentChoice equipChoice = buildEquipmentChoice(pool, parent, eqMod, bAdd, forEqBuilder, selectedList.size(), pc);
    int effectiveChoices;
    if (equipChoice.isBAdd()) {
        effectiveChoices = selectedList.size() + equipChoice.getMaxSelect();
    } else {
        effectiveChoices = selectedList.size();
    }
    String title = //$NON-NLS-1$
    LanguageBundle.getFormattedString(//$NON-NLS-1$
    "in_equipChoiceMod", equipChoice.getTitle(), eqMod.getDisplayName(), "|");
    CDOMChooserFacadeImpl<Object> chooserFacade = new CDOMChooserFacadeImpl<>(title, equipChoice.getAvailableList(), selectedList, effectiveChoices);
    chooserFacade.setDefaultView(ChooserTreeViewType.NAME);
    chooserFacade.setAllowsDups(equipChoice.isAllowDuplicates());
    ChooserFactory.getDelegate().showGeneralChooser(chooserFacade);
    selectedList = chooserFacade.getFinalSelected();
    setChoice(parent, eqMod, selectedList, equipChoice);
    return parent.hasAssociations(eqMod);
}
Also used : CDOMChooserFacadeImpl(pcgen.core.chooser.CDOMChooserFacadeImpl) ArrayList(java.util.ArrayList) EquipmentChoice(pcgen.core.EquipmentChoice)

Example 2 with EquipmentChoice

use of pcgen.core.EquipmentChoice in project pcgen by PCGen.

the class EquipmentChoiceDriver method buildEquipmentChoice.

/**
	 * Build up the details of a required choice
	 *
	 * @param   pool
	 * @param   parent the equipment this modifer will be applied to
	 * @param   bAdd is a choice being added or removed
	 * @param   forEqBuilder
	 * @param   numSelected
	 *
	 * @return  A populated EquipmentChoice object
	 */
public static EquipmentChoice buildEquipmentChoice(final int pool, final Equipment parent, EquipmentModifier eqMod, final boolean bAdd, final boolean forEqBuilder, final int numSelected, PlayerCharacter pc) {
    final EquipmentChoice equipChoice = new EquipmentChoice(bAdd, pool);
    String choiceString = eqMod.getSafe(StringKey.CHOICE_STRING);
    if (choiceString.isEmpty()) {
        return equipChoice;
    }
    equipChoice.constructFromChoiceString(choiceString, parent, pool, numSelected, forEqBuilder, pc);
    return equipChoice;
}
Also used : EquipmentChoice(pcgen.core.EquipmentChoice)

Aggregations

EquipmentChoice (pcgen.core.EquipmentChoice)2 ArrayList (java.util.ArrayList)1 CDOMChooserFacadeImpl (pcgen.core.chooser.CDOMChooserFacadeImpl)1