Пример #1
0
  /*
   * (non-Javadoc)
   *
   * @see java.lang.Object#equals(java.lang.Object)
   */
  @Override
  public boolean equals(Object o) {

    if (o == null) {
      return false;
    }

    if (!o.getClass().equals(this.getClass())) return false;

    Item otherItem = (Item) o;

    if (!otherItem.getId().equals(getId())) return false;

    return true;
  }
Пример #2
0
  @Override
  public int compareTo(Item another) {

    int comp1 = 0;
    if (getCategory() != null && another.getCategory() != null)
      comp1 = getCategory().compareToIgnoreCase(another.getCategory());
    else if (getCategory() == null) comp1 = -1;
    else if (another.getCategory() == null) comp1 = 1;
    else comp1 = 0;

    int comp2 = getName().compareToIgnoreCase(another.getName());
    int comp3 = getId().compareTo(another.getId());

    return comp1 * 10000 + comp2 * 100 + comp3;
  }
Пример #3
0
  /*
   * (non-Javadoc)
   *
   * @see java.lang.Object#clone()
   */
  @Override
  public Item clone() {
    Item item;
    try {
      item = (Item) super.clone();

      item.itemSpecs = new ArrayList<ItemSpecification>(getSpecifications().size());

      for (ItemSpecification specification : getSpecifications()) {
        item.itemSpecs.add(specification.clone());
      }

      item.weaponSpecsHelper = null;
      item.shieldSpecsHelper = null;
      item.distanceWeaponSpecsHelper = null;
      item.armorSpecsHelper = null;
      item.miscSpecsHelper = null;
    } catch (CloneNotSupportedException e) {
      return null;
    }

    return item;
  }
