use of pcgen.core.Language in project pcgen by PCGen.
the class StartingLanguageFacet method dataAdded.
/**
* Adds available Languages to this facet when a CDOMObject added to a
* Player Character makes Languages available to the Player Character.
*
* Triggered when one of the Facets to which StartingLanguageFacet listens
* fires a DataFacetChangeEvent to indicate a CDOMObject was added to a
* Player Character.
*
* @param dfce
* The DataFacetChangeEvent containing the information about the
* change
*
* @see pcgen.cdom.facet.event.DataFacetChangeListener#dataAdded(pcgen.cdom.facet.event.DataFacetChangeEvent)
*/
@Override
public void dataAdded(DataFacetChangeEvent<CharID, CDOMObject> dfce) {
CDOMObject cdo = dfce.getCDOMObject();
Collection<CDOMReference<Language>> list = cdo.getListMods(Language.STARTING_LIST);
if (list != null) {
CharID id = dfce.getCharID();
for (CDOMReference<Language> ref : list) {
addAll(id, ref.getContainedObjects(), cdo);
}
}
}
use of pcgen.core.Language in project pcgen by PCGen.
the class PCGVer2Parser method parseLanguageLine.
/*
* ###############################################################
* Character Languages methods
* ###############################################################
*/
private void parseLanguageLine(final String line) {
final PCGTokenizer tokens;
try {
tokens = new PCGTokenizer(line);
} catch (PCGParseException pcgpex) {
final String msg = LanguageBundle.getFormattedString(//$NON-NLS-1$
"Warnings.PCGenParser.IllegalLanguage", line, pcgpex.getMessage());
warnings.add(msg);
return;
}
for (PCGElement element : tokens.getElements()) {
final Language aLang = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Language.class, EntityEncoder.decode(element.getText()));
if (aLang == null) {
final String message = //$NON-NLS-1$
"No longer speaks language: " + element.getText();
warnings.add(message);
continue;
}
cachedLanguages.add(aLang);
}
}
use of pcgen.core.Language in project pcgen by PCGen.
the class PCGVer2Creator method appendLanguageLine.
/*
* ###############################################################
* Character Language methods
* ###############################################################
*/
private void appendLanguageLine(StringBuilder buffer) {
String del = Constants.EMPTY_STRING;
TreeSet<Language> sortedlangs = new TreeSet(charDisplay.getLanguageSet());
for (final Language lang : sortedlangs) {
buffer.append(del);
buffer.append(IOConstants.TAG_LANGUAGE).append(':');
buffer.append(EntityEncoder.encode(lang.getKeyName()));
//$NON-NLS-1$
del = "|";
}
buffer.append(IOConstants.LINE_SEP);
}
use of pcgen.core.Language in project pcgen by PCGen.
the class PCGVer2Parser method processRemoval.
private void processRemoval(CNAbility langbonus, HashMapToList<Language, Object> sources, Map<Object, Integer> actorLimit, Map<PersistentTransitionChoice, CDOMObject> ptcSources, Language l, Object actor) {
Integer limit = actorLimit.get(actor);
//apply
processActor(langbonus, ptcSources, l, actor);
cachedLanguages.remove(l);
sources.removeListFor(l);
//Remove this sources from all languages (may create more items with only one source)
if (limit == 1) {
for (Language lang : sources.getKeySet()) {
sources.removeFromListFor(lang, actor);
}
//Used up
actorLimit.remove(actor);
} else {
//Use a slot
actorLimit.put(actor, limit - 1);
}
}
use of pcgen.core.Language in project pcgen by PCGen.
the class AbstractGlobalTargetedSaveRestoreTest method testAutoLanguage.
@Test
public void testAutoLanguage() {
T target = create(getObjectClass(), "Target");
Language granted = create(Language.class, "Granted");
create(Language.class, "Ignored");
new plugin.lsttokens.auto.LangToken().parseToken(context, target, "Granted");
Object o = prepare(target);
finishLoad();
assertFalse(pc.hasLanguage(granted));
applyObject(target);
assertTrue(pc.hasLanguage(granted));
runRoundRobin(getPreEqualityCleanup());
assertTrue(pc.hasLanguage(granted));
assertTrue(reloadedPC.hasLanguage(granted));
remove(o);
reloadedPC.setDirty(true);
assertFalse(reloadedPC.hasLanguage(granted));
}
Aggregations