MCPcopy Create free account
hub / github.com/PCGen/pcgen / resolveLanguages

Method resolveLanguages

code/src/java/pcgen/io/PCGVer2Parser.java:5686–5776  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5684 private static final Class<Language> LANGUAGE_CLASS = Language.class;
5685
5686 private void resolveLanguages()
5687 {
5688 CNAbility langbonus = thePC.getBonusLanguageAbility();
5689 int currentBonusLang = thePC.getDetailedAssociationCount(langbonus);
5690 boolean foundLang = currentBonusLang > 0;
5691
5692 Set<Language> foundLanguages = new HashSet<>(thePC.getLanguageSet());
5693 //Captures Auto (AUTO:LANG) and Persistent choices (ADD ex ability and CHOOSE)
5694 cachedLanguages.removeAll(foundLanguages);
5695
5696 HashMapToList<Language, Object> langSources = new HashMapToList<>();
5697 Map<Object, Integer> actorLimit = new IdentityHashMap<>();
5698 Map<PersistentTransitionChoice, CDOMObject> ptcSources = new IdentityHashMap<>();
5699
5700 List<? extends CDOMObject> abilities = thePC.getCDOMObjectList();
5701 for (CDOMObject a : abilities)
5702 {
5703 List<PersistentTransitionChoice<?>> addList = a.getListFor(ListKey.ADD);
5704 if (addList != null)
5705 {
5706 for (PersistentTransitionChoice<?> ptc : addList)
5707 {
5708 SelectableSet<?> ss = ptc.getChoices();
5709 if (ss.getName().equals("LANGUAGE") && LANGUAGE_CLASS.equals(ss.getChoiceClass()))
5710 {
5711 Collection<Language> selected = (Collection<Language>) ss.getSet(thePC);
5712 for (Language l : selected)
5713 {
5714 if (cachedLanguages.contains(l))
5715 {
5716 String source = SourceFormat.getFormattedString(a, Globals.getSourceDisplay(), true);
5717 int choiceCount = ptc.getCount().resolve(thePC, source).intValue();
5718 if (choiceCount > 0)
5719 {
5720 langSources.addToListFor(l, ptc);
5721 ptcSources.put(ptc, a);
5722 actorLimit.put(ptc, choiceCount);
5723 }
5724 }
5725 }
5726 }
5727 }
5728 }
5729 }
5730 if (!foundLang)
5731 {
5732 Set<Language> bonusAllowed = thePC.getLanguageBonusSelectionList();
5733 int count = thePC.getBonusLanguageCount();
5734 int choiceCount = count - currentBonusLang;
5735 if (choiceCount > 0)
5736 {
5737 for (Language l : bonusAllowed)
5738 {
5739 if (cachedLanguages.contains(l))
5740 {
5741 langSources.addToListFor(l, langbonus);
5742 actorLimit.put(langbonus, choiceCount);
5743 }

Callers 1

parsePCGMethod · 0.95

Calls 15

getFormattedStringMethod · 0.95
getSourceDisplayMethod · 0.95
processRemovalMethod · 0.95
getCDOMObjectListMethod · 0.80
intValueMethod · 0.80
getBonusLanguageCountMethod · 0.80
removeAllMethod · 0.65
getListForMethod · 0.65
getChoicesMethod · 0.65
equalsMethod · 0.65

Tested by

no test coverage detected