コード例 #1
0
 public void check(MOB mob, Armor A) {
   if (!layered) {
     checked = true;
     disabled = false;
   }
   if (A.amWearingAt(Wearable.IN_INVENTORY)) {
     checked = false;
     return;
   }
   if (checked) return;
   Item I = null;
   disabled = false;
   for (int i = 0; i < mob.numItems(); i++) {
     I = mob.getItem(i);
     if ((I instanceof Armor)
         && (!I.amWearingAt(Wearable.IN_INVENTORY))
         && ((I.rawWornCode() & A.rawWornCode()) > 0)
         && (I != A)) {
       disabled = A.getClothingLayer() <= ((Armor) I).getClothingLayer();
       if (disabled) {
         break;
       }
     }
   }
   checked = true;
 }
コード例 #2
0
  @Test
  public void testShuffled() {

    for (Integer[] perm : perms) {
      Group group = new Group("group");

      for (Integer i : perm) {
        Item item = new Item(group, i);
        group.add(item);
      }

      Queueable[] elems = group.getQueue();
      for (Queueable elem : elems) {
        Item item = (Item) elem;
        //        System.out.print( " " + item.getSalience() + "/"  + item.getActivationNumber() +
        // "/" + item.getIndex() );
        if (item.getIndex() % 2 == 0) {
          group.remove(item);
          group.add(item);
        }
      }
      boolean ok = true;
      StringBuilder sb = new StringBuilder("queue:");
      for (int i = max - 1; i >= 0; i--) {
        int sal = group.getNext().getSalience();
        sb.append(" ").append(sal);
        if (sal != i) ok = false;
      }
      assertTrue("incorrect order in " + sb.toString(), ok);
      //      System.out.println( sb.toString() );
    }
  }
コード例 #3
0
 public Set<MOB> getDeadMOBsFrom(Environmental whoE) {
   if (whoE instanceof MOB) {
     final MOB mob = (MOB) whoE;
     final Room room = mob.location();
     if (room != null) return getEveryoneHere(mob, room);
   } else if (whoE instanceof Item) {
     final Item item = (Item) whoE;
     final Environmental E = item.owner();
     if (E != null) {
       final Room room = getTickersRoom(whoE);
       if (room != null) {
         if ((E instanceof MOB) && ((mask == null) || (CMLib.masking().maskCheck(mask, E, false))))
           return new XHashSet<MOB>((MOB) E);
         else if (E instanceof Room) return getEveryoneHere(null, (Room) E);
         room.recoverRoomStats();
       }
     }
   } else if (whoE instanceof Room) return getEveryoneHere(null, (Room) whoE);
   else if (whoE instanceof Area) {
     final Set<MOB> allMobs = new HashSet<MOB>();
     for (final Enumeration r = ((Area) whoE).getMetroMap(); r.hasMoreElements(); ) {
       final Room R = (Room) r.nextElement();
       allMobs.addAll(getEveryoneHere(null, R));
     }
   }
   return new HashSet<MOB>();
 }
