private IEquipmentItem getSpecialManagedItem(String templateId) {
   for (IEquipmentItem item : naturalWeaponItems) {
     if (templateId.equals(item.getTemplateId())) {
       return item;
     }
   }
   return null;
 }
 @Override
 public int getMotesExpended() {
   int total = 0;
   for (IEquipmentItem item : equipmentItems) {
     for (IEquipmentStats stats : item.getStats())
       if (stats instanceof IArtifactStats
           && item.getAttunementState() == ((IArtifactStats) stats).getAttuneType())
         total += ((IArtifactStats) stats).getAttuneCost();
   }
   return total;
 }
예제 #3
0
 @Override
 public void refreshItems() {
   for (IEquipmentItem item : equipmentItems) {
     if (canBeRemoved(item)) {
       IEquipmentItem refreshedItem = refreshItem(item);
       if (refreshedItem != null) {
         refreshedItem.setPersonalization(item);
         getOptionProvider().transferOptions(item, refreshedItem);
         announceItemAndListenForChanges(refreshedItem);
       }
     }
   }
 }
 @Override
 public void refreshItems() {
   for (IEquipmentItem item : equipmentItems) {
     if (canBeRemoved(item)) {
       IEquipmentItem refreshedItem = refreshItem(item);
       if (refreshedItem != null) {
         refreshedItem.setPersonalization(item);
         getCharacterOptionProvider().transferOptions(item, refreshedItem);
         initItem(refreshedItem);
       }
     }
   }
 }
 @Override
 public void changeOccurred() {
   for (IEquipmentItem item : getEquipmentItems())
     for (IEquipmentStats stats : item.getStats()) {
       List<IEquipmentStatsOption> list = optionsTable.get(item, stats);
       if (list == null) {
         return;
       }
       List<IEquipmentStatsOption> optionsList = new ArrayList<IEquipmentStatsOption>(list);
       for (IEquipmentStatsOption option : optionsList) {
         if (!characterStillHasCorrespondingSpecialty(option)) {
           disableStatOption(item, stats, option);
         }
       }
     }
 }
예제 #6
0
 @Override
 public void removeItem(IEquipmentItem item) {
   equipmentItems.remove(item);
   announce().itemRemoved(item);
   item.removeChangeListener(itemChangePropagator);
   fireModelChanged();
 }
 @Override
 public boolean transferOptions(IEquipmentItem fromItem, IEquipmentItem toItem) {
   if (fromItem == null || toItem == null) {
     return false;
   }
   boolean transferred = false;
   for (IEquipmentStats fromStats : fromItem.getStats()) {
     List<IEquipmentStatsOption> optionList = optionsTable.get(fromItem, fromStats);
     optionsTable.add(fromItem, fromStats, null);
     IEquipmentStats toStats = toItem.getStat(fromStats.getId());
     if (toStats != null && optionList != null) {
       optionsTable.add(toItem, toStats, optionList);
       transferred = true;
     }
   }
   return transferred;
 }
 @Override
 public IEquipmentStatsOption[] getEnabledStatOptions(IEquipmentStats stats) {
   if (stats == null) {
     return new IEquipmentStatsOption[0];
   }
   List<IEquipmentItem> itemList = new ArrayList<IEquipmentItem>();
   itemList.addAll(naturalWeaponItems);
   Collections.addAll(itemList, getEquipmentItems());
   for (IEquipmentItem item : itemList) {
     for (IEquipmentStats stat : item.getStats()) {
       if (stats.equals(stat)) {
         return getEnabledStatOptions(item, stat);
       }
     }
   }
   return new IEquipmentStatsOption[0];
 }
예제 #9
0
  @Override
  public boolean transferOptions(IEquipmentItem fromItem, IEquipmentItem toItem) {
    boolean transferred = false;
    if (fromItem != null && toItem != null) {
      for (IEquipmentStats fromStats : fromItem.getStats()) {
        List<IEquipmentStatsOption> specialtyList = optionsTable.remove(fromItem, fromStats);
        boolean printCheckboxEnabled = fromItem.isPrintEnabled(fromStats);
        IEquipmentStats toStats = toItem.getStat(fromStats.getId());

        if (toStats != null) {
          transferred = true;
          if (specialtyList != null) {
            optionsTable.put(toItem, toStats, specialtyList);
          }
          toItem.setPrintEnabled(toStats, printCheckboxEnabled);
        }
      }
    }
    return transferred;
  }
예제 #10
0
 private void initItem(final IEquipmentItem item) {
   equipmentItemControl.forAllDo(
       new IClosure<ICollectionListener<IEquipmentItem>>() {
         @Override
         public void execute(ICollectionListener<IEquipmentItem> input) {
           input.itemAdded(item);
         }
       });
   modelChangeControl.fireChangedEvent();
   item.addChangeListener(itemChangePropagator);
 }
