use of pcgen.core.character.CharacterSpell in project pcgen by PCGen.
the class SpellMemToken method getBonusSpellValue.
/**
* Display an * is the spell is a domain/specialty spell,
* display ** if it is ONLY a domain/specialty spell. A value
* may also be supplied that will be displayed for non-specialty spells.
*
* @param aPC The character being processed.
* @param spellLevel The level of the spell.
* @param sString The indicator to use for domain/specialty spells.
* @param altLabel The indicator to use for non domain/specialty spells.
* @param aObject The class containing the spell.
* @param bookName The name of the spell book.
* @param cs The spell as it applies to the character
* @param aSpell The generic spell.
* @return The annotation string indicating domain/specialty status
*/
private String getBonusSpellValue(PlayerCharacter aPC, final int spellLevel, String sString, String altLabel, final PObject aObject, String bookName, CharacterSpell cs, Spell aSpell) {
StringBuilder retValue = new StringBuilder();
if ((aObject != null) && (cs != null) && cs.isSpecialtySpell(aPC) && (aObject instanceof PCClass)) {
final List<CharacterSpell> charSpells = aPC.getCharacterSpells(aObject, aSpell, bookName, spellLevel);
boolean isDomainOnly = true;
for (CharacterSpell cSpell : charSpells) {
if (!cSpell.isSpecialtySpell(aPC)) {
isDomainOnly = false;
break;
}
}
if (isDomainOnly) {
retValue.append(sString);
} else {
retValue.append(sString + sString);
}
} else {
retValue.append(altLabel);
}
return retValue.toString();
}
use of pcgen.core.character.CharacterSpell in project pcgen by PCGen.
the class PlayerCharacter method aggregateSpellList.
public List<Spell> aggregateSpellList(final String school, final String subschool, final String descriptor, final int minLevel, final int maxLevel) {
final List<Spell> retList = new ArrayList<>();
for (PObject pObj : getSpellClassList()) {
for (int a = minLevel; a <= maxLevel; a++) {
for (CharacterSpell cs : getCharacterSpells(pObj, a)) {
final Spell aSpell = cs.getSpell();
SpellSchool ss = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(SpellSchool.class, school);
if ((school.isEmpty()) || (ss != null) && aSpell.containsInList(ListKey.SPELL_SCHOOL, ss) || (subschool.isEmpty()) || aSpell.containsInList(ListKey.SPELL_SUBSCHOOL, subschool) || (descriptor.isEmpty()) || aSpell.containsInList(ListKey.SPELL_DESCRIPTOR, descriptor)) {
retList.add(aSpell);
}
}
}
}
return retList;
}
use of pcgen.core.character.CharacterSpell in project pcgen by PCGen.
the class PlayerCharacter method countSpellsInBook.
/**
* Counts the number of spells inside a spellbook Yes, divine casters can
* have a "spellbook"
*
* @param aString
* @return spells in a book
*/
public int countSpellsInBook(final String aString) {
final StringTokenizer aTok = new StringTokenizer(aString, ".");
final int classNum = Integer.parseInt(aTok.nextToken());
final int sbookNum = Integer.parseInt(aTok.nextToken());
final int levelNum;
if (sbookNum >= getSpellBookCount()) {
return 0;
}
if (aTok.hasMoreTokens()) {
levelNum = Integer.parseInt(aTok.nextToken());
} else {
levelNum = -1;
}
String bookName = Globals.getDefaultSpellBook();
if (sbookNum > 0) {
bookName = getSpellBookNames().get(sbookNum);
}
final PObject aObject = getSpellClassAtIndex(classNum);
if (aObject != null) {
final List<CharacterSpell> aList = getCharacterSpells(aObject, null, bookName, levelNum);
return aList.size();
}
return 0;
}
use of pcgen.core.character.CharacterSpell in project pcgen by PCGen.
the class PlayerCharacter method getCharacterSpellForSpell.
/**
* Retrieve the character's existing version of this spell, if any.
* @param po The source of the spell list for this spell (normally a PCClass)
* @param spell The spell to be retrieved
* @param owner The source of the spell (either the PCClass or the Domian)
* @return The character's existing instance of the spell, or null if none.
*/
public CharacterSpell getCharacterSpellForSpell(PObject po, Spell spell, PObject owner) {
List<CharacterSpell> cspells = new ArrayList<>(getCharacterSpells(po));
// Add in the spells granted by objects
addBonusKnownSpellsToList(po, cspells);
for (CharacterSpell cs : cspells) {
Spell sp = cs.getSpell();
if (spell.equals(sp) && (cs.getOwner().equals(owner))) {
return cs;
}
}
return null;
}
use of pcgen.core.character.CharacterSpell in project pcgen by PCGen.
the class PlayerCharacter method getTotalCasterLevelWithSpellBonus.
public int getTotalCasterLevelWithSpellBonus(CharacterSpell acs, final Spell aSpell, final String spellType, final String classOrRace, final int casterLev) {
if (aSpell != null && acs.getFixedCasterLevel() != null) {
return getVariableValue(acs.getFixedCasterLevel(), Constants.EMPTY_STRING).intValue();
}
int tBonus = casterLev;
boolean replaceCasterLevel = false;
String tType;
String tStr;
// final List<TypedBonus> bonuses = new ArrayList<TypedBonus>();
final List<CasterLevelSpellBonus> bonuses = new ArrayList<>();
if (classOrRace != null) {
// bonuses.addAll(getBonusesTo("CASTERLEVEL", classOrRace));
tBonus = (int) getTotalBonusTo("CASTERLEVEL", classOrRace);
if (tBonus > 0) {
tType = getSpellBonusType("CASTERLEVEL", classOrRace);
bonuses.add(new CasterLevelSpellBonus(tBonus, tType));
}
// BONUS:CASTERLEVEL|CLASS.Sorcerer|1
if (!classOrRace.startsWith("RACE.")) {
tStr = "CLASS." + classOrRace;
// bonuses.addAll( getBonusesTo("CASTERLEVEL", tStr) );
tBonus = (int) getTotalBonusTo("CASTERLEVEL", tStr);
if (tBonus > 0) {
tType = getSpellBonusType("CASTERLEVEL", tStr);
bonuses.add(new CasterLevelSpellBonus(tBonus, tType));
}
}
}
if (aSpell == null) {
return tallyCasterlevelBonuses(casterLev, replaceCasterLevel, bonuses);
}
if (!spellType.equals(Constants.NONE)) {
tStr = "TYPE." + spellType;
// bonuses.addAll( getBonusesTo("CASTERLEVEL", tStr) );
tBonus = (int) getTotalBonusTo("CASTERLEVEL", tStr);
if (tBonus > 0) {
tType = getSpellBonusType("CASTERLEVEL", tStr);
bonuses.add(new CasterLevelSpellBonus(tBonus, tType));
}
tStr += ".RESET";
// final List<TypedBonus> reset = getBonusesTo("CASTERLEVEL", tStr);
// if ( reset.size() > 0 )
// {
// bonuses.addAll(reset);
// replaceCasterLevel = true;
// }
tBonus = (int) getTotalBonusTo("CASTERLEVEL", tStr);
if (tBonus > 0) {
replaceCasterLevel = true;
tType = getSpellBonusType("CASTERLEVEL", tStr);
bonuses.add(new CasterLevelSpellBonus(tBonus, tType));
}
}
tStr = "SPELL." + aSpell.getKeyName();
// bonuses.addAll( getBonusesTo("CASTERLEVEL", tStr) );
tBonus = (int) getTotalBonusTo("CASTERLEVEL", tStr);
if (tBonus > 0) {
tType = getSpellBonusType("CASTERLEVEL", tStr);
bonuses.add(new CasterLevelSpellBonus(tBonus, tType));
}
tStr += ".RESET";
// final List<TypedBonus> reset = getBonusesTo("CASTERLEVEL", tStr);
// if ( reset.size() > 0 )
// {
// bonuses.addAll(reset);
// replaceCasterLevel = true;
// }
tBonus = (int) getTotalBonusTo("CASTERLEVEL", tStr);
if (tBonus > 0) {
replaceCasterLevel = true;
tType = getSpellBonusType("CASTERLEVEL", tStr);
bonuses.add(new CasterLevelSpellBonus(tBonus, tType));
}
/*
* This wraps in TreeSet because it looks to me like this is ordered
* (given .RESET)
*/
for (SpellSchool school : new TreeSet<>(aSpell.getSafeListFor(ListKey.SPELL_SCHOOL))) {
tStr = "SCHOOL." + school.toString();
// bonuses.addAll( getBonusesTo("CASTERLEVEL", tStr) );
tBonus = (int) getTotalBonusTo("CASTERLEVEL", tStr);
if (// Allow negative bonus to casterlevel
tBonus != 0) {
tType = getSpellBonusType("CASTERLEVEL", tStr);
bonuses.add(new CasterLevelSpellBonus(tBonus, tType));
}
tStr += ".RESET";
// final List<TypedBonus> reset1 = getBonusesTo("CASTERLEVEL",
// tStr);
// if ( reset.size() > 0 )
// {
// bonuses.addAll(reset1);
// replaceCasterLevel = true;
// }
tBonus = (int) getTotalBonusTo("CASTERLEVEL", tStr);
if (tBonus > 0) {
replaceCasterLevel = true;
tType = getSpellBonusType("CASTERLEVEL", tStr);
bonuses.add(new CasterLevelSpellBonus(tBonus, tType));
}
}
for (String subschool : new TreeSet<>(aSpell.getSafeListFor(ListKey.SPELL_SUBSCHOOL))) {
tStr = "SUBSCHOOL." + subschool;
// bonuses.addAll( getBonusesTo("CASTERLEVEL", tStr) );
tBonus = (int) getTotalBonusTo("CASTERLEVEL", tStr);
if (tBonus > 0) {
tType = getSpellBonusType("CASTERLEVEL", tStr);
bonuses.add(new CasterLevelSpellBonus(tBonus, tType));
}
tStr += ".RESET";
// final List<TypedBonus> reset1 = getBonusesTo("CASTERLEVEL",
// tStr);
// if ( reset.size() > 0 )
// {
// bonuses.addAll(reset1);
// replaceCasterLevel = true;
// }
tBonus = (int) getTotalBonusTo("CASTERLEVEL", tStr);
if (tBonus > 0) {
replaceCasterLevel = true;
tType = getSpellBonusType("CASTERLEVEL", tStr);
bonuses.add(new CasterLevelSpellBonus(tBonus, tType));
}
}
//Not wrapped because it wasn't in 5.14
for (String desc : aSpell.getSafeListFor(ListKey.SPELL_DESCRIPTOR)) {
tStr = "DESCRIPTOR." + desc;
// bonuses.addAll( getBonusesTo("CASTERLEVEL", tStr) );
tBonus = (int) getTotalBonusTo("CASTERLEVEL", tStr);
if (tBonus > 0) {
tType = getSpellBonusType("CASTERLEVEL", tStr);
bonuses.add(new CasterLevelSpellBonus(tBonus, tType));
}
tStr += ".RESET";
// final List<TypedBonus> reset1 = getBonusesTo("CASTERLEVEL",
// tStr);
// if ( reset.size() > 0 )
// {
// bonuses.addAll(reset1);
// replaceCasterLevel = true;
// }
tBonus = (int) getTotalBonusTo("CASTERLEVEL", tStr);
if (tBonus > 0) {
replaceCasterLevel = true;
tType = getSpellBonusType("CASTERLEVEL", tStr);
bonuses.add(new CasterLevelSpellBonus(tBonus, tType));
}
}
final HashMapToList<CDOMList<Spell>, Integer> domainMap = getSpellLevelInfo(aSpell);
if (domainMap != null) {
for (CDOMList<Spell> spellList : domainMap.getKeySet()) {
if (spellList instanceof DomainSpellList) {
tStr = "DOMAIN." + spellList.getKeyName();
// bonuses.addAll( getBonusesTo("CASTERLEVEL", tStr) );
tBonus = (int) getTotalBonusTo("CASTERLEVEL", tStr);
if (tBonus > 0) {
tType = getSpellBonusType("CASTERLEVEL", tStr);
bonuses.add(new CasterLevelSpellBonus(tBonus, tType));
}
tStr += ".RESET";
// final List<TypedBonus> reset1 =
// getBonusesTo("CASTERLEVEL", tStr);
// if ( reset.size() > 0 )
// {
// bonuses.addAll(reset1);
// replaceCasterLevel = true;
// }
tBonus = (int) getTotalBonusTo("CASTERLEVEL", tStr);
if (tBonus > 0) {
replaceCasterLevel = true;
tType = getSpellBonusType("CASTERLEVEL", tStr);
bonuses.add(new CasterLevelSpellBonus(tBonus, tType));
}
}
}
}
int result = tallyCasterlevelBonuses(casterLev, replaceCasterLevel, bonuses);
return (result);
}
Aggregations