Search in sources :

Example 1 with PointBuyMethod

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

the class PCLevelInfo method getBonusSkillPool.

/**
	 * Calculate the number of bonus skill points added by this level.
	 *
	 * @return  the number of bonus skill points added by this level
	 */
private int getBonusSkillPool(PlayerCharacter aPC) {
    int returnValue = 0;
    final PCClass aClass = aPC.getClassKeyed(classKeyName);
    final String purchaseName = SettingsHandler.getGame().getPurchaseModeMethodName();
    if (purchaseName != null) {
        PointBuyMethod pbm = SettingsHandler.getGame().getContext().getReferenceContext().silentlyGetConstructedCDOMObject(PointBuyMethod.class, purchaseName);
        List<BonusObj> bonusList = BonusUtilities.getBonusFromList(pbm.getBonuses(), "SKILLPOOL", "NUMBER");
        returnValue += (int) aPC.calcBonusFromList(bonusList, null);
    }
    if (aClass != null) {
        // These bonuses apply to the level or higher. We have to add and then remove
        // the previous to get the effective level bonus
        returnValue += (int) aClass.getBonusTo("SKILLPOOL", "NUMBER", classLevel, aPC);
        returnValue -= (int) aClass.getBonusTo("SKILLPOOL", "NUMBER", classLevel - 1, aPC);
    }
    if (classLevel == 1) {
        returnValue += (int) aPC.getTotalBonusTo("SKILLPOOL", "CLASS." + classKeyName);
    }
    returnValue += (int) aPC.getTotalBonusTo("SKILLPOOL", "CLASS." + classKeyName + ";LEVEL." + Integer.toString(classLevel));
    returnValue += (int) aPC.getTotalBonusTo("SKILLPOOL", "LEVEL." + aPC.getCharacterLevel(this));
    return returnValue;
}
Also used : BonusObj(pcgen.core.bonus.BonusObj) PointBuyMethod(pcgen.core.PointBuyMethod) PCClass(pcgen.core.PCClass)

Example 2 with PointBuyMethod

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

the class CharacterStatsPanel method initComponents.

/**
	 * Build and initialise the user interface.
	 */
private void initComponents() {
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    JLabel label;
    ButtonGroup exclusiveGroup;
    Border etched = null;
    TitledBorder title1 = BorderFactory.createTitledBorder(etched, in_abilities);
    title1.setTitleJustification(TitledBorder.LEFT);
    this.setBorder(title1);
    this.setLayout(gridbag);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new Insets(2, 2, 2, 2);
    final GameMode gameMode = SettingsHandler.getGame();
    int row = 0;
    exclusiveGroup = new ButtonGroup();
    Utility.buildConstraints(c, 0, row++, 3, 1, 0, 0);
    label = new JLabel(LanguageBundle.getFormattedString("in_Prefs_abilitiesGenLabel", //$NON-NLS-1$
    gameMode.getDisplayName()));
    gridbag.setConstraints(label, c);
    this.add(label);
    Utility.buildConstraints(c, 0, row, 1, 1, 0, 0);
    label = new JLabel("  ");
    gridbag.setConstraints(label, c);
    this.add(label);
    Utility.buildConstraints(c, 1, row++, 2, 1, 0, 0);
    abilitiesUserRolledButton = new JRadioButton(LanguageBundle.getString("in_Prefs_abilitiesUserRolled"));
    gridbag.setConstraints(abilitiesUserRolledButton, c);
    this.add(abilitiesUserRolledButton);
    exclusiveGroup.add(abilitiesUserRolledButton);
    Utility.buildConstraints(c, 1, row++, 2, 1, 0, 0);
    abilitiesAllSameButton = new JRadioButton(LanguageBundle.getString("in_Prefs_abilitiesAllSame") + ": ");
    gridbag.setConstraints(abilitiesAllSameButton, c);
    this.add(abilitiesAllSameButton);
    exclusiveGroup.add(abilitiesAllSameButton);
    Utility.buildConstraints(c, 1, row, 1, 1, 0, 0);
    label = new JLabel("  ");
    gridbag.setConstraints(label, c);
    this.add(label);
    Utility.buildConstraints(c, 2, row++, 2, 1, 0, 0);
    abilityScoreCombo = new JComboBoxEx();
    for (int i = gameMode.getStatMin(); i <= gameMode.getStatMax(); ++i) {
        abilityScoreCombo.addItem(String.valueOf(i));
    }
    gridbag.setConstraints(abilityScoreCombo, c);
    this.add(abilityScoreCombo);
    ReferenceManufacturer<RollMethod> mfg = gameMode.getModeContext().getReferenceContext().getManufacturer(RollMethod.class);
    List<RollMethod> rollMethods = mfg.getOrderSortedObjects();
    if (!rollMethods.isEmpty()) {
        Utility.buildConstraints(c, 1, row++, 2, 1, 0, 0);
        abilitiesRolledButton = new JRadioButton("Rolled:");
        gridbag.setConstraints(abilitiesRolledButton, c);
        this.add(abilitiesRolledButton);
        exclusiveGroup.add(abilitiesRolledButton);
        Utility.buildConstraints(c, 2, row++, 2, 1, 0, 0);
        abilityRolledModeCombo = new JComboBoxEx();
        for (RollMethod rm : rollMethods) {
            abilityRolledModeCombo.addItem(rm.getDisplayName());
        }
        gridbag.setConstraints(abilityRolledModeCombo, c);
        this.add(abilityRolledModeCombo);
    }
    Collection<PointBuyMethod> methods = SettingsHandler.getGame().getModeContext().getReferenceContext().getConstructedCDOMObjects(PointBuyMethod.class);
    final int purchaseMethodCount = methods.size();
    Utility.buildConstraints(c, 1, row++, 2, 1, 0, 0);
    abilitiesPurchasedButton = new JRadioButton(LanguageBundle.getString("in_Prefs_abilitiesPurchased") + ": ");
    gridbag.setConstraints(abilitiesPurchasedButton, c);
    this.add(abilitiesPurchasedButton);
    exclusiveGroup.add(abilitiesPurchasedButton);
    Utility.buildConstraints(c, 2, row++, 2, 1, 0, 0);
    pMode = new String[purchaseMethodCount];
    pModeMethodName = new String[purchaseMethodCount];
    int i = 0;
    for (PointBuyMethod pbm : methods) {
        pMode[i] = pbm.getDescription();
        pModeMethodName[i] = pbm.getDisplayName();
        i++;
    }
    abilityPurchaseModeCombo = new JComboBoxEx(pMode);
    gridbag.setConstraints(abilityPurchaseModeCombo, c);
    this.add(abilityPurchaseModeCombo);
    //
    if (purchaseMethodCount == 0) {
        abilityPurchaseModeCombo.setVisible(false);
        abilitiesPurchasedButton.setVisible(false);
    }
    Utility.buildConstraints(c, 1, row++, 1, 1, 0, 0);
    label = new JLabel(" ");
    gridbag.setConstraints(label, c);
    this.add(label);
    Utility.buildConstraints(c, 1, row++, 3, 1, 0, 0);
    JButton purchaseModeButton = new JButton(LanguageBundle.getString("in_Prefs_purchaseModeConfig"));
    gridbag.setConstraints(purchaseModeButton, c);
    this.add(purchaseModeButton);
    purchaseModeButton.addActionListener(new PurchaseModeButtonListener());
    Utility.buildConstraints(c, 5, 20, 1, 1, 1, 1);
    c.fill = GridBagConstraints.BOTH;
    label = new JLabel(" ");
    gridbag.setConstraints(label, c);
    this.add(label);
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JRadioButton(javax.swing.JRadioButton) RollMethod(pcgen.cdom.content.RollMethod) GridBagLayout(java.awt.GridBagLayout) PointBuyMethod(pcgen.core.PointBuyMethod) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) TitledBorder(javax.swing.border.TitledBorder) GameMode(pcgen.core.GameMode) ButtonGroup(javax.swing.ButtonGroup) JComboBoxEx(pcgen.gui2.util.JComboBoxEx) Border(javax.swing.border.Border) TitledBorder(javax.swing.border.TitledBorder)

