use of pcgen.core.character.CompanionMod in project pcgen by PCGen.
the class CompanionModLoader method getLoadable.
@Override
protected CompanionMod getLoadable(LoadContext context, String firstToken, URI sourceURI) throws PersistenceLayerException {
String name = processFirstToken(context, firstToken);
if (name == null) {
return null;
}
//Always create a new CompanionMod (no Copy Mod or Forget)
//But we need to create a unique name (and do it with something that is unique-ish)
//Note there is currently no risk of name conflict here since they cannot be uniquely named
String uniqueName = "COMPANIONMOD_" + COMPANION_MOD_ID++;
CompanionMod mod = super.getLoadable(context, uniqueName, sourceURI);
//Process the first token since it's not really a name...
LstUtils.processToken(context, mod, sourceURI, firstToken);
return mod;
}
use of pcgen.core.character.CompanionMod in project pcgen by PCGen.
the class GlobalQualifyTest method testFromCompanionMod.
@Override
@Test
public void testFromCompanionMod() throws PersistenceLayerException {
CompanionMod source = create(CompanionMod.class, "Source");
ParseResult result = token.parseToken(context, source, "RACE|Dwarf");
assertFalse(result.passed());
}
use of pcgen.core.character.CompanionMod in project pcgen by PCGen.
the class PlayerCharacter method getEffectiveCompanionLevel.
/**
* This method returns the effective level of this character for purposes of
* applying companion mods to a companion of the specified type.
* <p>
* <b>Note</b>: This whole structure is kind of messed up since nothing
* enforces that a companion mod of a given type always looks at the same
* variable (either Class or Variable). Note it seems that this used to
* be driven off types but now it's driven from a list of companion mods
* but the java doc has not been updated.
*
* @param compList
* A list of companionMods to get level for
* @return The effective level for this companion type
*/
public int getEffectiveCompanionLevel(final CompanionList compList) {
for (CompanionMod cMod : Globals.getContext().getReferenceContext().getManufacturer(CompanionMod.class, compList).getAllObjects()) {
Map<String, Integer> varmap = cMod.getMapFor(MapKey.APPLIED_VARIABLE);
for (final String varName : varmap.keySet()) {
final int lvl = this.getVariableValue(varName, Constants.EMPTY_STRING).intValue();
if (lvl > 0) {
return lvl;
}
}
Map<CDOMSingleRef<? extends PCClass>, Integer> ac = cMod.getMapFor(MapKey.APPLIED_CLASS);
for (Map.Entry<CDOMSingleRef<? extends PCClass>, Integer> me : ac.entrySet()) {
PCClass pcclass = me.getKey().get();
String key = pcclass.getKeyName();
int lvl = getLevel(getClassKeyed(key));
if (lvl > 0) {
return lvl;
}
}
}
return 0;
}
use of pcgen.core.character.CompanionMod in project pcgen by PCGen.
the class PlayerCharacter method getOldFollowerLimit.
private int getOldFollowerLimit(CompanionList cList) {
// they can take unlimited number of them.
for (CompanionMod cMod : Globals.getContext().getReferenceContext().getManufacturer(CompanionMod.class, cList).getAllObjects()) {
Map<String, Integer> varmap = cMod.getMapFor(MapKey.APPLIED_VARIABLE);
for (String varName : varmap.keySet()) {
if (this.getVariableValue(varName, Constants.EMPTY_STRING).intValue() > 0) {
return -1;
}
}
Map<CDOMSingleRef<? extends PCClass>, Integer> ac = cMod.getMapFor(MapKey.APPLIED_CLASS);
for (Map.Entry<CDOMSingleRef<? extends PCClass>, Integer> me : ac.entrySet()) {
PCClass pcclass = me.getKey().get();
String key = pcclass.getKeyName();
for (PCClass pcClass : getClassSet()) {
if (pcClass.getKeyName().equals(key)) {
return me.getValue();
}
}
}
}
return 0;
}
use of pcgen.core.character.CompanionMod in project pcgen by PCGen.
the class RaceTypeFacetTest method testGetFromTemplateOverridesRaceandCMod.
@Test
public void testGetFromTemplateOverridesRaceandCMod() {
Race r = new Race();
r.put(ObjectKey.RACETYPE, TEST_RACE_TYPE);
rfacet.set(id, r);
assertSame(TEST_RACE_TYPE, facet.getRaceType(id));
CompanionMod c = new CompanionMod();
c.put(ObjectKey.RACETYPE, RACE_TYPE_TOO);
cfacet.add(id, c);
assertSame(RACE_TYPE_TOO, facet.getRaceType(id));
PCTemplate t = new PCTemplate();
t.put(ObjectKey.RACETYPE, LAST_RACE_TYPE);
tfacet.add(id, t, this);
assertSame(LAST_RACE_TYPE, facet.getRaceType(id));
tfacet.remove(id, t, this);
assertSame(RACE_TYPE_TOO, facet.getRaceType(id));
cfacet.remove(id, c);
assertSame(TEST_RACE_TYPE, facet.getRaceType(id));
}
Aggregations