コード例 #4
0
ファイル: ImplSimpleDBService.java プロジェクト: amciver/Trax
    @Override
    protected TreeMap<Float, DropsiteLocation> doInBackground(
        android.location.Location... location) {

      TreeMap<Float, DropsiteLocation> locations = new TreeMap<Float, DropsiteLocation>();

      try {

        if (location[0] != null) {
          android.location.Location currentLocation = location[0];

          SelectResult result =
              SimpleDB.getInstance()
                  .select(new SelectRequest("select * from `Dropsites` limit 25"));
          for (Item dropsite : result.getItems()) {
            android.location.Location dropsiteLocation =
                new android.location.Location(currentLocation.getProvider());

            DropsiteLocation internalDropsiteLocation = new DropsiteLocation();
            internalDropsiteLocation.setId(dropsite.getName());

            // used to temporarily store hours of open and close for each location
            Hashtable<Integer, String> dateOpen = new Hashtable<Integer, String>();
            Hashtable<Integer, String> dateClose = new Hashtable<Integer, String>();

            for (Attribute attribute : dropsite.getAttributes()) {

              if (attribute.getName().equalsIgnoreCase("location"))
                internalDropsiteLocation.setLocation(attribute.getValue());
              if (attribute.getName().equalsIgnoreCase("description"))
                internalDropsiteLocation.setDescription(attribute.getValue());

              if (attribute.getName().equalsIgnoreCase("start_collection"))
                internalDropsiteLocation.setDateOpen(DateTime.parse(attribute.getValue()));
              if (attribute.getName().equalsIgnoreCase("end_collection"))
                internalDropsiteLocation.setDateClose(DateTime.parse(attribute.getValue()));

              if (attribute.getName().equalsIgnoreCase("lat"))
                dropsiteLocation.setLatitude(Double.parseDouble(attribute.getValue()));
              if (attribute.getName().equalsIgnoreCase("lng"))
                dropsiteLocation.setLongitude(Double.parseDouble(attribute.getValue()));

              if (attribute.getName().equalsIgnoreCase("city"))
                internalDropsiteLocation.setCityCode(attribute.getValue());
            }

            // store the location of the lot
            internalDropsiteLocation.setPoint(
                new LatLng(dropsiteLocation.getLatitude(), dropsiteLocation.getLongitude()));

            // save it to our locations listing to return back to the consumer
            locations.put(currentLocation.distanceTo(dropsiteLocation), internalDropsiteLocation);
          }
        }
      } catch (Exception e) {
        Log.e("GetDropsitesTask", "Failure attempting to get locations", e);
      }

      return locations;
    }
コード例 #5
0
 @Override
 public boolean run(final Item item) {
   final LocalPlayerCharacter character = WakfuGameEntity.getInstance().getLocalPlayer();
   if (character.getBags().getItemFromInventories(item.getUniqueId()) == null) {
     ReduceDeadStateItemAction.m_logger.error(
         (Object)
             "[ItemAction] On essaye de lancer une action avec un item qui n'est pas dans les bags");
     return false;
   }
   boolean hasDeadState = false;
   final List<StateRunningEffect> states = character.getRunningEffectManager().getRunningState();
   for (int i = 0; i < states.size(); ++i) {
     final StateRunningEffect effect = states.get(i);
     if (effect.getState() == null || effect.getState().isStateForDeath()) {
       hasDeadState = true;
       break;
     }
   }
   if (!hasDeadState) {
     ReduceDeadStateItemAction.m_logger.warn(
         (Object) "Tentative d'utilisation d'un item de reduction de DEAD_STATE sans en avoir");
     return false;
   }
   this.sendRequest(item.getUniqueId());
   return true;
 }
コード例 #6
0
 /** fetch the feed from the RSS Url */
 public String fetchFeed() {
   StringBuffer feed = new StringBuffer();
   for (Iterator<Item> I = contents.values().iterator(); I.hasNext(); ) {
     Item item = I.next();
     String itemUrl = item.getUrl();
     try {
       URL feedUrl = new URL(itemUrl);
       Charset encoding = Charset.defaultCharset();
       BufferedReader bufferedReader =
           new BufferedReader(new InputStreamReader(feedUrl.openStream(), encoding));
       // String inputLine;
       int feedChar;
       /*while ((inputLine = bufferedReader.readLine()) != null) {
       feed.append(inputLine);
       }*/
       // read individual characters
       while ((feedChar = bufferedReader.read()) != -1) {
         char value = (char) feedChar;
         if (value == '"') {
           feed.append("\\\"");
         } else if (value == '\r' || value == '\n') {
           feed.append("\\n");
         } else {
           feed.append(value);
         }
         // feed.append(value);
       }
       bufferedReader.close();
     } catch (Exception e) {
       System.out.println(e.getMessage());
     }
   }
   return feedJson(feed.toString());
 }
