Esempio n. 1
0
 private int calculateCharmCost(
     ICharmConfiguration charmConfiguration, ICharm charm, Set<ICharm> charmsCalculated) {
   ISpecialCharmConfiguration specialCharm =
       charmConfiguration.getSpecialCharmConfiguration(charm);
   int charmCost =
       calculator.getCharmCosts(
           charm,
           basicCharacter,
           traitConfiguration,
           character.getCharacterTemplate().getMagicTemplate().getFavoringTraitType());
   if (specialCharm != null) {
     int timesLearnedWithExperience =
         specialCharm.getCurrentLearnCount() - specialCharm.getCreationLearnCount();
     int specialCharmCost = timesLearnedWithExperience * charmCost;
     if (specialCharm instanceof IUpgradableCharmConfiguration) {
       return (costsExperience(charmConfiguration, charm, charmsCalculated) ? charmCost : 0)
           + ((IUpgradableCharmConfiguration) specialCharm).getUpgradeXPCost();
     }
     if (!(specialCharm instanceof ISubeffectCharmConfiguration)) {
       return specialCharmCost;
     }
     ISubeffectCharmConfiguration subeffectCharmConfiguration =
         (ISubeffectCharmConfiguration) specialCharm;
     int count =
         Math.max(
             0,
             (subeffectCharmConfiguration.getExperienceLearnedSubeffectCount()
                 - (subeffectCharmConfiguration.getCreationLearnedSubeffectCount() == 0 ? 1 : 0)));
     int subeffectCost =
         (int) Math.ceil(count * subeffectCharmConfiguration.getPointCostPerEffect() * 2);
     return subeffectCost + specialCharmCost;
   }
   return costsExperience(charmConfiguration, charm, charmsCalculated) ? charmCost : 0;
 }
 private IFavorableTrait[] getAllAbilities() {
   List<ITraitType> abilityTypes = new ArrayList<>();
   for (GroupedTraitType type : character.getCharacterTemplate().getAbilityGroups()) {
     abilityTypes.add(type.getTraitType());
   }
   return traitConfiguration.getFavorableTraits(
       abilityTypes.toArray(new ITraitType[abilityTypes.size()]));
 }
Esempio n. 3
0
 private int getCharmCosts() {
   int experienceCosts = 0;
   ICharmConfiguration charmConfiguration = character.getCharms();
   Set<ICharm> charmsCalculated = new HashSet<>();
   for (ICharm charm : charmConfiguration.getLearnedCharms(true)) {
     int charmCosts = calculateCharmCost(charmConfiguration, charm, charmsCalculated);
     if (charmConfiguration.isAlienCharm(charm)) {
       charmCosts *= 2;
     }
     experienceCosts += charmCosts;
     charmsCalculated.add(charm);
   }
   return experienceCosts;
 }
  private void initTotal(IOverviewCategory category) {
    totalView = category.addAlotmentView(getString("Overview.Experience.Total"), 4);
    character
        .getExperiencePoints()
        .addExperiencePointConfigurationListener(
            new IExperiencePointConfigurationListener() {
              @Override
              public void entryAdded(IExperiencePointEntry entry) {
                calculateXPCost();
              }

              @Override
              public void entryRemoved(IExperiencePointEntry entry) {
                calculateXPCost();
              }

              @Override
              public void entryChanged(IExperiencePointEntry entry) {
                calculateXPCost();
              }
            });
  }
 public ExperiencedOverviewPresenter(
     Resources resources,
     final ICharacter character,
     CategorizedOverview overview,
     IExperiencePointManagement experiencePoints) {
   this.resources = resources;
   this.character = character;
   character
       .getCharacterContext()
       .getCharacterListening()
       .addChangeListener(
           new GlobalCharacterChangeAdapter() {
             @Override
             public void characterChanged() {
               if (character.isExperienced()) {
                 calculateXPCost();
               }
             }
           });
   this.management = experiencePoints;
   this.view = overview;
 }
  @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]);
  }
 private int getTotalXP() {
   return character.getExperiencePoints().getTotalExperiencePoints() + management.getMiscGain();
 }
Esempio n. 8
0
 private boolean isSpecialCharm(ICharm charm) {
   return character.getCharms().getSpecialCharmConfiguration(charm) != null;
 }
 @Override
 public void doTable(Parse table) {
   @SuppressWarnings("unchecked")
   ICharacter character = new CharacterSummary(summary).getCharacter();
   character.getStatistics().setExperienced(true);
 }