Exemple #1
0
 private ISpell[] getCircleFilteredSpellList(ISpell[] spells) {
   List<ISpell> spellList = new ArrayList<>();
   for (ISpell spell : spells) {
     if (ArrayUtils.contains(spellModel.getCircles(), spell.getCircleType())) {
       spellList.add(spell);
     }
   }
   return spellList.toArray(new ISpell[spellList.size()]);
 }
Exemple #2
0
  public void initPresentation() {
    Identifier[] allowedCircles = spellModel.getCircles();
    view.initGui(allowedCircles);
    view.addMagicViewListener(
        new IMagicViewListener() {
          @Override
          public void magicRemoved(Object[] removedSpells) {
            List<ISpell> spellList = new ArrayList<>();
            for (Object spellObject : removedSpells) {
              spellList.add((ISpell) spellObject);
            }
            spellConfiguration.removeSpells(spellList.toArray(new ISpell[spellList.size()]));
          }

          @Override
          public void magicAdded(Object[] addedSpells) {
            List<ISpell> spellList = new ArrayList<>();
            for (Object spellObject : addedSpells) {
              if (spellConfiguration.isSpellAllowed((ISpell) spellObject)) {
                spellList.add((ISpell) spellObject);
              }
            }
            spellConfiguration.addSpells(spellList.toArray(new ISpell[spellList.size()]));
          }
        });
    view.addCircleSelectionListener(
        new ObjectValueListener<CircleType>() {
          @Override
          public void valueChanged(CircleType circleType) {
            circle = circleType;
            view.setMagicOptions(getSpellsToShow());
          }
        });
    spellConfiguration.addMagicLearnListener(
        new IMagicLearnListener<ISpell>() {
          @Override
          public void magicForgotten(ISpell[] magic) {
            forgetSpellListsInView(view, magic);
          }

          @Override
          public void magicLearned(ISpell[] magic) {
            learnSpellListsInView(view, magic);
          }
        });
    initSpellListsInView(view);
    ExperienceModelFetcher.fetch(hero)
        .addStateChangeListener(
            new ChangeListener() {
              @Override
              public void changeOccurred() {
                view.clearSelection();
              }
            });
  }
Exemple #3
0
 public SpellPresenter(
     net.sf.anathema.character.presenter.magic.spells.SpellModel spellModel,
     Hero hero,
     Resources resources,
     ISpellView view,
     MagicDescriptionProvider magicDescriptionProvider) {
   this.spellModel = spellModel;
   this.hero = hero;
   SpellViewProperties properties =
       new SpellViewProperties(resources, hero, magicDescriptionProvider);
   this.resources = resources;
   this.spellConfiguration = SpellsModelFetcher.fetch(hero);
   this.view = view;
   view.prepare(properties);
   circle = spellModel.getCircles()[0];
 }