コード例 #7
0
  /** @return XML representation of cart contents */
  public String toXml() {
    StringBuffer xml = new StringBuffer();
    xml.append("<?xml version=\"1.0\"?>\n");
    // Append the current system time to check for latest async calls
    xml.append(
        "<cart generated=\""
            + System.currentTimeMillis()
            + "\" total=\""
            + getCartTotal()
            + "\">\n");
    // Generate xml tags and values by iterating through the contents
    for (Iterator<Item> I = contents.values().iterator(); I.hasNext(); ) {
      Item item = I.next();
      // int itemQuantity = contents.get(item).intValue();

      xml.append("<item code=\"" + item.getCode() + "\">\n");
      xml.append("<name>");
      xml.append(item.getName());
      xml.append("</name>\n");
      // xml.append("<quantity>");
      // xml.append(itemQuantity);
      // xml.append("</quantity>\n");
      xml.append("</item>\n");
    }
    // xml.append("<feed>").append(cartXml).append("</feed>\n");
    xml.append("</cart>\n");
    return xml.toString();
  }
コード例 #8
0
  /**
   * See which items are possible to get the backup file from cloud.
   *
   * @param context DSpace context
   * @param item iterator of items
   * @return integer set with all the IDs Items that are possible to get the backup file from cloud
   */
  public Set<Integer> checkPossibleItemsGet(Context context, ItemIterator items) {
    // This will contain all the Items IDs that backup files could be get from cloud
    Set<Integer> setInfo = new HashSet<Integer>();

    try {
      // if exist some item to evaluate make the connection and
      // get items backups files in cloud
      if (items.hasNext() == true) {
        this.makeConnection();
        this.filesInCloud.putAll(this.newCloudConnection.getInfoFilesIn(Constants.ITEM));
      }

      // do the operation for all items
      while (items.hasNext() == true) {
        Item objItem = items.next();
        // check if it is possible and necessary to get a backup file from cloud
        Boolean checkCorrect = this.couldGetFileFromCloud(context, objItem.getID(), Constants.ITEM);
        // add the ID collection to set if correct
        if (checkCorrect == true) setInfo.add(objItem.getID());
      }

      // close the connection to cloud
      this.closeConnection();

    } catch (SQLException ex) {
      Logger.getLogger(ActualContentManagement.class.getName()).log(Level.SEVERE, null, ex);
    }

    return setInfo;
  }
コード例 #9
0
ファイル: Item.java プロジェクト: yhrabovskyi/mini-shop
  /**
   * Creates an item object from String parameters and id (needed when edit form is performed).
   *
   * @param conn connection to database
   * @param param map of parameters to set
   * @param id id of item
   * @return an item object
   */
  public static Item createItem(Connection conn, Map<String, String[]> param, String id)
      throws SQLException {

    Item item = createItem(conn, param);
    item.setId(Integer.parseInt(id));
    return item;
  }
コード例 #10
0
  private String buildInvoice() {
    double taxRate = 6;
    String message;

    this.grandTotal = ((taxRate / 100) * this.subtotal) + this.subtotal;

    DateFormat dateFormat = new SimpleDateFormat("dd/MM/YY HH:mm:ss z");
    this.transDate = new Date();

    message = "Date: " + dateFormat.format(this.transDate) + "\n\n";
    message += "Number of line items: " + this.totalItems + "\n\n";
    message += "Item# / ID / Title / Price / Qty / Disc % / Subtotal:\n\n";
    int counter = 0;
    for (Item i : order.getOrder()) {
      counter++;
      message += counter + ". " + i.toString() + "\n";
    }
    message += "\n";
    message += "Order subtotal: " + formatter.format(this.subtotal) + "\n\n";
    message += "Tax rate: " + taxRate + "%\n\n";
    message += "Tax amount: " + formatter.format(((taxRate / 100) * this.subtotal)) + "\n\n";
    message += "Order total: " + formatter.format(this.grandTotal) + "\n\n";
    message += "Thanks for shopping at Funky Town Books\n\n";

    return message;
  }
