Esempio n. 1
0
  public List<Ability> getClanLevelEffectsList(final MOB mob, final Integer level) {
    if (clanEffectNames == null) return empty;

    if ((clanEffectMap == null)
        && (clanEffectNames != null)
        && (clanEffectLevels != null)
        && (clanEffectParms != null)) clanEffectMap = new Hashtable<Integer, List<Ability>>();

    if (clanEffectMap == null) return empty;

    if (clanEffectMap.containsKey(level)) return clanEffectMap.get(level);
    final CMObjUniqSortSVec<Ability> finalV = new CMObjUniqSortSVec<Ability>();
    for (int v = 0; v < clanEffectLevels.length; v++) {
      if ((clanEffectLevels[v] <= level.intValue())
          && (clanEffectNames.length > v)
          && (clanEffectParms.length > v)) {
        Ability A = CMClass.getAbility(clanEffectNames[v]);
        if (A != null) {
          // mob was set to null here to make the cache map actually relevant .. see caching below
          A.setProficiency(CMLib.ableMapper().getMaxProficiency((MOB) null, true, A.ID()));
          A.setMiscText(clanEffectParms[v]);
          A.makeNonUninvokable();
          A.setSavable(false); // must go AFTER the ablve
          finalV.add(A);
        }
      }
    }
    finalV.trimToSize();
    clanEffectMap.put(level, finalV);
    return finalV;
  }
Esempio n. 2
0
  public ChameleonList<Ability> getClanLevelEffects(final MOB mob, final Integer level) {
    if (level == null) return getEmptyClanLevelEffects(mob);
    final DefaultClanGovernment myGovt = this;
    final List<Ability> myList = getClanLevelEffectsList(mob, level);
    final List<Ability> finalV = new Vector<Ability>(myList.size());
    for (final Ability A : myList) {
      Ability finalA = (Ability) A.copyOf();
      finalA.makeNonUninvokable();
      finalA.setSavable(false); // must come AFTER the above
      finalA.setAffectedOne(mob);
      finalV.add(finalA);
    }
    final ChameleonList<Ability> finalFinalV;
    if (mob == null) {
      finalFinalV =
          new ChameleonList<Ability>(
              finalV,
              new ChameleonList.Signaler<Ability>(myList) {
                public boolean isDeprecated() {
                  return false;
                }

                public void rebuild(final ChameleonList<Ability> me) {}
              });
    } else {
      finalFinalV =
          new ChameleonList<Ability>(
              finalV,
              new ChameleonList.Signaler<Ability>(myList) {
                public boolean isDeprecated() {
                  if ((mob == null) || (mob.amDestroyed())) return true;
                  final Clan C = mob.getMyClan();
                  if (C == null) return true;
                  if ((C.getGovernment() != myGovt)
                      || (getClanLevelEffectsList(mob, Integer.valueOf(C.getClanLevel()))
                          != oldReferenceListRef.get())) return true;
                  return false;
                }

                public void rebuild(final ChameleonList<Ability> me) {

                  final Clan C = (mob != null) ? mob.getMyClan() : null;
                  if ((mob == null) || (mob.amDestroyed()) || (C == null))
                    me.changeMeInto(getEmptyClanLevelEffects(mob));
                  else
                    me.changeMeInto(
                        C.getGovernment()
                            .getClanLevelEffects(mob, Integer.valueOf(C.getClanLevel())));
                }
              });
    }
    return finalFinalV;
  }