Пример #1
0
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if (!super.okMessage(myHost, msg)) return false;

    if ((msg.target() == affected)
        && msg.isTarget(CMMsg.MASK_MALICIOUS)
        && CMLib.flags().isAPlant(msg.source())
        && (affected instanceof MOB)
        && (pointsRemaining >= 0)) {
      final MOB mob = (MOB) affected;
      final MOB plantMOB = msg.source();
      final Room R = plantMOB.location();
      if ((R != null) && (R == mob.location())) {
        if ((msg.isSource(CMMsg.TYP_ADVANCE)) && (--pointsRemaining >= 0)) {
          R.show(
              plantMOB,
              affected,
              CMMsg.MSG_OK_ACTION,
              L("<S-NAME> struggle(s) against <T-YOUPOSS> anti-plant shell."));
          return false;
        } else if (plantMOB.getVictim() == null) {
          plantMOB.setVictim(mob);
          if (mob.getVictim() == plantMOB) {
            if (mob.rangeToTarget() > 0) plantMOB.setRangeToTarget(mob.rangeToTarget());
            else {
              plantMOB.setRangeToTarget(R.maxRange());
              mob.setRangeToTarget(R.maxRange());
            }
          } else plantMOB.setRangeToTarget(R.maxRange());
          if ((--pointsRemaining) < 0) {
            unInvoke();
            return true;
          }
          R.show(
              plantMOB,
              affected,
              CMMsg.MSG_OK_ACTION,
              L("<S-NAME> <S-IS-ARE> repelled by <T-YOUPOSS> anti-plant shell."));
          return false;
        } else if ((plantMOB.getVictim() == affected) && (plantMOB.rangeToTarget() <= 0)) {
          plantMOB.setRangeToTarget(R.maxRange());
          if (mob.getVictim() == plantMOB) mob.setRangeToTarget(R.maxRange());
          if ((--pointsRemaining) < 0) {
            unInvoke();
            return true;
          }
          R.show(
              plantMOB,
              affected,
              CMMsg.MSG_OK_ACTION,
              L("<S-NAME> <S-IS-ARE> repelled by <T-YOUPOSS> anti-plant shell."));
          return false;
        } else if ((mob.getVictim() == plantMOB) && (mob.rangeToTarget() <= 0)) {
          mob.setRangeToTarget(R.maxRange());
          if ((--pointsRemaining) < 0) {
            unInvoke();
            return true;
          }
          R.show(
              plantMOB,
              affected,
              CMMsg.MSG_OK_ACTION,
              L("<S-NAME> <S-IS-ARE> repelled by <T-YOUPOSS> anti-plant shell."));
          return false;
        }
      }
    } else if (msg.isSource(CMMsg.TYP_ADVANCE)
        && (msg.source() == affected)
        && (msg.source().getVictim() == msg.target())
        && (CMLib.flags().isAPlant((MOB) msg.target()))
        && (pointsRemaining >= 0)
        && (msg.source().rangeToTarget() == 1)) {
      final MOB plantM = msg.source().getVictim();
      if (plantM != null) {
        final Room R = plantM.location();
        if (R != null) {
          final CMMsg msg2 =
              CMClass.getMsg(
                  plantM,
                  msg.source(),
                  CMMsg.MSG_RETREAT,
                  L("<S-NAME> <S-IS-ARE> pushed back by <T-YOUPOSS> anti-plant shell."));
          if (R.okMessage(plantM, msg2)) R.send(plantM, msg2);
        }
      }
    }
    if (pointsRemaining < 0) {
      unInvoke();
      return true;
    }
    return true;
  }