コード例 #11
0
ファイル: Inventory.java プロジェクト: renokun/CoffeeMud
 public static InventoryList fetchInventory(MOB seer, MOB mob) {
   final InventoryList lst = new InventoryList();
   Vector<Coins> coinsV = null;
   int insertAt = -1;
   CMLib.beanCounter().getTotalAbsoluteNativeValue(mob);
   for (final Enumeration<Item> i = mob.items(); i.hasMoreElements(); ) {
     final Item thisItem = i.nextElement();
     if (thisItem == null) continue;
     if ((thisItem.container() == null) && (thisItem.amWearingAt(Wearable.IN_INVENTORY))) {
       if (CMLib.flags().canBeSeenBy(thisItem, seer)) lst.foundAndSeen = true;
       else lst.foundButUnseen = true;
       if ((!(thisItem instanceof Coins)) || (((Coins) thisItem).getDenomination() == 0.0))
         lst.viewItems.add(thisItem);
       else {
         coinsV = lst.moneyItems.get(((Coins) thisItem).getCurrency());
         if (coinsV == null) {
           coinsV = new Vector<Coins>();
           lst.moneyItems.put(((Coins) thisItem).getCurrency(), coinsV);
         }
         for (insertAt = 0; insertAt < coinsV.size(); insertAt++)
           if (coinsV.get(insertAt).getDenomination() > ((Coins) thisItem).getDenomination())
             break;
         if (insertAt >= coinsV.size()) coinsV.add((Coins) thisItem);
         else coinsV.insertElementAt((Coins) thisItem, insertAt);
       }
     }
   }
   return lst;
 }
コード例 #12
0
  // Create workflow start provenance message
  protected void recordStart(Context context, Item myitem)
      throws SQLException, IOException, AuthorizeException {
    // get date
    DCDate now = DCDate.getCurrent();

    // Create provenance description
    String provmessage;

    if (myitem.getSubmitter() != null) {
      provmessage =
          "Submitted by "
              + myitem.getSubmitter().getFullName()
              + " ("
              + myitem.getSubmitter().getEmail()
              + ") on "
              + now.toString()
              + "\n";
    } else
    // null submitter
    {
      provmessage = "Submitted by unknown (probably automated) on" + now.toString() + "\n";
    }

    // add sizes and checksums of bitstreams
    provmessage += installItemService.getBitstreamProvenanceMessage(context, myitem);

    // Add message to the DC
    itemService.addMetadata(
        context, myitem, MetadataSchema.DC_SCHEMA, "description", "provenance", "en", provmessage);
    itemService.update(context, myitem);
  }
コード例 #13
0
  /**
   * Commit the contained item to the main archive. The item is associated with the relevant
   * collection, added to the search index, and any other tasks such as assigning dates are
   * performed.
   *
   * @return the fully archived item.
   */
  @Override
  public Item archive(Context context, BasicWorkflowItem workflowItem)
      throws SQLException, IOException, AuthorizeException {
    // FIXME: Check auth
    Item item = workflowItem.getItem();
    Collection collection = workflowItem.getCollection();

    log.info(
        LogManager.getHeader(
            context,
            "archive_item",
            "workflow_item_id="
                + workflowItem.getID()
                + "item_id="
                + item.getID()
                + "collection_id="
                + collection.getID()));

    installItemService.installItem(context, workflowItem);

    // Log the event
    log.info(
        LogManager.getHeader(
            context,
            "install_item",
            "workflow_id=" + workflowItem.getID() + ", item_id=" + item.getID() + "handle=FIXME"));

    return item;
  }
コード例 #14
0
ファイル: Blacksmithing.java プロジェクト: kingdavid127/MUD
 @Override
 public boolean mayICraft(final Item I) {
   if (I == null) return false;
   if (!super.mayBeCrafted(I)) return false;
   if (((I.material() & RawMaterial.MATERIAL_MASK) != RawMaterial.MATERIAL_METAL)
       && ((I.material() & RawMaterial.MATERIAL_MASK) != RawMaterial.MATERIAL_MITHRIL))
     return false;
   if (CMLib.flags().isDeadlyOrMaliciousEffect(I)) return false;
   if (isANativeItem(I.Name()) && (!(I instanceof Armor)) && (!(I instanceof Weapon))) return true;
   if (I instanceof Rideable) {
     final Rideable R = (Rideable) I;
     final int rideType = R.rideBasis();
     switch (rideType) {
       case Rideable.RIDEABLE_LADDER:
       case Rideable.RIDEABLE_SLEEP:
       case Rideable.RIDEABLE_SIT:
       case Rideable.RIDEABLE_TABLE:
         return true;
       default:
         return false;
     }
   }
   if (I instanceof DoorKey) return true;
   if (I instanceof Shield) return false;
   if (I instanceof Weapon) return false;
   if (I instanceof Light) return true;
   if (I instanceof Armor) return false;
   if (I instanceof Container) return true;
   if ((I instanceof Drink) && (!(I instanceof Potion))) return true;
   if (I instanceof FalseLimb) return true;
   if (I.rawProperLocationBitmap() == Wearable.WORN_HELD) return true;
   return (isANativeItem(I.Name()));
 }
