Search in sources :

Example 66 with Domain

use of pcgen.core.Domain in project pcgen by PCGen.

the class TestHelper method makeDomain.

/**
	 * Set the important info about a Domain
	 * @param name The domain name
	 * @return The domain (which has also been added to global storage)
	 */
public static Domain makeDomain(final String name) {
    final Domain domain = new Domain();
    domain.setName(name);
    domain.put(StringKey.KEY_NAME, (name));
    Globals.getContext().getReferenceContext().importObject(domain);
    return domain;
}
Also used : Domain(pcgen.core.Domain)

Example 67 with Domain

use of pcgen.core.Domain in project pcgen by PCGen.

the class DomainTokenTest method testUnparseMultiple.

@Test
public void testUnparseMultiple() throws PersistenceLayerException {
    Domain wp1 = construct(primaryContext, getLegalValue());
    primaryProf.addToListFor(ListKey.DOMAIN, buildQO(wp1));
    Domain wp2 = construct(primaryContext, getAlternateLegalValue());
    primaryProf.addToListFor(ListKey.DOMAIN, buildQO(wp2));
    String[] unparsed = getToken().unparse(primaryContext, primaryProf);
    expectSingle(unparsed, getLegalValue() + getJoinCharacter() + getAlternateLegalValue());
}
Also used : Domain(pcgen.core.Domain) Test(org.junit.Test)

Example 68 with Domain

use of pcgen.core.Domain in project pcgen by PCGen.

the class CharacterSpell method isSpecialtySpell.

/**
	 * is speciality spell
	 * @return TRUE if speciality spell
	 */
public boolean isSpecialtySpell(PlayerCharacter pc) {
    final boolean result;
    if (spell == null) {
        result = false;
    } else if (owner instanceof Domain) {
        result = true;
    } else if (owner instanceof PCClass) {
        final PCClass a = (PCClass) owner;
        result = SpellCountCalc.isSpecialtySpell(pc, a, spell);
    } else {
        result = false;
    }
    return result;
}
Also used : Domain(pcgen.core.Domain) PCClass(pcgen.core.PCClass)

Example 69 with Domain

use of pcgen.core.Domain in project pcgen by PCGen.

the class DomainApplication method removeDomainsForLevel.

public static void removeDomainsForLevel(PCClass cl, final int removedLevel, final PlayerCharacter aPC) {
    /*
		 * Note this uses ALL of the domains up to and including this level,
		 * because there is the possibility (albeit strange) that the PC was
		 * qualified at a previous level change, but the PlayerCharacter is now
		 * not qualified for the given Domain. Even this has quirks, since it is
		 * only applied at the time of level increase, but I think that quirk
		 * should be resolved by a CDOM system around 6.0 - thpr 10/23/06
		 */
    for (QualifiedObject<CDOMSingleRef<Domain>> qo : cl.getSafeListFor(ListKey.DOMAIN)) {
        CDOMSingleRef<Domain> ref = qo.getObject(aPC, cl);
        if (ref == null) {
            ref = qo.getRawObject();
            aPC.removeDomain(ref.get());
        }
    }
    for (int i = 0; i <= removedLevel; i++) {
        // TODO This stinks for really high level characters - can this ever
        // get null back?
        PCClassLevel pcl = aPC.getActiveClassLevel(cl, i);
        for (QualifiedObject<CDOMSingleRef<Domain>> qo : pcl.getSafeListFor(ListKey.DOMAIN)) {
            CDOMSingleRef<Domain> ref = qo.getObject(aPC, cl);
            if ((ref == null) || (i == removedLevel)) {
                ref = qo.getRawObject();
                aPC.removeDomain(ref.get());
            }
        }
    }
}
Also used : Domain(pcgen.core.Domain) CDOMSingleRef(pcgen.cdom.reference.CDOMSingleRef) PCClassLevel(pcgen.cdom.inst.PCClassLevel)

Example 70 with Domain

use of pcgen.core.Domain in project pcgen by PCGen.

the class PCGVer2Creator method appendDomainLines.

