Search in sources :

Example 21 with Deity

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

the class DeityWeaponToken method getCollection.

@Override
public <R> Collection<R> getCollection(PlayerCharacter pc, Converter<WeaponProf, R> c) {
    Deity deity = pc.getDisplay().getDeity();
    if (deity == null) {
        return Collections.emptySet();
    }
    HashSet<R> set = new HashSet<>();
    List<CDOMReference<WeaponProf>> dwp = deity.getSafeListFor(ListKey.DEITYWEAPON);
    for (CDOMReference<WeaponProf> ref : dwp) {
        set.addAll(c.convert(ref));
    }
    return set;
}
Also used : Deity(pcgen.core.Deity) WeaponProf(pcgen.core.WeaponProf) CDOMReference(pcgen.cdom.base.CDOMReference) HashSet(java.util.HashSet)

Example 22 with Deity

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

the class DeityToken method getCollection.

@Override
public <R> Collection<R> getCollection(PlayerCharacter pc, Converter<Domain, R> c) {
    HashSet<R> returnSet = new HashSet<>();
    Deity deity = pc.getDisplay().getDeity();
    if (deity == null) {
        return returnSet;
    }
    CDOMReference<DomainList> list = Deity.DOMAINLIST;
    Collection<CDOMReference<Domain>> mods = deity.getListMods(list);
    for (CDOMReference<Domain> ref : mods) {
        Collection<AssociatedPrereqObject> assoc = deity.getListAssociations(list, ref);
        for (AssociatedPrereqObject apo : assoc) {
            if (PrereqHandler.passesAll(apo.getPrerequisiteList(), pc, deity)) {
                returnSet.addAll(c.convert(ref));
                break;
            }
        }
    }
    return returnSet;
}
Also used : Deity(pcgen.core.Deity) DomainList(pcgen.cdom.list.DomainList) Domain(pcgen.core.Domain) CDOMReference(pcgen.cdom.base.CDOMReference) HashSet(java.util.HashSet) AssociatedPrereqObject(pcgen.cdom.base.AssociatedPrereqObject)

Example 23 with Deity

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

the class DeityWeaponProfFacetTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    Deity cdo1 = new Deity();
    cdo1.setName("Deity1");
    Deity cdo2 = new Deity();
    cdo2.setName("Deity2");
    WeaponProf st1 = new WeaponProf();
    st1.setName("Prof1");
    WeaponProf st2 = new WeaponProf();
    st1.setName("Prof2");
    cdo1.addToListFor(ListKey.DEITYWEAPON, CDOMDirectSingleRef.getRef(st1));
    cdo2.addToListFor(ListKey.DEITYWEAPON, CDOMDirectSingleRef.getRef(st2));
    source = new Deity[] { cdo1, cdo2 };
    target = new WeaponProf[] { st1, st2 };
}
Also used : Deity(pcgen.core.Deity) WeaponProf(pcgen.core.WeaponProf)

Example 24 with Deity

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

the class NPCGenerator method selectDeity.

private void selectDeity(final PlayerCharacter aPC, final PCClass aClass) {
    // Copy the list since we may modify it
    final WeightedCollection<Deity> deities = new WeightedCollection<>(theConfiguration.getDeityWeights(aClass.getKeyName()));
    boolean selected = false;
    while (!deities.isEmpty()) {
        final Deity deity = deities.getRandomValue();
        if (aPC.canSelectDeity(deity)) {
            aPC.setDeity(deity);
            selected = true;
            break;
        }
        deities.remove(deity);
    }
    if (!selected) {
        //$NON-NLS-1$
        Logging.errorPrintLocalised("NPCGen.Errors.CantSelectDeity");
    }
}
Also used : Deity(pcgen.core.Deity) WeightedCollection(pcgen.base.util.WeightedCollection)

Example 25 with Deity

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

the class PreDomainTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    Domain goodDomain = new Domain();
    goodDomain.setName("Good");
    Globals.getContext().getReferenceContext().importObject(goodDomain);
    Domain animalDomain = new Domain();
    animalDomain.setName("Animal");
    Globals.getContext().getReferenceContext().importObject(animalDomain);
    deity = new Deity();
    deity.setName("Test Deity");
    deity.put(ObjectKey.ALIGNMENT, CDOMDirectSingleRef.getRef(ng));
    deity.putToList(Deity.DOMAINLIST, CDOMDirectSingleRef.getRef(goodDomain), new SimpleAssociatedObject());
    deity.putToList(Deity.DOMAINLIST, CDOMDirectSingleRef.getRef(animalDomain), new SimpleAssociatedObject());
}
Also used : Deity(pcgen.core.Deity) Domain(pcgen.core.Domain) SimpleAssociatedObject(pcgen.cdom.base.SimpleAssociatedObject)

Aggregations

Deity (pcgen.core.Deity)39 CDOMReference (pcgen.cdom.base.CDOMReference)8 Domain (pcgen.core.Domain)8 Test (org.junit.Test)5 WeaponProf (pcgen.core.WeaponProf)5 HashSet (java.util.HashSet)3 TreeSet (java.util.TreeSet)3 StringManager (pcgen.base.format.StringManager)3 PCAlignment (pcgen.core.PCAlignment)3 BigDecimal (java.math.BigDecimal)2 ArrayList (java.util.ArrayList)2 StringTokenizer (java.util.StringTokenizer)2 AssociatedPrereqObject (pcgen.cdom.base.AssociatedPrereqObject)2 SimpleAssociatedObject (pcgen.cdom.base.SimpleAssociatedObject)2 LinkedHashSet (java.util.LinkedHashSet)1 Set (java.util.Set)1 NumberManager (pcgen.base.format.NumberManager)1 Indirect (pcgen.base.util.Indirect)1 WeightedCollection (pcgen.base.util.WeightedCollection)1 WrappedMapSet (pcgen.base.util.WrappedMapSet)1