コード例 #1
0
 public ICharm[] getExperienceLearnedCharms() {
   List<ICharm> allLearnedCharms = new ArrayList<ICharm>();
   for (ILearningCharmGroup group : getAllGroups()) {
     Collections.addAll(allLearnedCharms, group.getExperienceLearnedCharms());
   }
   return allLearnedCharms.toArray(new ICharm[allLearnedCharms.size()]);
 }
コード例 #2
0
 @Override
 public ICharm[] getLearnedCharms(boolean experienced) {
   List<ICharm> allLearnedCharms = new ArrayList<ICharm>();
   for (ILearningCharmGroup group : getAllGroups()) {
     Collections.addAll(allLearnedCharms, group.getCreationLearnedCharms());
     if (experienced) {
       Collections.addAll(allLearnedCharms, group.getExperienceLearnedCharms());
     }
   }
   return allLearnedCharms.toArray(new ICharm[allLearnedCharms.size()]);
 }
コード例 #3
0
 public void unlearnAllAlienCharms() {
   for (ILearningCharmGroup[] groups : nonMartialArtsGroupsByType.values()) {
     for (ILearningCharmGroup group : groups) {
       if (group.getCharacterType() != getNativeCharacterType()) {
         group.forgetAll();
       }
     }
   }
   for (ILearningCharmGroup group : martialArtsGroups) {
     group.unlearnExclusives();
   }
 }
コード例 #4
0
 private ILearningCharmGroup getGroupById(ICharacterType characterType, String groupId) {
   List<ILearningCharmGroup> candidateGroups = new ArrayList<ILearningCharmGroup>();
   Collections.addAll(candidateGroups, getCharmGroups(characterType));
   Collections.addAll(candidateGroups, getMartialArtsGroups());
   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$
 }
コード例 #5
0
 private void verifyCharms() {
   if (!context.isFullyLoaded()) {
     return;
   }
   List<ICharm> charmsToUnlearn = new ArrayList<ICharm>();
   for (ICharm charm : this.getLearnedCharms(true)) {
     boolean prerequisitesForCharmAreNoLongerMet = !isLearnable(charm);
     boolean charmCanBeUnlearned = isUnlearnable(charm);
     if (prerequisitesForCharmAreNoLongerMet && charmCanBeUnlearned) {
       charmsToUnlearn.add(charm);
     }
   }
   for (ICharm charm : charmsToUnlearn) {
     ILearningCharmGroup group = learningCharmGroupContainer.getLearningCharmGroup(charm);
     boolean learnedAtCreation = group.isLearned(charm, false);
     boolean learnedWithExperience = !learnedAtCreation;
     group.forgetCharm(charm, learnedWithExperience);
   }
 }
コード例 #6
0
 public final boolean isLearned(ICharm charm) {
   ILearningCharmGroup group = getGroup(charm);
   return group != null && group.isLearned(charm);
 }
コード例 #7
0
 protected boolean isUnlearnableWithoutConsequences(ICharm charm) {
   final ILearningCharmGroup group = getGroup(charm);
   return group.isUnlearnableWithoutConsequences(charm);
 }
コード例 #8
0
 public final boolean isUnlearnable(ICharm charm) {
   final ILearningCharmGroup group = getGroup(charm);
   return group.isUnlearnable(charm);
 }
コード例 #9
0
  private ILearningCharmGroup[] createGroups(ICharmGroup[] charmGroups) {
    List<ILearningCharmGroup> newGroups = new ArrayList<ILearningCharmGroup>();
    ICharmLearnListener mergedListener =
        new CharmLearnAdapter() {
          @Override
          public void charmLearned(ICharm charm) {
            for (ICharm mergedCharm : charm.getMergedCharms()) {
              if (!isLearned(mergedCharm)
                  && isLearnableWithoutPrereqs(mergedCharm)
                  && CharmConfiguration.this.getSpecialCharmConfiguration(mergedCharm) == null) {
                getGroup(mergedCharm)
                    .learnCharm(mergedCharm, context.getBasicCharacterContext().isExperienced());
              }
            }

            for (ICharm child : charm.getLearnChildCharms()) {
              boolean learnedMerged = false;
              for (ICharm mergedCharm : child.getMergedCharms())
                learnedMerged = learnedMerged || isLearned(mergedCharm);
              if (learnedMerged && isLearnable(child))
                getGroup(child)
                    .learnCharm(child, context.getBasicCharacterContext().isExperienced());
            }
          }

          @Override
          public void charmForgotten(ICharm charm) {
            boolean forgetMerges = true;
            for (ICharm parentCharm : charm.getParentCharms())
              forgetMerges = forgetMerges && isLearned(parentCharm);
            if (forgetMerges)
              for (ICharm mergedCharm : charm.getMergedCharms()) {
                if (isLearned(mergedCharm) && isUnlearnableWithoutConsequences(mergedCharm)) {
                  getGroup(mergedCharm)
                      .forgetCharm(mergedCharm, context.getBasicCharacterContext().isExperienced());
                }
              }
          }

          @Override
          public void recalculateRequested() {
            for (ICharm charm : getLearnedCharms(true)) {
              boolean prereqsMet = true;
              for (ICharm parent : charm.getParentCharms())
                for (String subeffectRequirement : charm.getParentSubeffects())
                  if (getSubeffectParent(subeffectRequirement).equals(parent.getId())) {
                    ISpecialCharmConfiguration config =
                        getSpecialCharmConfiguration(getSubeffectParent(subeffectRequirement));
                    if (config instanceof IMultipleEffectCharmConfiguration) {
                      IMultipleEffectCharmConfiguration mConfig =
                          (IMultipleEffectCharmConfiguration) config;
                      prereqsMet =
                          prereqsMet
                              && mConfig
                                  .getEffectById(getSubeffect(subeffectRequirement))
                                  .isLearned();
                    }
                    if (config instanceof IMultiLearnableCharmConfiguration) {
                      IMultiLearnableCharmConfiguration mConfig =
                          (IMultiLearnableCharmConfiguration) config;
                      String effect = getSubeffect(subeffectRequirement);
                      int requiredCount = Integer.parseInt(effect.replace("Repurchase", ""));
                      prereqsMet = mConfig.getCurrentLearnCount() >= requiredCount;
                    }
                  }
              if (!prereqsMet)
                getGroup(charm)
                    .forgetCharm(charm, context.getBasicCharacterContext().isExperienced());
            }
          }
        };
    for (ICharmGroup charmGroup : charmGroups) {
      ILearningCharmGroup group =
          new LearningCharmGroup(
              getLearnStrategy(), charmGroup, this, learningCharmGroupContainer, this);
      newGroups.add(group);

      group.addCharmLearnListener(mergedListener);
    }
    return newGroups.toArray(new LearningCharmGroup[newGroups.size()]);
  }
コード例 #10
0
 public void addCharmLearnListener(ICharmLearnListener listener) {
   for (ILearningCharmGroup group : getAllGroups()) {
     group.addCharmLearnListener(listener);
   }
 }