Пример #1
0
 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;
 }