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;
}
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;
}
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 };
}
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");
}
}
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());
}
Aggregations