use of pcgen.cdom.helper.ClassSource in project pcgen by PCGen.
the class DomainApplication method removeDomain.
/**
* Remove a domain from the character.
* @param pc The character
* @param domain The domain.
*/
public static void removeDomain(PlayerCharacter pc, Domain domain) {
ClassSource source = pc.getDomainSource(domain);
PCClass aClass = pc.getClassKeyed(source.getPcclass().getKeyName());
if (aClass != null) {
int maxLevel;
for (maxLevel = 0; maxLevel < 10; maxLevel++) {
if (pc.getSpellSupport(aClass).getCastForLevel(maxLevel, pc) == 0) {
break;
}
}
if (maxLevel > 0) {
removeSpellsFromClassForLevels(pc, domain, aClass);
}
if ((maxLevel > 1) && (aClass.getSafe(IntegerKey.KNOWN_SPELLS_FROM_SPECIALTY) == 0)) {
DomainSpellList domainSpellList = domain.get(ObjectKey.DOMAIN_SPELLLIST);
final List<Spell> aList = pc.getAllSpellsInLists(Collections.singletonList(domainSpellList));
for (Spell gcs : aList) {
if (SpellLevel.getFirstLvlForKey(gcs, domainSpellList, pc) < maxLevel) {
pc.removeDomainSpellCount(aClass);
break;
}
}
}
}
if (!pc.isImporting()) {
BonusActivation.deactivateBonuses(domain, pc);
}
}
use of pcgen.cdom.helper.ClassSource in project pcgen by PCGen.
the class PCGVer2Creator method getDomainSourcePcgString.
/**
* Returns the source of the domain in the format "PObject|name[|level]"
* For example, "PCClass|Cleric|1"
* (since the level is relevant)
* For example, "Feat|Awesome Divinity" to attach a domain to a feat
*
* This method should NOT be called outside of file i/o routines
* DO NOT perform comparisons on this String
*
* @return String the source of the domain
*/
private String getDomainSourcePcgString(Domain domain) {
final StringBuilder buff = new StringBuilder(30);
ClassSource source = thePC.getDomainSource(domain);
buff.append("PCClass");
buff.append('|');
buff.append(source.getPcclass().getKeyName());
if (source.getLevel() > 0) {
buff.append('|');
buff.append(source.getLevel());
}
return buff.toString();
}
use of pcgen.cdom.helper.ClassSource in project pcgen by PCGen.
the class DomainSpellsFacet method dataAdded.
/**
* Adds Domain Spells allowed / granted to the Player Character due to the
* Domain selections of the Player Character.
*
* Triggered when one of the Facets to which DomainSpellsFacet listens fires
* a DataFacetChangeEvent to indicate a Domain was added to a Player
* Character.
*
* @param dfce
* The DataFacetChangeEvent containing the information about the
* change
*
* @see pcgen.cdom.facet.event.DataFacetChangeListener#dataAdded(pcgen.cdom.facet.event.DataFacetChangeEvent)
*/
@Override
public void dataAdded(DataFacetChangeEvent<CharID, Domain> dfce) {
Domain domain = dfce.getCDOMObject();
CharID id = dfce.getCharID();
ClassSource source = domainFacet.getSource(id, domain);
if (source != null) {
String classKey = source.getPcclass().getKeyName();
PCClass domainClass = getClassKeyed(id, classKey);
if (domainClass != null) {
PlayerCharacter pc = trackingFacet.getPC(id);
final int maxLevel = pc.getSpellSupport(domainClass).getMaxCastLevel();
DomainApplication.addSpellsToClassForLevels(pc, domain, domainClass, 0, maxLevel);
}
}
}
use of pcgen.cdom.helper.ClassSource in project pcgen by PCGen.
the class PCMaxCastableDomainTermEvaluator method resolve.
@Override
public Float resolve(PlayerCharacter pc) {
Domain domain = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Domain.class, domainKey);
if (domain == null) {
return 0.0f;
}
ClassSource source = pc.getDomainSource(domain);
if (source == null) {
return 0.0f;
}
String classKey = source.getPcclass().getKeyName();
PCClass spClass = pc.getClassKeyed(classKey);
int cutoff = pc.getSpellSupport(spClass).getHighestLevelSpell();
Float max = 0.0f;
if (pc.getSpellSupport(spClass).hasCastList()) {
for (int i = 0; i < cutoff; i++) {
if (pc.getSpellSupport(spClass).getCastForLevel(i, pc) != 0) {
max = Math.max(max, i);
}
}
} else {
for (int i = 0; i < cutoff; i++) {
if (pc.getSpellSupport(spClass).getKnownForLevel(i, pc) != 0) {
max = Math.max(max, i);
}
}
}
return max;
}
use of pcgen.cdom.helper.ClassSource in project pcgen by PCGen.
the class PlayerCharacter method getConcentration.
public int getConcentration(final Spell sp, final CharacterSpell aSpell, PCClass aClass, int spellLevel, int metaConcentration, CDOMObject ow) {
String bonDomain = "";
if (ow instanceof Domain) {
bonDomain = "DOMAIN." + ow.getKeyName();
ClassSource source = getDomainSource((Domain) ow);
if (source != null) {
aClass = getClassKeyed(source.getPcclass().getKeyName());
}
}
boolean useStatFromSpell = false;
String bonClass = "";
String spellType = "";
String classKey = "";
if ((aClass != null) || (ow instanceof PCClass)) {
if ((aClass == null) || (ow instanceof PCClass)) {
aClass = (PCClass) ow;
}
bonClass = "CLASS." + aClass.getKeyName();
classKey = "CLASS:" + aClass.getKeyName();
spellType = aClass.getSpellType();
useStatFromSpell = aClass.getSafe(ObjectKey.USE_SPELL_SPELL_STAT);
}
if (!(ow instanceof PCClass) && !(ow instanceof Domain)) {
// get BASESPELLSTAT from spell itself
useStatFromSpell = true;
}
// set the spell Level used in aPC.getVariableValue()
// Explicitly should *not* set the dirty flag to true.
spellLevelTemp = spellLevel;
// must be done after spellLevel is set above
int concentration = getVariableValue(aSpell, SettingsHandler.getGame().getSpellBaseConcentration(), classKey).intValue() + metaConcentration;
concentration += (int) getTotalBonusTo("CONCENTRATION", "ALLSPELLS");
if (useStatFromSpell) {
// get the BASESPELLSTAT from the spell itself
CDOMSingleRef<PCStat> stat = sp.get(ObjectKey.SPELL_STAT);
if (stat != null) {
concentration += this.getStatModFor(stat.get());
}
}
if (!sp.getKeyName().isEmpty()) {
concentration += (int) getTotalBonusTo("CONCENTRATION", "SPELL." + sp.getKeyName());
}
// DOMAIN.name
if (!bonDomain.isEmpty()) {
concentration += (int) getTotalBonusTo("CONCENTRATION", bonDomain);
}
// CLASS.name
if (!bonClass.isEmpty()) {
concentration += (int) getTotalBonusTo("CONCENTRATION", bonClass);
}
concentration += (int) getTotalBonusTo("CONCENTRATION", "TYPE." + spellType);
if (spellType.equals("ALL")) {
for (Type aType : sp.getTrueTypeList(false)) {
concentration += (int) getTotalBonusTo("CONCENTRATION", "TYPE." + aType);
}
}
for (SpellSchool aType : sp.getSafeListFor(ListKey.SPELL_SCHOOL)) {
concentration += (int) getTotalBonusTo("CONCENTRATION", "SCHOOL." + aType.toString());
}
for (String aType : sp.getSafeListFor(ListKey.SPELL_SUBSCHOOL)) {
concentration += (int) getTotalBonusTo("CONCENTRATION", "SUBSCHOOL." + aType);
}
for (String aType : sp.getSafeListFor(ListKey.SPELL_DESCRIPTOR)) {
concentration += (int) getTotalBonusTo("CONCENTRATION", "DESCRIPTOR." + aType);
}
// Explicitly should *not* set the dirty flag to true.
spellLevelTemp = 0;
return concentration;
}
Aggregations