예제 #11
0
 public EquipmentPto createPto(IEquipmentItem item) {
   EquipmentPto pto = new EquipmentPto();
   pto.templateId = item.getTemplateId();
   pto.customTitle = item.getTitle();
   if (!item.getBaseDescription().equals(item.getDescription())) {
     pto.description = item.getDescription();
   }
   if (item.getMaterialComposition() == MaterialComposition.Variable) {
     pto.material = item.getMaterial().name();
   }
   for (IEquipmentStats stats : item.getStats()) {
     if (item.isPrintEnabled(stats)) {
       EquipmentStatsPto printPto = createStatsPto(item, stats);
       pto.printStats.add(printPto);
     }
   }
   return pto;
 }
예제 #12
0
 @Override
 public void removeItem(final IEquipmentItem item) {
   equipmentItems.remove(item);
   equipmentItemControl.forAllDo(
       new IClosure<ICollectionListener<IEquipmentItem>>() {
         @Override
         public void execute(final ICollectionListener<IEquipmentItem> input) {
           input.itemRemoved(item);
         }
       });
   item.removeChangeListener(itemChangePropagator);
   modelChangeControl.fireChangedEvent();
 }
예제 #13
0
 private EquipmentStatsPto createStatsPto(IEquipmentItem item, IEquipmentStats stats) {
   EquipmentStatsPto statsPto = new EquipmentStatsPto();
   statsPto.id = stats.getId();
   IEquipmentStats stat = item.getStat(stats.getId());
   EquipmentOptionsProvider optionProvider = heroModel.getOptionProvider();
   IEquipmentStatsOption[] enabledStatOptions = optionProvider.getEnabledStatOptions(item, stat);
   for (IEquipmentStatsOption option : enabledStatOptions) {
     EquipmentOptionPto optionPto = new EquipmentOptionPto();
     optionPto.name = option.getName();
     optionPto.type = option.getType();
   }
   return statsPto;
 }
예제 #14
0
 private void announceItemAndListenForChanges(IEquipmentItem refreshedItem) {
   announce().itemAdded(refreshedItem);
   refreshedItem.addChangeListener(itemChangePropagator);
   fireModelChanged();
 }
예제 #15
0
 private IEquipmentItem refreshItem(final IEquipmentItem item) {
   String templateId = item.getTemplateId();
   MagicalMaterial material = item.getMaterial();
   removeItem(item);
   return addEquipmentObjectFor(templateId, material);
 }
 private boolean hasCustomTitle(IEquipmentItem item) {
   return !item.getTemplateId().equals(item.getTitle());
 }
  @Override
  public ICardData[] getCards(ICharacter character, ICardReportResourceProvider resourceProvider) {
    IEquipmentAdditionalModel model =
        (IEquipmentAdditionalModel)
            character
                .getStatistics()
                .getCharacterContext()
                .getAdditionalModel(IEquipmentAdditionalModelTemplate.ID);
    List<ICardData> data = new ArrayList<ICardData>();
    for (IEquipmentItem item : model.getEquipmentItems()) {
      String title = item.getTitle();
      Paragraph headerText = new Paragraph();
      if (hasCustomTitle(item)) {
        headerText.add(new Phrase(item.getTemplateId(), resourceProvider.getNormalFont()));
      }
      if (item.getMaterialComposition() == MaterialComposition.Variable) {
        String itemMaterial = "";
        if (hasCustomTitle(item)) itemMaterial += " (";
        itemMaterial += item.getMaterial().getId();
        if (hasCustomTitle(item)) itemMaterial += ")";
        headerText.add(new Phrase(itemMaterial + "\n", resourceProvider.getNormalFont()));
      }
      if (item.getCost() != null) {
        headerText.add(new Phrase(item.getCost().toString(), resourceProvider.getNormalFont()));
      }

      List<Phrase> bodyText = new ArrayList<Phrase>();

      String description = item.getDescription();
      if (description != null && !description.isEmpty()) {
        bodyText.add(new Phrase(description, resourceProvider.getNormalFont()));
        bodyText.add(new Phrase("\n", resourceProvider.getNormalFont()));
      }
      for (IEquipmentStats stats : item.getStats()) {
        Paragraph statsParagraph = new Paragraph();
        if (stats instanceof IArtifactStats) {
          IArtifactStats artifactStats = (IArtifactStats) stats;
          if (artifactStats.getAttuneType() != ArtifactAttuneType.FullyAttuned) {
            continue;
          }
          statsParagraph.add(
              new Phrase(
                  resources.getString("Equipment.Stats.Short.AttuneCost").trim() + ": ",
                  resourceProvider.getBoldFont()));
          statsParagraph.add(
              new Phrase(artifactStats.getAttuneCost() + "m", resourceProvider.getNormalFont()));
        } else {
          String statsString = stringBuilder.createString(item, stats);
          statsParagraph.add(new Phrase(stats.getId() + ": ", resourceProvider.getBoldFont()));
          statsParagraph.add(
              new Phrase(
                  statsString.substring(statsString.indexOf(':') + 2),
                  resourceProvider.getNormalFont()));
        }

        bodyText.add(statsParagraph);
      }

      data.add(
          new EquipmentCardData(
              title, headerText, bodyText.toArray(new Phrase[0]), resourceProvider.getNullIcon()));
    }
    return data.toArray(new ICardData[0]);
  }