コード例 #15
0
ファイル: Preds.java プロジェクト: dirkk/basex
  /**
   * Checks if the predicates are successful for the specified item.
   *
   * @param it item to be checked
   * @param qc query context
   * @return result of check
   * @throws QueryException query exception
   */
  protected final boolean preds(final Item it, final QueryContext qc) throws QueryException {
    if (preds.length == 0) return true;

    // set context value and position
    final Value cv = qc.value;
    try {
      if (qc.scoring) {
        double s = 0;
        for (final Expr p : preds) {
          qc.value = it;
          final Item i = p.test(qc, info);
          if (i == null) return false;
          s += i.score();
        }
        it.score(Scoring.avg(s, preds.length));
      } else {
        for (final Expr p : preds) {
          qc.value = it;
          if (p.test(qc, info) == null) return false;
        }
      }
      return true;
    } finally {
      qc.value = cv;
    }
  }
コード例 #16
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    super.tick(ticking, tickID);
    if ((canAct(ticking, tickID)) && (ticking instanceof MOB)) {
      if (DoneEquipping) return true;

      final MOB mob = (MOB) ticking;
      final Room thisRoom = mob.location();
      if (thisRoom.numItems() == 0) return true;

      DoneEquipping = true;
      final Vector<Item> stuffIHad = new Vector<Item>();
      for (int i = 0; i < mob.numItems(); i++) stuffIHad.addElement(mob.getItem(i));
      mob.enqueCommand(new XVector<String>("GET", "ALL"), MUDCmdProcessor.METAFLAG_FORCED, 0);
      Item I = null;
      final Vector<Item> dropThisStuff = new Vector<Item>();
      for (int i = 0; i < mob.numItems(); i++) {
        I = mob.getItem(i);
        if ((I != null) && (!stuffIHad.contains(I))) {
          if (I instanceof DeadBody) dropThisStuff.addElement(I);
          else if ((I.container() != null) && (I.container() instanceof DeadBody))
            I.setContainer(null);
        }
      }
      for (int d = 0; d < dropThisStuff.size(); d++)
        mob.enqueCommand(
            new XVector<String>("DROP", "$" + dropThisStuff.elementAt(d).Name() + "$"),
            MUDCmdProcessor.METAFLAG_FORCED,
            0);
      mob.enqueCommand(new XVector<String>("WEAR", "ALL"), MUDCmdProcessor.METAFLAG_FORCED, 0);
    }
    return true;
  }
