예제 #1
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    super.tick(ticking, tickID);

    if (anyWetWeather(lastWeather)) {
      if (ticking instanceof Room) {
        final Room R = (Room) ticking;
        final Area A = R.getArea();
        if ((!anyWetWeather(A.getClimateObj().weatherType(R)))
            && (!dryWeather(A.getClimateObj().weatherType(R)))
            && (CMLib.dice().rollPercentage() < pct()))
          makePuddle(R, lastWeather, A.getClimateObj().weatherType(R));
      } else if (ticking instanceof Area) {
        final Area A = (Area) ticking;
        if ((!anyWetWeather(A.getClimateObj().weatherType(null)))
            && (!dryWeather(A.getClimateObj().weatherType(null)))) {
          for (final Enumeration<Room> e = A.getProperMap(); e.hasMoreElements(); ) {
            final Room R = e.nextElement();
            if (((R.domainType() & Room.INDOORS) == 0)
                && (R.domainType() != Room.DOMAIN_OUTDOORS_AIR)
                && (!CMLib.flags().isWateryRoom(R))
                && (CMLib.dice().rollPercentage() < pct()))
              makePuddle(R, lastWeather, A.getClimateObj().weatherType(null));
          }
        }
      }
    }

    if (ticking instanceof Room)
      lastWeather = ((Room) ticking).getArea().getClimateObj().weatherType((Room) ticking);
    else if (ticking instanceof Area)
      lastWeather = ((Area) ticking).getClimateObj().weatherType(null);
    return true;
  }
예제 #2
0
  @Override
  public void executeMsg(Environmental affecting, CMMsg msg) {
    super.executeMsg(affecting, msg);
    final MOB source = msg.source();
    if (!canFreelyBehaveNormal(affecting)) return;
    final MOB observer = (MOB) affecting;

    if ((source != observer)
        && (msg.amITarget(observer))
        && (msg.targetMinor() == CMMsg.TYP_GIVE)
        && (msg.tool() instanceof Coins)) {
      if ((CMLib.flags().canBeSeenBy(source, observer))
          && (CMLib.flags().canBeSeenBy(observer, source))) {
        double value = ((Coins) msg.tool()).getTotalValue();
        final String currency = ((Coins) msg.tool()).getCurrency().toUpperCase();
        double takeCut = getMyCut(affecting, currency);
        double amountToTake = CMLib.beanCounter().abbreviatedRePrice(observer, value * takeCut);
        if ((amountToTake > 0.0)
            && (amountToTake
                < CMLib.beanCounter()
                    .getLowestDenomination(CMLib.beanCounter().getCurrency(observer))))
          amountToTake =
              CMLib.beanCounter().getLowestDenomination(CMLib.beanCounter().getCurrency(observer));
        value -= amountToTake;
        observer.recoverPhyStats();
        final Coins C = CMLib.beanCounter().makeBestCurrency(observer, value);
        if ((value > 0.0) && (C != null)) {
          // this message will actually end up triggering the hand-over.
          final CMMsg newMsg =
              CMClass.getMsg(
                  observer,
                  source,
                  C,
                  CMMsg.MSG_SPEAK,
                  L("^T<S-NAME> say(s) 'Thank you for your business' to <T-NAMESELF>.^?"));
          C.setOwner(observer);
          final long num = C.getNumberOfCoins();
          final String curr = C.getCurrency();
          final double denom = C.getDenomination();
          C.destroy();
          C.setNumberOfCoins(num);
          C.setCurrency(curr);
          C.setDenomination(denom);
          msg.addTrailerMsg(newMsg);
        } else CMLib.commands().postSay(observer, source, L("Gee, thanks. :)"), true, false);
        ((Coins) msg.tool()).destroy();
      } else if (!CMLib.flags().canBeSeenBy(source, observer))
        CMLib.commands()
            .postSay(observer, null, L("Wha?  Where did this come from?  Cool!"), true, false);
    } else if ((msg.source() == observer)
        && (msg.target() instanceof MOB)
        && (msg.targetMinor() == CMMsg.TYP_SPEAK)
        && (msg.tool() instanceof Coins)
        && (((Coins) msg.tool()).amDestroyed())
        && (!msg.source().isMine(msg.tool()))
        && (!((MOB) msg.target()).isMine(msg.tool())))
      CMLib.beanCounter()
          .giveSomeoneMoney(msg.source(), (MOB) msg.target(), ((Coins) msg.tool()).getTotalValue());
  }
예제 #3
0
 @Override
 public void startBehavior(PhysicalAgent forMe) {
   if (forMe == null) return;
   if (!(forMe instanceof MOB)) return;
   // i suppose this is for accepting heavy loads of coin
   ((MOB) forMe).baseCharStats().setStat(CharStats.STAT_STRENGTH, 100);
   super.startBehavior(forMe);
 }
예제 #4
0
 @Override
 public void setParms(String newParm) {
   super.setParms(newParm);
   rates.clear();
   cut = 0.05;
   spaceMaxCut = 0.0;
   spaceMaxDistance = SpaceObject.Distance.GalaxyRadius.dm;
   newParm = newParm.toUpperCase();
   int x = newParm.indexOf('=');
   while (x > 0) {
     int lastSp = newParm.lastIndexOf(' ', x);
     if (lastSp < 0) lastSp = 0;
     if ((lastSp >= 0) && (lastSp < x - 1) && (Character.isLetter(newParm.charAt(x - 1)))) {
       String parm = newParm.substring(lastSp, x).trim().toUpperCase();
       while ((x < newParm.length()) && (newParm.charAt(x) != '=')) x++;
       if (x < newParm.length()) {
         while ((x < newParm.length())
             && (!Character.isDigit(newParm.charAt(x)))
             && (newParm.charAt(x) != '.')) x++;
         if (x < newParm.length()) {
           newParm = newParm.substring(x);
           x = 0;
           while ((x < newParm.length())
               && ((Character.isDigit(newParm.charAt(x))) || (newParm.charAt(x) == '.'))) x++;
           double val = CMath.s_double(newParm.substring(0, x));
           if (newParm.substring(0, x).indexOf('.') < 0)
             val = CMath.s_long(newParm.substring(0, x));
           if (x < newParm.length()) newParm = newParm.substring(x + 1);
           else newParm = "";
           if (parm.equalsIgnoreCase("default")) parm = "";
           if (parm.equalsIgnoreCase("spacemaxcut")) spaceMaxCut = val / 100.0;
           else if (parm.equalsIgnoreCase("spacemaxdistance"))
             spaceMaxDistance =
                 Math.round(CMath.mul(SpaceObject.Distance.GalaxyRadius.dm, val / 100.0));
           else if (parm.equalsIgnoreCase("cut")) cut = val / 100.0;
           else rates.put(parm, Double.valueOf(val / 100.0));
         }
       }
     }
     x = newParm.indexOf('=');
   }
 }