private void appendDomainLines(StringBuilder buffer) {
    for (final Domain domain : charDisplay.getDomainSet()) {
        // TODO is any of this commented out code any use anymore?:
        //
        //  			// improve here - performance and concept!!!!
        //  			domainSpells.clear();
        //  			for (Iterator it2 = Globals.getSpellMap().values().iterator(); it2.hasNext();)
        //  			{
        //  				aSpell = (Spell)it2.next();
        //  //			levelString = aSpell.levelForClass(aDomain.getName());
        //  				if ((levelString.length() > 0) &&
        //  				  (levelString.indexOf("-1") < 0))
        //  				{
        //  					tokens = new StringTokenizer(levelString, ",");
        //  					while (tokens.hasMoreTokens())
        //  					{
        //  						if (tokens.nextToken().equals(aDomain.getName()))
        //  						{
        //  							break;
        //  						}
        //  					}
        //  					domainSpells.add(((tokens.hasMoreTokens()) ? tokens.nextToken() + " " : "") +
        //  					  aSpell.getName());
        //  				}
        //  			}
        buffer.append(IOConstants.TAG_DOMAIN).append(':');
        buffer.append(EntityEncoder.encode(domain.getKeyName()));
        for (String assoc : thePC.getAssociationList(domain)) {
            buffer.append('|');
            buffer.append(IOConstants.TAG_ASSOCIATEDDATA).append(':');
            buffer.append(EntityEncoder.encode(assoc));
        }
        for (final Description desc : domain.getSafeListFor(ListKey.DESCRIPTION)) {
            buffer.append('|');
            buffer.append(IOConstants.TAG_DOMAINGRANTS).append(':');
            buffer.append(desc.getPCCText());
        }
        buffer.append('|');
        appendSourceInTaggedFormat(buffer, getDomainSourcePcgString(domain));
        //			buffer.append('|');
        //			buffer.append(TAG_DOMAINFEATS).append(':');
        //			buffer.append(aDomain.getFeatList());
        //			buffer.append('|');
        //			buffer.append(TAG_DOMAINSKILLS).append(':');
        //			buffer.append(aDomain.getSkillList());
        //			buffer.append('|');
        //			buffer.append(TAG_DOMAINSPECIALS).append(':');
        //			buffer.append(aDomain.getSpecialAbility());
        //			buffer.append('|');
        //			buffer.append(TAG_DOMAINSPELLS).append(':');
        //			buffer.append(aDomain.getSpellList());
        appendAddTokenInfo(buffer, domain);
        buffer.append(IOConstants.LINE_SEP);
    /*
			 * not working yet anyways
			 *
			 * author: Thomas Behr 09-09-02
			 */
    //  			buffer.append(TAG_DOMAINSPELLS).append(':');
    //  			buffer.append(EntityEncoder.encode(aDomain.getKeyName()));
    //  			buffer.append('|');
    //  			buffer.append(TAG_SPELLLIST).append(':');
    //			buffer.append('[');
    //  			del = "";
    //  			Collections.sort(domainSpells);
    //  			for (Iterator it2 = domainSpells.iterator(); it2.hasNext();)
    //  			{
    //  				buffer.append(del);
    //  				buffer.append(TAG_SPELL).append(':');
    //				buffer.append(EntityEncoder.encode((String)it2.next()));
    //  				del = "|";
    //  			}
    //			buffer.append(']');
    //  			buffer.append(LINE_SEP);
    }
}
Also used : Description(pcgen.core.Description) Domain(pcgen.core.Domain)

Aggregations

Domain (pcgen.core.Domain)79 PCClass (pcgen.core.PCClass)31 Test (org.junit.Test)19 ClassSource (pcgen.cdom.helper.ClassSource)18 ArrayList (java.util.ArrayList)11 CDOMSingleRef (pcgen.cdom.reference.CDOMSingleRef)10 Prerequisite (pcgen.core.prereq.Prerequisite)10 AssociatedPrereqObject (pcgen.cdom.base.AssociatedPrereqObject)8 CDOMReference (pcgen.cdom.base.CDOMReference)8 Deity (pcgen.core.Deity)7 Spell (pcgen.core.spell.Spell)7 AbstractTokenModelTest (tokenmodel.testsupport.AbstractTokenModelTest)7 StringTokenizer (java.util.StringTokenizer)6 Ability (pcgen.core.Ability)6 QualifiedObject (pcgen.core.QualifiedObject)6 ParseResult (pcgen.rules.persistence.token.ParseResult)6 TreeSet (java.util.TreeSet)5 PlayerCharacter (pcgen.core.PlayerCharacter)5 PCClassLevel (pcgen.cdom.inst.PCClassLevel)4 ClassSpellList (pcgen.cdom.list.ClassSpellList)4