コード例 #17
0
ファイル: CoffeeUtensils.java プロジェクト: bbailey/ewok
 public boolean armorCheck(MOB mob, Item I, int allowedArmorLevel) {
   if ((((I instanceof Armor) || (I instanceof Shield)))
       && (I.rawProperLocationBitmap() & CharClass.ARMOR_WEARMASK) > 0) {
     boolean ok = true;
     switch (I.material() & RawMaterial.MATERIAL_MASK) {
       case RawMaterial.MATERIAL_LEATHER:
         if ((allowedArmorLevel == CharClass.ARMOR_CLOTH)
             || (allowedArmorLevel == CharClass.ARMOR_VEGAN)
             || (allowedArmorLevel == CharClass.ARMOR_OREONLY)
             || (allowedArmorLevel == CharClass.ARMOR_METALONLY)) ok = false;
         break;
       case RawMaterial.MATERIAL_METAL:
       case RawMaterial.MATERIAL_MITHRIL:
         if ((allowedArmorLevel == CharClass.ARMOR_CLOTH)
             || (allowedArmorLevel == CharClass.ARMOR_LEATHER)
             || (allowedArmorLevel == CharClass.ARMOR_NONMETAL)) ok = false;
         break;
       case RawMaterial.MATERIAL_ENERGY:
         if ((allowedArmorLevel == CharClass.ARMOR_METALONLY)
             || (allowedArmorLevel == CharClass.ARMOR_OREONLY)
             || (allowedArmorLevel == CharClass.ARMOR_VEGAN)) return false;
         break;
       case RawMaterial.MATERIAL_CLOTH:
         if ((allowedArmorLevel == CharClass.ARMOR_METALONLY)
             || (allowedArmorLevel == CharClass.ARMOR_OREONLY)
             || ((allowedArmorLevel == CharClass.ARMOR_VEGAN)
                 && ((I.material() == RawMaterial.RESOURCE_HIDE)
                     || (I.material() == RawMaterial.RESOURCE_FUR)
                     || (I.material() == RawMaterial.RESOURCE_FEATHERS)
                     || (I.material() == RawMaterial.RESOURCE_WOOL)))) ok = false;
         break;
       case RawMaterial.MATERIAL_PLASTIC:
       case RawMaterial.MATERIAL_WOODEN:
         if ((allowedArmorLevel == CharClass.ARMOR_CLOTH)
             || (allowedArmorLevel == CharClass.ARMOR_OREONLY)
             || (allowedArmorLevel == CharClass.ARMOR_LEATHER)
             || (allowedArmorLevel == CharClass.ARMOR_METALONLY)) ok = false;
         break;
       case RawMaterial.MATERIAL_ROCK:
       case RawMaterial.MATERIAL_GLASS:
         if ((allowedArmorLevel == CharClass.ARMOR_CLOTH)
             || (allowedArmorLevel == CharClass.ARMOR_LEATHER)
             || (allowedArmorLevel == CharClass.ARMOR_METALONLY)) ok = false;
         break;
       case RawMaterial.MATERIAL_FLESH:
         if ((allowedArmorLevel == CharClass.ARMOR_METALONLY)
             || (allowedArmorLevel == CharClass.ARMOR_VEGAN)
             || (allowedArmorLevel == CharClass.ARMOR_CLOTH)
             || (allowedArmorLevel == CharClass.ARMOR_OREONLY)) ok = false;
         break;
       default:
         if ((allowedArmorLevel == CharClass.ARMOR_METALONLY)
             || (allowedArmorLevel == CharClass.ARMOR_OREONLY)) ok = false;
         break;
     }
     return ok;
   }
   return true;
 }
コード例 #18
0
 /**
  * Return true if the Item <> exists.
  *
  * @param id - Name of the item.
  * @return true if the room as an item with that name.
  */
 public boolean existsItem(String id) {
   Iterator<Item> it = items.iterator();
   while (it.hasNext()) {
     Item aux = it.next();
     if (aux.getId().equalsIgnoreCase(id)) return true;
   }
   return false; // NO SE HA ENCONTRADO EL ITEM CON ESE ID
 }
コード例 #19
0
ファイル: ItemContainer.java プロジェクト: Lewix/textgame
 public Item itemOfType(String type) {
   for (Item it : itemList) {
     if (it.getType().equals(type)) {
       return it;
     }
   }
   return null;
 }
コード例 #20
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    if (commands.size() < 1) {
      mob.tell(
          L(
              "You must specify an item to fence, and possibly a ShopKeeper (unless it is implied)."));
      return false;
    }

    commands.add(0, "SELL"); // will be instantly deleted by parseshopkeeper
    final Environmental shopkeeper =
        CMLib.english().parseShopkeeper(mob, commands, L("Fence what to whom?"));
    if (shopkeeper == null) return false;
    if (commands.size() == 0) {
      mob.tell(L("Fence what?"));
      return false;
    }

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

    final boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              shopkeeper,
              this,
              CMMsg.MSG_SPEAK,
              auto ? "" : L("<S-NAME> fence(s) stolen loot to <T-NAMESELF>."));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        invoker = mob;
        addBackMap.clear();
        mob.addEffect(this);
        mob.recoverCharStats();
        commands.add(0, CMStrings.capitalizeAndLower("SELL"));
        mob.doCommand(commands, MUDCmdProcessor.METAFLAG_FORCED);
        commands.add(shopkeeper.name());
        mob.delEffect(this);
        for (Item I : addBackMap.keySet()) {
          if (mob.isMine(I)) {
            I.addEffect(addBackMap.get(I));
          }
        }
        addBackMap.clear();
        mob.recoverCharStats();
      }
    } else
      beneficialWordsFizzle(
          mob,
          shopkeeper,
          L(
              "<S-NAME> attempt(s) to fence stolen loot to <T-NAMESELF>, but make(s) <T-HIM-HER> too nervous."));

    // return whether it worked
    return success;
  }