Пример #4
0
  protected View prepareView(
      EquippedItem equippedItem, int position, View convertView, ViewGroup parent) {

    ViewHolder holder = (ViewHolder) convertView.getTag();

    Item item = equippedItem.getItem();
    ItemSpecification itemSpecification = equippedItem.getItemSpecification();

    // if (equippedItem.getSecondaryItem() != null
    // &&
    // (equippedItem.getSecondaryItem().getItem().hasSpecification(Shield.class)
    // || (equippedItem
    // .getSecondaryItem().getItem().hasSpecification(Weapon.class) &&
    // equippedItem.getHand() == Hand.rechts))) {
    //
    // } else {
    // fightItemsOdd = !fightItemsOdd;
    // }

    StyleableSpannableStringBuilder title = new StyleableSpannableStringBuilder();
    if (!TextUtils.isEmpty(item.getTitle())) title.append(item.getTitle());

    holder.text2.setText(itemSpecification.getInfo());
    holder.text3.setText(null);

    holder.icon1.setImageResource(DsaUtil.getResourceId(itemSpecification));
    holder.icon1.setVisibility(View.VISIBLE);

    if (itemSpecification instanceof DistanceWeapon) {
      DistanceWeapon distanceWeapon = (DistanceWeapon) itemSpecification;

      holder.icon2.setImageResource(R.drawable.icon_target);
      holder.icon2.setVisibility(View.VISIBLE);

      if (equippedItem.getTalent() != null) {
        CombatProbe probe = equippedItem.getCombatProbeAttacke();
        Util.appendValue(hero, title, probe, null, getFilter().getSettings().isIncludeModifiers());
        holder.icon2.setEnabled(true);
        holder.icon1.setEnabled(true);
        holder.icon2.setTag(equippedItem);
        holder.icon2.setOnClickListener(targetListener);
        holder.icon1.setTag(probe);
        holder.icon1.setOnClickListener(probeListener);
      } else {
        holder.icon2.setEnabled(false);
        holder.icon2.setTag(null);
        holder.icon2.setOnClickListener(null);

        holder.icon1.setEnabled(false);
        holder.icon1.setTag(null);
        holder.icon1.setOnClickListener(null);
      }

      holder.text2.setText(distanceWeapon.getInfo(hero.getModifierTP(equippedItem)));

      if (hero.getHuntingWeapon() != null && hero.getHuntingWeapon().equals(equippedItem)) {
        holder.text3.setText(" Jagdwaffe");
      }

    } else if (itemSpecification instanceof Shield) {
      holder.icon1.setVisibility(View.INVISIBLE);
      holder.icon1.setTag(null);
      holder.icon1.setOnClickListener(null);

      if (equippedItem.getUsageType() == UsageType.Paradewaffe)
        holder.icon2.setImageURI(item.getIconUri());
      else holder.icon2.setImageResource(R.drawable.icon_shield);

      holder.icon2.setVisibility(View.VISIBLE);
      if (equippedItem.getTalent() != null) {
        holder.icon2.setEnabled(true);
        CombatProbe probe = equippedItem.getCombatProbeDefense();
        Util.appendValue(hero, title, probe, null, getFilter().getSettings().isIncludeModifiers());
        holder.icon2.setTag(probe);
        holder.icon2.setOnClickListener(probeListener);

        holder.text3.setText(equippedItem.getTalent().getName());
      } else {
        holder.icon2.setEnabled(false);
        holder.icon2.setTag(null);
        holder.icon2.setOnClickListener(null);
      }

    } else if (itemSpecification instanceof Weapon) {
      Weapon weapon = (Weapon) itemSpecification;

      holder.icon2.setImageResource(R.drawable.icon_shield);
      holder.icon2.setVisibility(View.VISIBLE);
      if (equippedItem.getTalent() != null) {

        CombatProbe pa = null, at = null;

        if (weapon.isAttackable()) {
          holder.icon1.setEnabled(true);
          holder.icon1.setVisibility(View.VISIBLE);
          at = equippedItem.getCombatProbeAttacke();
          holder.icon1.setTag(at);
          holder.icon1.setOnClickListener(probeListener);
        } else {
          holder.icon1.setVisibility(View.INVISIBLE);
          holder.icon1.setTag(null);
          holder.icon1.setOnClickListener(null);
        }

        if (weapon.isDefendable()) {
          holder.icon2.setEnabled(true);
          holder.icon2.setVisibility(View.VISIBLE);
          pa = equippedItem.getCombatProbeDefense();
          holder.icon2.setTag(pa);
          holder.icon2.setOnClickListener(probeListener);
        } else {
          holder.icon2.setVisibility(View.INVISIBLE);
          holder.icon2.setTag(null);
          holder.icon2.setOnClickListener(null);
        }

        String talentName = null;
        if (equippedItem.getTalent() != null) {
          talentName = equippedItem.getTalent().getName();
        }

        SpannableStringBuilder sb = new SpannableStringBuilder();

        if (!TextUtils.isEmpty(weapon.getName())) {
          sb.append(weapon.getName());
          sb.append("/");
        }
        if (!TextUtils.isEmpty(equippedItem.getItemSpecification().getSpecificationLabel())) {
          sb.append(equippedItem.getItemSpecification().getSpecificationLabel());
          sb.append("/");
        }
        sb.append(talentName);

        if (equippedItem.getHand() == Hand.links) {
          sb.append(" (Links)");
        }

        if (equippedItem.isBeidhändigerKampf()) {
          sb.append(" - BK");
        }

        holder.text3.setText(sb);

        Util.appendValue(hero, title, at, pa, getFilter().getSettings().isIncludeModifiers());
      } else {
        holder.icon2.setEnabled(false);
        holder.icon2.setTag(null);
        holder.icon2.setOnClickListener(null);

        holder.icon1.setEnabled(false);
        holder.icon1.setTag(null);
        holder.icon1.setOnClickListener(null);
      }
      if (getFilter().getSettings().isIncludeModifiers()) {
        holder.text2.setText(
            weapon.getInfo(
                hero.getModifiedValue(AttributeType.Körperkraft, true, true),
                hero.getModifierTP(equippedItem)));
      } else {
        holder.text2.setText(weapon.getInfo());
      }
    } else if (itemSpecification instanceof Armor) {
      // Armor armor = (Armor) itemSpecification;
      holder.icon2.setVisibility(View.GONE);
      holder.icon2.setTag(null);
      holder.icon2.setOnClickListener(null);
    }

    if (holder.icon_chain_top != null && holder.icon_chain_bottom != null) {
      if (equippedItem.getSecondaryItem() != null) {
        if (position > 0 && getItem(position - 1).equals(equippedItem.getSecondaryItem())) {
          holder.icon_chain_bottom.setVisibility(View.VISIBLE);
          holder.icon_chain_top.setVisibility(View.GONE);
        } else if (position < getCount()
            && getItem(position + 1).equals(equippedItem.getSecondaryItem())) {
          holder.icon_chain_top.setVisibility(View.VISIBLE);
          holder.icon_chain_bottom.setVisibility(View.GONE);
        }
      } else {
        holder.icon_chain_top.setVisibility(View.GONE);
        holder.icon_chain_bottom.setVisibility(View.GONE);
      }
    }

    holder.text1.setText(title);

    return convertView;
  }
Пример #5
0
 public Item duplicate() {
   Item item = this.clone();
   item.id = UUID.randomUUID();
   return item;
 }
Пример #6
0
 /*
  * (non-Javadoc)
  *
  * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
  */
 @Override
 public int compare(Item object1, Item object2) {
   return object1.getName().compareToIgnoreCase(object2.getName());
 }