use of pcgen.cdom.helper.ClassSource in project pcgen by PCGen.
the class CharacterFacadeImpl method addDomain.
/**
* @see pcgen.core.facade.CharacterFacade#addDomain(pcgen.core.facade.DomainFacade)
*/
@Override
public void addDomain(DomainFacade domainFacade) {
if (!(domainFacade instanceof DomainFacadeImpl)) {
return;
}
DomainFacadeImpl domainFI = (DomainFacadeImpl) domainFacade;
Domain domain = domainFI.getRawObject();
if (charDisplay.hasDomain(domain)) {
return;
}
if (!isQualifiedFor(domainFacade)) {
delegate.showErrorMessage(Constants.APPLICATION_NAME, LanguageBundle.getFormattedString("in_qualifyMess", domain.getDisplayName()));
return;
}
// Check selected domains vs Max number allowed
if (charDisplay.getDomainCount() >= theCharacter.getMaxCharacterDomains()) {
delegate.showErrorMessage(Constants.APPLICATION_NAME, LanguageBundle.getFormattedString("in_errorNoMoreDomains"));
return;
}
if (!theCharacter.hasDefaultDomainSource()) {
// No source for the domain yet? Default to the last added class level
int level = charDisplay.getLevelInfoSize();
PCLevelInfo highestLevelInfo = charDisplay.getLevelInfo(level - 1);
PCClass cls = theCharacter.getClassKeyed(highestLevelInfo.getClassKeyName());
theCharacter.setDefaultDomainSource(new ClassSource(cls, highestLevelInfo.getClassLevel()));
}
if (theCharacter.addDomain(domain)) {
domains.addElement(domainFI);
DomainApplication.applyDomain(theCharacter, domain);
theCharacter.calcActiveBonuses();
remainingDomains.set(theCharacter.getMaxCharacterDomains() - charDisplay.getDomainCount());
updateDomainTodo();
spellSupportFacade.refreshAvailableKnownSpells();
companionSupportFacade.refreshCompanionData();
}
}
use of pcgen.cdom.helper.ClassSource in project pcgen by PCGen.
the class CcskillTokenTest method preparePC.
@Override
protected void preparePC(PlayerCharacter pc1, ChooseDriver owner) {
PCClass c1 = Globals.getContext().getReferenceContext().constructCDOMObject(PCClass.class, "Class1");
pc1.setDefaultDomainSource(new ClassSource(c1));
pc1.addDomain((Domain) owner);
super.preparePC(pc1, owner);
}
use of pcgen.cdom.helper.ClassSource in project pcgen by PCGen.
the class CskillTokenTest method preparePC.
@Override
protected void preparePC(PlayerCharacter pc1, ChooseDriver owner) {
PCClass c1 = Globals.getContext().getReferenceContext().constructCDOMObject(PCClass.class, "Class1");
pc1.setDefaultDomainSource(new ClassSource(c1));
pc1.addDomain((Domain) owner);
super.preparePC(pc1, owner);
}
use of pcgen.cdom.helper.ClassSource in project pcgen by PCGen.
the class NPCGenerator method selectDomains.
private void selectDomains(final PlayerCharacter aPC, final PCClass aClass) {
final WeightedCollection<Domain> domains = theConfiguration.getDomainWeights(aPC.getDeity().getKeyName(), aClass.getKeyName());
for (Iterator<Domain> iterator = domains.iterator(); iterator.hasNext(); ) {
Domain domain = iterator.next();
if (!domain.qualifies(aPC, domain)) {
iterator.remove();
}
}
if (domains.isEmpty()) {
return;
}
while (aPC.getDomainCount() < aPC.getMaxCharacterDomains()) {
final Domain domain = domains.getRandomValue();
//Can't add twice, so have to select another...
if (aPC.hasDomain(domain)) {
continue;
}
// space remains for another domain, so add it
aPC.addDomain(domain, new ClassSource(aClass));
DomainApplication.applyDomain(aPC, domain);
aPC.calcActiveBonuses();
}
}
use of pcgen.cdom.helper.ClassSource in project pcgen by PCGen.
the class PCCasterLevelClassTermEvaluator method resolve.
@Override
public Float resolve(PlayerCharacter pc, final CharacterSpell aSpell) {
// check if this is a domain spell
Domain domain = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Domain.class, source);
final ClassSource cs = pc.getDomainSource(domain);
// If source is a domain, get the Domain source (e.g, "Cleric"),
// otherwise just go with the original varSource
final String varSource = (cs != null) ? cs.getPcclass().getKeyName() : source;
final PCClass spClass = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(PCClass.class, varSource);
String spellType = Constants.NONE;
if ((spClass != null) && (!spClass.getSpellType().equals(Constants.NONE))) {
spellType = spClass.getSpellType();
}
final Double d1 = pc.getTotalBonusTo("PCLEVEL", varSource);
final int pcBonus = (d1 == null) ? 0 : d1.intValue();
// does the class have a Casterlevel?
final Double d2 = pc.getTotalBonusTo("CASTERLEVEL", varSource);
final int castBonus = (d2 == null) ? 0 : d2.intValue();
// If no CASTERLEVEL has been defined for this class then
// use total class level instead
final int iClass = (spClass != null && castBonus == 0) ? pc.getDisplay().getLevel(spClass) : 0;
return (float) pc.getTotalCasterLevelWithSpellBonus(aSpell, aSpell.getSpell(), spellType, varSource, iClass + pcBonus);
}
Aggregations