コード例 #21
0
 public static boolean isPlant(Item I) {
   if ((I != null) && (I.rawSecretIdentity().length() > 0)) {
     for (final Enumeration<Ability> a = I.effects(); a.hasMoreElements(); ) {
       final Ability A = a.nextElement();
       if ((A != null) && (A.invoker() != null) && (A instanceof Chant_SummonPlants)) return true;
     }
   }
   return false;
 }
コード例 #22
0
ファイル: Trap_Spark.java プロジェクト: kingdavid127/MUD
 @Override
 public Trap setTrap(MOB mob, Physical P, int trapBonus, int qualifyingClassLevel, boolean perm) {
   if (P == null) return null;
   if (mob != null) {
     final Item I = findMostOfMaterial(mob.location(), RawMaterial.MATERIAL_METAL);
     if (I != null) super.destroyResources(mob.location(), I.material(), 10);
   }
   return super.setTrap(mob, P, trapBonus, qualifyingClassLevel, perm);
 }
コード例 #23
0
ファイル: Tailoring.java プロジェクト: bbailey/ewok
 protected boolean canMend(MOB mob, Environmental E, boolean quiet) {
   if (!super.canMend(mob, E, quiet)) return false;
   Item IE = (Item) E;
   if ((IE.material() & RawMaterial.MATERIAL_MASK) != RawMaterial.MATERIAL_CLOTH) {
     if (!quiet) commonTell(mob, "That's not made of any sort of cloth.  It can't be mended.");
     return false;
   }
   return true;
 }
コード例 #24
0
ファイル: Path.java プロジェクト: hetykai/android-3
 public void addMove(int x, int y) {
   Item item = new Item();
   item.x = x;
   item.y = y;
   item.duration = System.currentTimeMillis() - this.lastMoveTime;
   cost += item.duration;
   items.add(item);
   this.lastMoveTime = System.currentTimeMillis();
 }
コード例 #25
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    Item target = null;
    if ((commands.size() == 0) && (!auto) && (givenTarget == null))
      target = Prayer_Sacrifice.getBody(mob.location());
    if (target == null)
      target = getTarget(mob, mob.location(), givenTarget, commands, Wearable.FILTER_UNWORNONLY);
    if (target == null) return false;

    if ((!(target instanceof DeadBody))
        || (target.rawSecretIdentity().toUpperCase().indexOf("FAKE") >= 0)) {
      mob.tell(L("You may only desecrate the dead."));
      return false;
    }
    if ((((DeadBody) target).isPlayerCorpse())
        && (!((DeadBody) target).getMobName().equals(mob.Name()))
        && (((DeadBody) target).hasContent())) {
      mob.tell(L("You are not allowed to desecrate a players corpse."));
      return false;
    }

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

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

    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto
                  ? L("<T-NAME> feel(s) desecrated!")
                  : L("^S<S-NAME> desecrate(s) <T-NAMESELF> before @x1.^?", hisHerDiety(mob)));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (CMLib.flags().isEvil(mob)) {
          double exp = 5.0;
          final int levelLimit = CMProps.getIntVar(CMProps.Int.EXPRATE);
          final int levelDiff = (mob.phyStats().level()) - target.phyStats().level();
          if (levelDiff > levelLimit) exp = 0.0;
          if (exp > 0.0)
            CMLib.leveler()
                .postExperience(
                    mob, null, null, (int) Math.round(exp) + super.getXPCOSTLevel(mob), false);
        }
        target.destroy();
        mob.location().recoverRoomStats();
      }
    } else
      beneficialWordsFizzle(
          mob, target, L("<S-NAME> attempt(s) to desecrate <T-NAMESELF>, but fail(s)."));

    // return whether it worked
    return success;
  }
