Beispiel #1
0
 public void unInvoke() {
   // undo the affects of this spell
   MOB recheckMOB = null;
   if ((canBeUninvoked()) && (affected != null)) {
     if (affected instanceof MOB) {
       MOB mob = (MOB) affected;
       if ((mob.location() != null) && (!mob.amDead()))
         mob.location()
             .show(
                 mob, null, CMMsg.MSG_OK_VISUAL, "<S-NAME> return(s) to <S-HIS-HER> normal size.");
       recheckMOB = mob;
     } else if (affected instanceof Item) {
       Item item = (Item) affected;
       if (item.owner() != null) {
         if (item.owner() instanceof Room)
           ((Room) item.owner())
               .showHappens(CMMsg.MSG_OK_VISUAL, item.name() + " returns to its proper size.");
         else if (item.owner() instanceof MOB) {
           ((MOB) item.owner()).tell(item.name() + " returns to its proper size.");
           recheckMOB = (MOB) item.owner();
         }
       }
     }
   }
   super.unInvoke();
   if (recheckMOB != null) CMLib.utensils().confirmWearability(recheckMOB);
 }
Beispiel #2
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    if ((!auto)
        && (!mob.isMonster())
        && (!disregardsArmorCheck(mob))
        && (mob.isMine(this))
        && (!renderedMundane)
        && (CMLib.dice().rollPercentage() < 50)) {
      if (!appropriateToMyFactions(mob)) {
        mob.tell(L("Extreme emotions disrupt your chant."));
        return false;
      } else if (!CMLib.utensils().armorCheck(mob, CharClass.ARMOR_LEATHER)) {
        mob.location()
            .show(
                mob,
                null,
                CMMsg.MSG_OK_VISUAL,
                L("<S-NAME> watch(es) <S-HIS-HER> armor absorb <S-HIS-HER> magical energy!"));
        return false;
      }
    }
    return true;
  }
Beispiel #3
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    Physical target = getAnyTarget(mob, commands, givenTarget, Wearable.FILTER_UNWORNONLY);
    if (target == null) return false;

    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    boolean success = proficiencyCheck(mob, 0, auto);
    if ((success) && ((target instanceof MOB) || (target instanceof Item))) {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto
                  ? "<T-NAME> feel(s) somewhat smaller."
                  : "^S<S-NAME> cast(s) a small spell on <T-NAMESELF>.^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        boolean isJustUnInvoking = false;
        if (target instanceof Item) {
          Ability A = target.fetchEffect("Spell_Shrink");
          if ((A != null) && (A.canBeUninvoked())) {
            A.unInvoke();
            isJustUnInvoking = true;
          }
        } else if (target instanceof MOB) {
          Ability A = target.fetchEffect("Spell_Grow");
          if ((A != null) && (A.canBeUninvoked())) {
            A.unInvoke();
            isJustUnInvoking = true;
          }
        }

        if ((!isJustUnInvoking) && (msg.value() <= 0)) {
          beneficialAffect(mob, target, asLevel, 0);
          if (target instanceof MOB) CMLib.utensils().confirmWearability((MOB) target);
        }
      }
    } else
      beneficialWordsFizzle(mob, target, "<S-NAME> attempt(s) to cast a small spell, but fail(s).");

    return success;
  }
 public static boolean doRentalProperty(Area A, String ID, String owner, int rent) {
   if (!CMProps.getBoolVar(CMProps.Bool.MUDSTARTED)) return false;
   final int month = A.getTimeObj().getMonth();
   final int day = A.getTimeObj().getDayOfMonth();
   final int year = A.getTimeObj().getYear();
   final Object O = Resources.getResource("RENTAL INFO/" + owner);
   List<PlayerData> pDataV = null;
   if (O instanceof List) pDataV = (List<PlayerData>) O;
   else pDataV = CMLib.database().DBReadData(owner, "RENTAL INFO");
   if (pDataV == null) pDataV = new Vector();
   DatabaseEngine.PlayerData pData = null;
   if (pDataV.size() == 0) {
     pData = new DatabaseEngine.PlayerData();
     pData.who = owner;
     pData.section = "RENTAL INFO";
     pData.key = "RENTAL INFO/" + owner;
     pData.xml = ID + "|~>|" + day + " " + month + " " + year + "|~;|";
     CMLib.database().DBCreateData(owner, "RENTAL INFO", "RENTAL INFO/" + owner, pData.xml);
     pDataV.add(pData);
     Resources.submitResource("RENTAL INFO/" + owner, pDataV);
     return false;
   } else if (pDataV.get(0) != null) {
     pData = pDataV.get(0);
     String parse = pData.xml;
     int x = parse.indexOf("|~;|");
     final StringBuffer reparse = new StringBuffer("");
     boolean changesMade = false;
     boolean needsToPay = false;
     while (x >= 0) {
       String thisOne = parse.substring(0, x);
       if (thisOne.startsWith(ID + "|~>|")) {
         thisOne = thisOne.substring((ID + "|~>|").length());
         final Vector dateV = CMParms.parse(thisOne);
         if (dateV.size() == 3) {
           int lastYear = CMath.s_int((String) dateV.lastElement());
           int lastMonth = CMath.s_int((String) dateV.elementAt(1));
           final int lastDay = CMath.s_int((String) dateV.firstElement());
           while (!needsToPay) {
             if (lastYear < year) needsToPay = true;
             else if ((lastYear == year) && (lastMonth < month) && (day >= lastDay))
               needsToPay = true;
             if (needsToPay) {
               if (CMLib.beanCounter()
                   .modifyLocalBankGold(
                       A,
                       owner,
                       CMLib.utensils().getFormattedDate(A)
                           + ":Withdrawal of "
                           + rent
                           + ": Rent for "
                           + ID,
                       CMLib.beanCounter().getCurrency(A),
                       (-rent))) {
                 lastMonth++;
                 if (lastMonth > A.getTimeObj().getMonthsInYear()) {
                   lastMonth = 1;
                   lastYear++;
                 }
                 changesMade = true;
                 needsToPay = false;
               }
             } else break;
           }
           if (changesMade)
             reparse.append(ID + "|~>|" + lastDay + " " + lastMonth + " " + lastYear + "|~;|");
           if (needsToPay && (!changesMade)) return true;
         }
       } else reparse.append(thisOne + "|~;|");
       parse = parse.substring(x + 4);
       x = parse.indexOf("|~;|");
     }
     if (changesMade) {
       CMLib.database()
           .DBReCreateData(owner, "RENTAL INFO", "RENTAL INFO/" + owner, reparse.toString());
       pData = new DatabaseEngine.PlayerData();
       pData.who = owner;
       pData.section = "RENTAL INFO";
       pData.key = "RENTAL INFO/" + owner;
       pData.xml = reparse.toString();
       pDataV.set(0, pData);
       Resources.removeResource("RENTAL INFO/" + owner);
       Resources.submitResource("RENTAL INFO/" + owner, pDataV);
     }
     return needsToPay;
   }
   return false;
 }