コード例 #1
0
ファイル: StdTub.java プロジェクト: Cocanuta/Marble
 public boolean okMessage(final Environmental myHost, final CMMsg msg) {
   if (!super.okMessage(myHost, msg)) return false;
   if (msg.amITarget(this)) {
     MOB mob = msg.source();
     switch (msg.targetMinor()) {
       case CMMsg.TYP_DRINK:
         if ((mob.isMine(this))
             || (phyStats().weight() > 1000)
             || (!CMLib.flags().isGettable(this))) {
           if (!containsDrink()) {
             mob.tell(name() + " is empty.");
             return false;
           }
           if ((liquidType() == RawMaterial.RESOURCE_SALTWATER)
               || (liquidType() == RawMaterial.RESOURCE_LAMPOIL)) {
             mob.tell(
                 "You don't want to be drinking "
                     + RawMaterial.CODES.NAME(liquidType()).toLowerCase()
                     + ".");
             return false;
           }
           return true;
         }
         mob.tell("You don't have that.");
         return false;
       case CMMsg.TYP_FILL:
         if ((liquidRemaining() >= amountOfLiquidHeld) && (liquidHeld() < 500000)) {
           mob.tell(name() + " is full.");
           return false;
         }
         if ((msg.tool() != null)
             && (msg.tool() != msg.target())
             && (msg.tool() instanceof Drink)) {
           Drink thePuddle = (Drink) msg.tool();
           if (!thePuddle.containsDrink()) {
             mob.tell(thePuddle.name() + " is empty.");
             return false;
           }
           if ((liquidRemaining() > 0) && (liquidType() != thePuddle.liquidType())) {
             mob.tell(
                 "There is still some "
                     + RawMaterial.CODES.NAME(liquidType()).toLowerCase()
                     + " left in "
                     + name()
                     + ".  You must empty it before you can fill it with "
                     + RawMaterial.CODES.NAME(thePuddle.liquidType()).toLowerCase()
                     + ".");
             return false;
           }
           return true;
         }
         mob.tell("You can't fill " + name() + " from that.");
         return false;
       default:
         break;
     }
   }
   return true;
 }
コード例 #2
0
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   if ((msg.amITarget(littlePlants)) && (msg.targetMinor() == CMMsg.TYP_GET))
     msg.addTrailerMsg(
         CMClass.getMsg(
             msg.source(),
             littlePlants,
             null,
             CMMsg.MSG_OK_VISUAL,
             CMMsg.MASK_ALWAYS | CMMsg.MSG_DEATH,
             CMMsg.NO_EFFECT,
             null));
 }
コード例 #3
0
ファイル: Thief_Listen.java プロジェクト: Cocanuta/Marble
  public void executeMsg(final Environmental myHost, final CMMsg msg) {
    super.executeMsg(myHost, msg);
    if ((affected != null)
        && (affected instanceof Room)
        && (invoker() != null)
        && (invoker().location() != null)
        && (sourceRoom != null)
        && (!invoker().isInCombat())
        && (invoker().location() == sourceRoom)) {
      if (invoker().location() == room) {
        if ((msg.sourceMinor() == CMMsg.TYP_SPEAK)
            && (msg.othersCode() == CMMsg.NO_EFFECT)
            && (msg.othersMessage() == null)
            && (msg.sourceMessage() != null)
            && (!msg.amISource(invoker()))
            && (!msg.amITarget(invoker()))
            && (!lastSaid.equals(msg.sourceMessage()))) {
          lastSaid = msg.sourceMessage();
          if ((invoker().phyStats().level() + (getXLEVELLevel(invoker()) * 10))
              > msg.source().phyStats().level())
            invoker().tell(msg.source(), msg.target(), msg.tool(), msg.sourceMessage());
          else
            invoker()
                .tell(
                    msg.source(),
                    null,
                    null,
                    "<S-NAME> said something, but you couldn't quite make it out.");
        }
      } else if ((msg.sourceMinor() == CMMsg.TYP_SPEAK)
          && (msg.othersMinor() == CMMsg.TYP_SPEAK)
          && (msg.othersMessage() != null)
          && (msg.sourceMessage() != null)
          && (!lastSaid.equals(msg.sourceMessage()))) {
        lastSaid = msg.sourceMessage();
        if ((invoker().phyStats().level() + (getXLEVELLevel(invoker()) * 10))
            > msg.source().phyStats().level())
          invoker().tell(msg.source(), msg.target(), msg.tool(), msg.sourceMessage());
        else
          invoker()
              .tell(
                  msg.source(),
                  null,
                  null,
                  "<S-NAME> said something, but you couldn't quite make it out.");
      }

    } else unInvoke();
  }
