Beispiel #1
0
  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);
  }
Beispiel #2
0
 public int amountTakenToFillMe(Drink theSource) {
   int amountToTake = amountOfLiquidHeld - amountOfLiquidRemaining;
   if (amountOfLiquidHeld >= 500000) amountToTake = theSource.liquidRemaining();
   if (amountToTake > theSource.liquidRemaining()) amountToTake = theSource.liquidRemaining();
   return amountToTake;
 }