use of pcgen.core.spell.Spell in project pcgen by PCGen.
the class KnownspellsTokenTest method testUnparseLevel.
@Test
public void testUnparseLevel() throws PersistenceLayerException {
CDOMGroupRef<Spell> all = primaryContext.getReferenceContext().getCDOMAllReference(Spell.class);
primaryProf.addToListFor(ListKey.KNOWN_SPELLS, new KnownSpellIdentifier(all, 4));
String[] sap = getToken().unparse(primaryContext, primaryProf);
expectSingle(sap, "LEVEL=4");
}
use of pcgen.core.spell.Spell in project pcgen by PCGen.
the class KnownspellsTokenTest method testRoundRobinTypeLevel.
@Test
public void testRoundRobinTypeLevel() throws PersistenceLayerException {
construct(primaryContext, "TestWP1");
construct(primaryContext, "TestWP2");
construct(primaryContext, "TestWP3");
construct(secondaryContext, "TestWP1");
construct(secondaryContext, "TestWP2");
construct(secondaryContext, "TestWP3");
Spell a = construct(primaryContext, "TestWP2");
a.addToListFor(ListKey.TYPE, Type.getConstant("SpellType"));
Spell c = construct(secondaryContext, "TestWP2");
c.addToListFor(ListKey.TYPE, Type.getConstant("SpellType"));
runRoundRobin("TestWP1" + getJoinCharacter() + "TYPE=SpellType,LEVEL=1");
}
use of pcgen.core.spell.Spell in project pcgen by PCGen.
the class PlayerCharacter method getCasterLevelForClass.
/**
* Computes the Caster Level for a Class
*
* @param aClass
* @return caster level for class
*/
public int getCasterLevelForClass(final PCClass aClass) {
final Spell sp = new Spell();
final CharacterSpell cs = new CharacterSpell(aClass, sp);
final String aSpellClass = "CLASS:" + aClass.getKeyName();
return getVariableValue(cs, "CASTERLEVEL", aSpellClass).intValue();
}
use of pcgen.core.spell.Spell in project pcgen by PCGen.
the class PlayerCharacter method removeKnownSpellsForClassLevel.
public void removeKnownSpellsForClassLevel(PCClass pcc) {
if (!pcc.containsListFor(ListKey.KNOWN_SPELLS) || importing || !autoKnownSpells) {
return;
}
if (!hasCharacterSpells(pcc)) {
return;
}
SpellSupportForPCClass spellSupport = getSpellSupport(pcc);
List<? extends CDOMList<Spell>> lists = getSpellLists(pcc);
List<CharacterSpell> spellsToBeRemoved = new ArrayList<>();
for (final CharacterSpell charSpell : getCharacterSpells(pcc)) {
final Spell aSpell = charSpell.getSpell();
// Check that the character can still cast spells of this level.
final Integer[] spellLevels = SpellLevel.levelForKey(aSpell, lists, this);
for (final Integer spellLevel : spellLevels) {
if (spellLevel == -1) {
continue;
}
final boolean isKnownAtThisLevel = spellSupport.isAutoKnownSpell(aSpell, spellLevel, true, this);
if (!isKnownAtThisLevel) {
spellsToBeRemoved.add(charSpell);
}
}
}
for (CharacterSpell characterSpell : spellsToBeRemoved) {
removeCharacterSpell(pcc, characterSpell);
}
}
use of pcgen.core.spell.Spell in project pcgen by PCGen.
the class DomainApplication method addSpellsToClassForLevels.
public static void addSpellsToClassForLevels(PlayerCharacter pc, Domain d, PCClass aClass, int minLevel, int maxLevel) {
if (aClass == null) {
return;
}
for (int aLevel = minLevel; aLevel <= maxLevel; aLevel++) {
Collection<Spell> domainSpells = pc.getSpellsIn(d.get(ObjectKey.DOMAIN_SPELLLIST), aLevel);
for (Spell spell : domainSpells) {
List<CharacterSpell> slist = pc.getCharacterSpells(aClass, spell, Globals.getDefaultSpellBook(), aLevel);
boolean flag = true;
for (CharacterSpell cs1 : slist) {
flag = !(cs1.getOwner().equals(d));
if (!flag) {
break;
}
}
if (flag) {
CharacterSpell cs = new CharacterSpell(d, spell);
cs.addInfo(aLevel, 1, Globals.getDefaultSpellBook());
pc.addCharacterSpell(aClass, cs);
}
}
}
}
Aggregations