コード例 #4
0
ファイル: StdTub.java プロジェクト: Cocanuta/Marble
  public void executeMsg(final Environmental myHost, final CMMsg msg) {
    if (msg.source().riding() == this) {
      CMLib.commands().handleHygenicMessage(msg, 0, PlayerStats.HYGIENE_WATERCLEAN);
    }

    if (msg.amITarget(this)) {
      MOB mob = msg.source();
      switch (msg.targetMinor()) {
        case CMMsg.TYP_DRINK:
          amountOfLiquidRemaining -= amountOfThirstQuenched;
          boolean thirsty = mob.curState().getThirst() <= 0;
          boolean full =
              !mob.curState()
                  .adjThirst(amountOfThirstQuenched, mob.maxState().maxThirst(mob.baseWeight()));
          if (thirsty) mob.tell("You are no longer thirsty.");
          else if (full) mob.tell("You have drunk all you can.");
          if (disappearsAfterDrinking) {
            destroy();
            return;
          }
          break;
        case CMMsg.TYP_FILL:
          if ((msg.tool() != null) && (msg.tool() instanceof Drink)) {
            Drink thePuddle = (Drink) msg.tool();
            int amountToTake = amountTakenToFillMe(thePuddle);
            thePuddle.setLiquidRemaining(thePuddle.liquidRemaining() - amountToTake);
            if (amountOfLiquidRemaining <= 0) setLiquidType(thePuddle.liquidType());
            if (((long) amountOfLiquidRemaining + (long) amountToTake) <= (long) Integer.MAX_VALUE)
              amountOfLiquidRemaining += amountToTake;
            if (amountOfLiquidRemaining > amountOfLiquidHeld)
              amountOfLiquidRemaining = amountOfLiquidHeld;
            if ((amountOfLiquidRemaining <= 0) && (disappearsAfterDrinking)) {
              destroy();
              return;
            }
          }
          break;
        default:
          break;
      }
    }
    super.executeMsg(myHost, msg);
  }
コード例 #5
0
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if (affected == null) return super.okMessage(myHost, msg);

    if (affected instanceof MOB) {
      MOB mob = (MOB) affected;
      if ((msg.amITarget(mob))
          && (!msg.amISource(mob))
          && (mob.location() != msg.source().location())
          && (msg.tool() != null)
          && (msg.tool() instanceof Ability)
          && (CMath.bset(((Ability) msg.tool()).flags(), Ability.FLAG_SUMMONING))
          && (!mob.amDead())) {
        msg.source()
            .location()
            .showHappens(
                CMMsg.MSG_OK_VISUAL, "Magical energy fizzles and is absorbed into the air!");
        return false;
      }
    } else if (affected instanceof Room) {
      Room R = (Room) affected;
      if ((msg.tool() != null)
          && (msg.tool() instanceof Ability)
          && (CMath.bset(((Ability) msg.tool()).flags(), Ability.FLAG_SUMMONING))) {
        Ability A = (Ability) msg.tool();
        if (((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_CHANT)
            || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL)
            || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_PRAYER)
            || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SONG)) {
          if ((msg.source().location() != null) && (msg.source().location() != R))
            msg.source()
                .location()
                .showHappens(
                    CMMsg.MSG_OK_VISUAL, "Magical energy fizzles and is absorbed into the air!");
          R.showHappens(
              CMMsg.MSG_OK_VISUAL, "Magical energy fizzles and is absorbed into the air!");
        }
        return false;
      }
    }
    return super.okMessage(myHost, msg);
  }