Package games.stendhal.server.entity.trade

Examples of games.stendhal.server.entity.trade.Market


     * @param price price for the item
     * @param number number of items to sell
     * @return true if making the offer was successful, false otherwise
     */
    private boolean createOffer(Player player, Item item, int price, int number) {
      Market shop = TradeCenterZoneConfigurator.getShopFromZone(player.getZone());
      if(shop != null) {
        Offer o = shop.createOffer(player, item, Integer.valueOf(price), Integer.valueOf(number));
        if (o == null) {
          return false;
        }

        StringBuilder message = new StringBuilder("Offer for some ");
        message.append(item.getName());
        message.append(" at ");
        message.append(price);
        message.append(" created. ");
        String messageNumberOfOffers = "You have now made "
          + Grammar.quantityplnoun(Integer.valueOf(shop.countOffersOfPlayer(player)), "offer", "one") + ".";
        player.sendPrivateText(message.toString() + messageNumberOfOffers);
        return true;
      }
      return false;
    }
View Full Code Here


  }

  class ConfirmAcceptOfferChatAction implements ChatAction {
    public void fire (Player player, Sentence sentence, EventRaiser npc) {
      Offer offer = getOffer();
      Market m = TradeCenterZoneConfigurator.getShopFromZone(player.getZone());
      String itemname = offer.getItemName();
      if (m.acceptOffer(offer,player)) {
        // Successful trade. Tell the offerer
        StringBuilder earningToFetchMessage = new StringBuilder();
        earningToFetchMessage.append("Your ");
        earningToFetchMessage.append(itemname);
        earningToFetchMessage.append(" was sold. You can now fetch your earnings from me.");

        logger.debug("sending a notice to '" + offer.getOfferer() + "': " + earningToFetchMessage.toString());
        DBCommandQueue.get().enqueue(new StoreMessageCommand("Harold", offer.getOfferer(), earningToFetchMessage.toString(), "N"));

        npc.say("Thanks.");
        // Obsolete the offers, since the list has changed
        ((MarketManagerNPC) npc.getEntity()).getOfferMap().clear();
      } else {
        // Trade failed for some reason. Check why, and inform the player
        if (!m.contains(offer)) {
          int quantity = getQuantity(offer.getItem());
          npc.say("I'm sorry, but " + Grammar.thatthose(quantity) + " "
              + Grammar.quantityplnoun(quantity, offer.getItem().getName(), "the")
              + " " + Grammar.isare(quantity)
              + " no longer for sale.");
View Full Code Here

    }
  }
 
  private void removeOffer(Player player, EventRaiser npc) {
    Offer offer = getOffer();
    Market m = TradeCenterZoneConfigurator.getShopFromZone(player.getZone());
    m.removeOffer(offer,player);
    npc.say("Ok.");
  }
View Full Code Here

TOP

Related Classes of games.stendhal.server.entity.trade.Market

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.