コード例 #26
0
ファイル: ItemContainer.java プロジェクト: Lewix/textgame
 public Item itemWithName(String name) {
   name = name.toLowerCase();
   for (Item it : itemList) {
     if (it.getName().toLowerCase().equals(name)) {
       return it;
     }
   }
   return null;
 }
コード例 #27
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;

    final boolean success = proficiencyCheck(mob, 0, auto);
    final String str =
        auto
            ? L("The unholy word is spoken.")
            : L("^S<S-NAME> speak(s) the unholy word@x1 to <T-NAMESELF>.^?", ofDiety(mob));

    final Room room = mob.location();
    if (room != null)
      for (int i = 0; i < room.numInhabitants(); i++) {
        final MOB target = room.fetchInhabitant(i);
        if (target == null) break;
        int affectType = CMMsg.MSG_CAST_VERBAL_SPELL;
        if (auto) affectType = affectType | CMMsg.MASK_ALWAYS;
        if (CMLib.flags().isGood(target)) affectType = affectType | CMMsg.MASK_MALICIOUS;

        if (success) {
          final CMMsg msg = CMClass.getMsg(mob, target, this, affectType, str);
          if (room.okMessage(mob, msg)) {
            room.send(mob, msg);
            if (msg.value() <= 0) {
              if (CMLib.flags().canBeHeardSpeakingBy(mob, target)) {
                final Item I = Prayer_Curse.getSomething(mob, true);
                if (I != null) {
                  Prayer_Curse.endLowerBlessings(I, CMLib.ableMapper().lowestQualifyingLevel(ID()));
                  I.recoverPhyStats();
                }
                Prayer_Curse.endLowerBlessings(
                    target, CMLib.ableMapper().lowestQualifyingLevel(ID()));
                beneficialAffect(mob, target, asLevel, 0);
                target.recoverPhyStats();
              } else if (CMath.bset(affectType, CMMsg.MASK_MALICIOUS))
                maliciousFizzle(mob, target, L("<T-NAME> did not hear the unholy word!"));
              else beneficialWordsFizzle(mob, target, L("<T-NAME> did not hear the unholy word!"));
            }
          }
        } else {
          if (CMath.bset(affectType, CMMsg.MASK_MALICIOUS))
            maliciousFizzle(
                mob,
                target,
                L("<S-NAME> attempt(s) to speak the unholy word to <T-NAMESELF>, but flub(s) it."));
          else
            beneficialWordsFizzle(
                mob,
                target,
                L("<S-NAME> attempt(s) to speak the unholy word to <T-NAMESELF>, but flub(s) it."));
          return false;
        }
      }

    // return whether it worked
    return success;
  }
コード例 #28
0
 public static Ability isPlant(Item I) {
   if ((I != null) && (I.rawSecretIdentity().length() > 0)) {
     for (int a = 0; a < I.numEffects(); a++) {
       Ability A = I.fetchEffect(a);
       if ((A != null) && (A.invoker() != null) && (A instanceof Chant_SummonPlants)) return A;
     }
   }
   return null;
 }
コード例 #29
0
  @Test
  public void In_ObjectIds() {
    Item i = new Item();
    i.setCtds(Arrays.asList(ObjectId.get(), ObjectId.get(), ObjectId.get()));
    ds.save(i);

    assertTrue(where(item, item.ctds.contains(i.getCtds().get(0))).count() > 0);
    assertTrue(where(item, item.ctds.contains(ObjectId.get())).count() == 0);
  }
コード例 #30
0
ファイル: Druid.java プロジェクト: kingdavid127/MUD
 @Override
 public void affectCharState(MOB affected, CharState affectableState) {
   super.affectCharState(affected, affectableState);
   if (affected.location() != null)
     for (int i = 0; i < affected.location().numItems(); i++) {
       final Item I = affected.location().getItem(i);
       if ((I != null) && (I.ID().equals("DruidicMonument")))
         affectableState.setMana(affectableState.getMana() + (affectableState.getMana() / 2));
     }
 }