Example 3 with PointBuyMethod

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

the class PurchaseModeFrame method addMethodButtonActionPerformed.

//
// Pop up a window to get information about a new purchase method
//
private void addMethodButtonActionPerformed() {
    NewPurchaseMethodDialog npmd = new NewPurchaseMethodDialog(this, true);
    npmd.setVisible(true);
    if (!npmd.getWasCancelled()) {
        final String methodName = npmd.getEnteredName();
        if (SettingsHandler.getGame().getModeContext().getReferenceContext().silentlyGetConstructedCDOMObject(PointBuyMethod.class, methodName) == null) {
            PointBuyMethod pbm = new PointBuyMethod();
            pbm.setName(methodName);
            pbm.setPointFormula(Integer.toString(npmd.getEnteredPoints()));
            currentPurchaseMethods.addItem(pbm);
            currentPurchaseMethods.setSelectedItem(pbm);
        } else {
            ShowMessageDelegate.showMessageDialog(//$NON-NLS-1$
            LanguageBundle.getString("in_Prefs_cannotAdd"), Constants.APPLICATION_NAME, MessageType.ERROR);
        }
    }
}
Also used : PointBuyMethod(pcgen.core.PointBuyMethod)

Example 4 with PointBuyMethod

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

the class PurchaseModeFrame method currentPurchaseMethodsActionPerformed.

/**
	 * Display info about the selected purchase method.
	 */
private void currentPurchaseMethodsActionPerformed() {
    final PointBuyMethod method = (PointBuyMethod) currentPurchaseMethods.getSelectedItem();
    if (method == null) {
        removeMethodButton.setEnabled(false);
        //$NON-NLS-1$
        purchaseMethodPointsEdit.setText("");
    } else {
        purchaseMethodPointsEdit.setText(method.getPointFormula());
        removeMethodButton.setEnabled(true);
    }
}
Also used : PointBuyMethod(pcgen.core.PointBuyMethod)

Example 5 with PointBuyMethod

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

the class PurchaseModeFrame method initializeCurrentPurchaseMethods.

private void initializeCurrentPurchaseMethods() {
    //
    // Set up the current methods combo's contents
    //
    Collection<PointBuyMethod> methods = SettingsHandler.getGame().getModeContext().getReferenceContext().getConstructedCDOMObjects(PointBuyMethod.class);
    if (!methods.isEmpty()) {
        currentPurchaseMethods.setModel(new DefaultComboBoxModel(methods.toArray()));
    }
    // Get into correct state
    currentPurchaseMethodsActionPerformed();
}
Also used : PointBuyMethod(pcgen.core.PointBuyMethod) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel)

Aggregations

PointBuyMethod (pcgen.core.PointBuyMethod)6 GameMode (pcgen.core.GameMode)2 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1 Collection (java.util.Collection)1 ButtonGroup (javax.swing.ButtonGroup)1 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)1 JButton (javax.swing.JButton)1 JLabel (javax.swing.JLabel)1 JRadioButton (javax.swing.JRadioButton)1 Border (javax.swing.border.Border)1 TitledBorder (javax.swing.border.TitledBorder)1 RollMethod (pcgen.cdom.content.RollMethod)1 PCClass (pcgen.core.PCClass)1 BonusObj (pcgen.core.bonus.BonusObj)1 JComboBoxEx (pcgen.gui2.util.JComboBoxEx)1