Esempio n. 1
0
 public Item buildMyThing(MOB mob, Room room) {
   Area A = room.getArea();
   boolean bonusWorthy = (Druid_MyPlants.myPlant(room, mob, 0) == null);
   Vector V = Druid_MyPlants.myAreaPlantRooms(mob, room.getArea());
   int pct = 0;
   if (A.getAreaIStats()[Area.Stats.VISITABLE_ROOMS.ordinal()] > 10)
     pct =
         (int)
             Math.round(
                 100.0
                     * CMath.div(
                         V.size(), A.getAreaIStats()[Area.Stats.VISITABLE_ROOMS.ordinal()]));
   Item I = buildMyPlant(mob, room);
   if ((I != null)
       && ((mob.charStats().getCurrentClass().baseClass().equalsIgnoreCase("Druid"))
           || (CMSecurity.isASysOp(mob)))) {
     if (!CMLib.law().isACity(A)) {
       if (pct > 0) {
         int newPct =
             (int)
                 Math.round(
                     100.0
                         * CMath.div(
                             V.size(), A.getAreaIStats()[Area.Stats.VISITABLE_ROOMS.ordinal()]));
         if ((newPct >= 50) && (A.fetchEffect("Chant_DruidicConnection") == null)) {
           Ability A2 = CMClass.getAbility("Chant_DruidicConnection");
           if (A2 != null) A2.invoke(mob, A, true, 0);
         }
       }
     } else if ((bonusWorthy) && (!mob.isMonster())) {
       long[] num = (long[]) plantBonuses.get(mob.Name() + "/" + room.getArea().Name());
       if ((num == null)
           || (System.currentTimeMillis() - num[1]
               > (room.getArea().getTimeObj().getDaysInMonth()
                   * room.getArea().getTimeObj().getHoursInDay()
                   * CMProps.getMillisPerMudHour()))) {
         num = new long[2];
         plantBonuses.remove(mob.Name() + "/" + room.getArea().Name());
         plantBonuses.put(mob.Name() + "/" + room.getArea().Name(), num);
         num[1] = System.currentTimeMillis();
       }
       if (V.size() >= num[0]) {
         num[0]++;
         if (num[0] < 19) {
           mob.tell("You have made this city greener.");
           CMLib.leveler().postExperience(mob, null, null, (int) num[0], false);
         }
       }
     }
   }
   return I;
 }
Esempio n. 2
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {

    int type = mob.location().domainType();
    if (((type & Room.INDOORS) > 0)
        || (type == Room.DOMAIN_OUTDOORS_AIR)
        || (type == Room.DOMAIN_OUTDOORS_CITY)
        || (type == Room.DOMAIN_OUTDOORS_SPACEPORT)
        || (type == Room.DOMAIN_OUTDOORS_UNDERWATER)
        || (type == Room.DOMAIN_OUTDOORS_WATERSURFACE)) {
      mob.tell("That magic won't work here.");
      return false;
    }
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    boolean success = proficiencyCheck(mob, 0, auto);

    if (success) {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              mob.location(),
              this,
              verbalCastCode(mob, mob.location(), auto),
              auto ? "" : "^S<S-NAME> " + prayForWord(mob) + " to make the land fruitful.^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        beneficialAffect(
            mob,
            mob.location(),
            asLevel,
            CMLib.ableMapper().qualifyingClassLevel(mob, this)
                * (int)
                    ((CMProps.getMillisPerMudHour()
                            * ((long) mob.location().getArea().getTimeObj().getHoursInDay()))
                        / CMProps.getTickMillis()));
      }

    } else
      beneficialWordsFizzle(
          mob,
          null,
          "<S-NAME> " + prayForWord(mob) + " to make the land fruitful, but nothing happens.");

    // return whether it worked
    return success;
  }