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