Search in sources :

Example 16 with ClassSource

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();
    }
}
Also used : PCLevelInfo(pcgen.core.pclevelinfo.PCLevelInfo) Domain(pcgen.core.Domain) PCClass(pcgen.core.PCClass) ClassSource(pcgen.cdom.helper.ClassSource)

Example 17 with ClassSource

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);
}
Also used : PCClass(pcgen.core.PCClass) ClassSource(pcgen.cdom.helper.ClassSource)

Example 18 with ClassSource

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);
}
Also used : PCClass(pcgen.core.PCClass) ClassSource(pcgen.cdom.helper.ClassSource)

Example 19 with ClassSource

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();
    }
}
Also used : Domain(pcgen.core.Domain) ClassSource(pcgen.cdom.helper.ClassSource)

Example 20 with ClassSource

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);
}
Also used : Domain(pcgen.core.Domain) PCClass(pcgen.core.PCClass) ClassSource(pcgen.cdom.helper.ClassSource)

Aggregations

ClassSource (pcgen.cdom.helper.ClassSource)31 PCClass (pcgen.core.PCClass)19 Domain (pcgen.core.Domain)18 Test (org.junit.Test)9 AbstractTokenModelTest (tokenmodel.testsupport.AbstractTokenModelTest)6 ParseResult (pcgen.rules.persistence.token.ParseResult)5 PlayerCharacter (pcgen.core.PlayerCharacter)4 CNAbility (pcgen.cdom.content.CNAbility)3 Ability (pcgen.core.Ability)3 CharacterSpell (pcgen.core.character.CharacterSpell)3 Spell (pcgen.core.spell.Spell)3 PreParserFactory (pcgen.persistence.lst.prereq.PreParserFactory)3 AssociatedPrereqObject (pcgen.cdom.base.AssociatedPrereqObject)2 CDOMReference (pcgen.cdom.base.CDOMReference)2 Type (pcgen.cdom.enumeration.Type)2 SpellSchool (pcgen.cdom.identifier.SpellSchool)2 DomainSpellList (pcgen.cdom.list.DomainSpellList)2 PCLevelInfo (pcgen.core.pclevelinfo.PCLevelInfo)2 MessageType (pcgen.core.utils.MessageType)2 AttackType (pcgen.util.enumeration.AttackType)2