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;
}
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);
}
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);
}
}
}
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);
}
}
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();
}
Aggregations