Example #1
0
 @Override
 public int compareTo(StatModifier o) {
   int result = getPriority().getValue() - o.getPriority().getValue();
   if (result == 0) {
     result = id - o.id;
   }
   return result;
 }
  @Override
  public void startEffect(Effect effect) {
    Player player = (Player) effect.getEffector();
    boolean isSetMain = false;
    boolean isSetSub = false;

    TreeSet<StatModifier> modifierTemplates = getModifiers(effect);
    for (StatModifier modifier : modifierTemplates) {
      for (Item item : player.getEquipment().getEquippedItemsWithoutStigma()) {
        WeaponType targetWeaponType = item.getItemTemplate().getWeaponType();
        if (targetWeaponType == null) continue;
        if (targetWeaponType.equals(weaponType)) {
          if (item.getEquipmentSlot() == ItemSlot.MAIN_HAND.getSlotIdMask()) {
            switch (modifier.getStat()) {
              case PHYSICAL_ATTACK:
                modifier.getStatToModifies().add(StatEnum.MAIN_HAND_POWER);
                isSetMain = true;
                break;
              default:
            }
          }
          if (item.getEquipmentSlot() == ItemSlot.SUB_HAND.getSlotIdMask()) {
            switch (modifier.getStat()) {
              case PHYSICAL_ATTACK:
                modifier.getStatToModifies().add(StatEnum.OFF_HAND_POWER);
                isSetSub = true;
                break;
              default:
            }
          }
        }
      }
      modifier.setCanDuplicate(false);
    }
    super.startEffect(effect, modifierTemplates);
    if (isSetMain) player.getEffectController().setWeaponMastery(effect.getSkillId());
    if (isSetSub) player.getEffectController().setSubWeaponMastery(effect.getSkillId());
  }