private void initUniqueTypes(ICharmTemplate charmTemplate) { if (!charmTemplate.hasUniqueCharms()) { return; } IUniqueCharmType type = charmTemplate.getUniqueCharmType(); CharmTree charmTree = new CharmTree(charmTemplate.getUniqueCharms()); ILearningCharmGroup[] groups = createGroups(charmTree.getAllCharmGroups()); nonMartialArtsGroupsByType.put(type.getId(), groups); alienTreesByType.put(type.getId(), charmTree); }
private ILearningCharmGroup getGroupById(ICharacterType characterType, String groupId) { List<ILearningCharmGroup> candidateGroups = new ArrayList<ILearningCharmGroup>(); Collections.addAll(candidateGroups, getCharmGroups(characterType)); Collections.addAll(candidateGroups, getMartialArtsGroups()); ICharmTemplate charmTemplate = templatesByType.get(characterType); if (charmTemplate.hasUniqueCharms()) { IUniqueCharmType uniqueType = charmTemplate.getUniqueCharmType(); Collections.addAll(candidateGroups, getCharmGroups(uniqueType.getId())); } for (ILearningCharmGroup group : candidateGroups) { if (group.getId().equals(groupId)) { return group; } } throw new IllegalArgumentException( "No charm group defined for Id: " + groupId + "," + characterType); //$NON-NLS-1$ //$NON-NLS-2$ }
@Override public ICharm getCharmById(String charmId) { charmId = getCharmTrueName(charmId); ICharm charm = martialArtsCharmTree.getCharmById(charmId); if (charm != null) { return charm; } ICharacterType characterType = getCharacterType(charmId); charm = getCharmTree(characterType).getCharmById(charmId); if (charm != null) { return charm; } ICharmTemplate charmTemplate = templatesByType.get(getNativeCharacterType()); if (charmTemplate.hasUniqueCharms()) { IUniqueCharmType uniqueType = charmTemplate.getUniqueCharmType(); charm = getCharmTree(uniqueType.getId()).getCharmById(charmId); if (charm != null) { return charm; } } throw new IllegalArgumentException( "No charm found for id \"" + charmId + "\""); // $NON-NLS-1$ //$NON-NLS-2$ }