Package games.stendhal.server.entity.item

Examples of games.stendhal.server.entity.item.StackableItem


      int summedUpEarnings = 0;
      //sum up
      for (Earning earningToSumUp : earningsToRemove) {
        summedUpEarnings = summedUpEarnings + earningToSumUp.getValue();
      }
      final StackableItem item = (StackableItem) SingletonRepository.getEntityManager().getItem("money");
      item.setQuantity(summedUpEarnings);
      if(earner.equipToInventoryOnly(item)) {
        //reward only if equipping was done
        for(Earning earningToReward : earningsToRemove) {
          if (earningToReward.shouldReward()) {
            applyTradingBonus(earner);
View Full Code Here


    player.setQuest("fishermans_license2", "done");
    en.step(player, "bye");
    assertEquals("Goodbye.", getReply(npc));

    // -----------------------------------------------
    final StackableItem money = (StackableItem)SingletonRepository.getEntityManager().getItem("money");
    money.setQuantity(100000);
    player.equipToInventoryOnly(money);

    en.step(player, "hi");
    assertEquals("Hello, player.", getReply(npc));
    en.step(player, "buy");
View Full Code Here

    en.step(player, quest.getTriggerPhraseToEnumerateMissingItems().get(0));
    assertEquals("i have not brought anything yet it should be all needed items",
        "#one, #two, and #three", getReply(npc));

    StackableItem item = new StackableItem("one", "", "", null);
    item.setQuantity(10);
    item.setID(new ID(2, "testzone"));
    player.getSlot("bag").add(item);
    en.step(player, "yes");
    assertEquals("item brought", quest.askForItemsAfterPlayerSaidHeHasItems(), getReply(npc));

    en.step(player, "one");
    assertEquals("item brought", quest.respondToItemBrought(), getReply(npc));
    en.step(player, "one");
    assertEquals("item brought", quest.respondToOfferOfNotMissingItem(), getReply(npc));
    npc.remove("text");
    assertEquals(ConversationStates.QUESTION_1, en.getCurrentState());
    en.step(player, quest.getTriggerPhraseToEnumerateMissingItems().get(0));
    final List<String> missing = new LinkedList<String>(quest.getNeededItems());
    missing.remove("one");
    assertEquals("two and three are missing", "#two and #three", getReply(npc));
    en.step(player, "two");
    assertEquals("item brought", quest.respondToOfferOfNotExistingItem("two"), getReply(npc));

    item = new StackableItem("two", "", "", null);
    item.setQuantity(10);
    item.setID(new ID(2, "testzone"));
    player.getSlot("bag").add(item);
    item = new StackableItem("three", "", "", null);
    item.setQuantity(10);
    item.setID(new ID(2, "testzone"));
    player.getSlot("bag").add(item);
    en.step(player, "three");
    assertEquals("item brought", quest.respondToItemBrought(), getReply(npc));
    en.step(player, "two");
    assertEquals("last item brought", quest.respondToLastItemBrought(), getReply(npc));
View Full Code Here

      final RPSlot rpslot = ((EntitySlot) parent.getSlot(slot)).getWriteableSlot();


      // check if the item can be merged with one already in the slot
      if (entity instanceof StackableItem) {
        final StackableItem stackEntity = (StackableItem) entity;
        // find a stackable item of the same type
        final Iterator<RPObject> it = rpslot.iterator();
        while (it.hasNext()) {
          final RPObject object = it.next();
          if (object instanceof StackableItem) {
            // found another stackable
            final StackableItem other = (StackableItem) object;
            if (other.isStackable(stackEntity)) {
              new ItemLogger().merge(player, stackEntity, other);

              // other is the same type...merge them
              other.add(stackEntity);
              entity = null;
              // do not process the entity further
              break;
            }
          }
View Full Code Here

   *
   * @return Entity to place somewhere else in the world
   */
  public Item removeFromWorld() {
    if (quantity != 0) {
      final StackableItem newItem = ((StackableItem) item).splitOff(quantity);
      new ItemLogger().splitOff(player, item, newItem, quantity);
      return newItem;
    } else {
      item.removeFromWorld();
      return item;
View Full Code Here

    PlayerTestHelper.registerPlayer(george);
    StendhalRPZone zone = new StendhalRPZone("shop");
    Market market = Market.createShop();
    zone.add(market);
    Item item = SingletonRepository.getEntityManager().getItem("axe");
    StackableItem erniesMoney = (StackableItem) SingletonRepository
        .getEntityManager().getItem("money");
    Integer price = Integer.valueOf(10);
    erniesMoney.setQuantity(price);
    george.equipToInventoryOnly(item);
   
    CIDSubmitAction.nameList.put("george", "georgescid");
   
    Offer offer = market.createOffer(george, item, price, 1);
View Full Code Here

    PlayerTestHelper.registerPlayer(george);
    StendhalRPZone zone = new StendhalRPZone("shop");
    Market market = Market.createShop();
    zone.add(market);
    Item item = SingletonRepository.getEntityManager().getItem("axe");
    StackableItem money = (StackableItem) SingletonRepository
        .getEntityManager().getItem("money");
    Integer price = Integer.valueOf(10);
    money.setQuantity(price);
    george.equipToInventoryOnly(item);
    george.equipToInventoryOnly(money);
   
    CIDSubmitAction.nameList.put("george", "georgescid");
   
View Full Code Here

        "*sigh* I SPECIFICALLY said that we need 10 pieces of ham!",
        getReply(katinkaNpc));
    assertTrue(enKatinka.step(player, "bye"));
    assertEquals("Goodbye!", getReply(katinkaNpc));
    // equip player with to less needed stuff
    final StackableItem ham = new StackableItem("ham", "", "", null);
    ham.setQuantity(5);
    ham.setID(new ID(2, ZONE_NAME));
    player.getSlot("bag").add(ham);
    assertEquals(5, player.getNumberOfEquipped("ham"));

    // bother katinka again
    assertTrue(enKatinka.step(player, "hi"));
    assertEquals("Welcome back! Have you brought the 10 pieces of ham?",
        getReply(katinkaNpc));
    assertTrue("lie", enKatinka.step(player, "yes"));
    assertEquals(
        "*sigh* I SPECIFICALLY said that we need 10 pieces of ham!",
        getReply(katinkaNpc));
    assertTrue(enKatinka.step(player, "bye"));
    assertEquals("Goodbye!", getReply(katinkaNpc));
    // equip player with to needed stuff
    final StackableItem ham2 = new StackableItem("ham", "", "", null);
    ham2.setQuantity(5);
    ham2.setID(new ID(3, ZONE_NAME));
    player.getSlot("bag").add(ham2);
    assertEquals(10, player.getNumberOfEquipped("ham"));
    // bring stuff to katinka
    assertTrue(enKatinka.step(player, "hi"));
    assertEquals("Welcome back! Have you brought the 10 pieces of ham?",
View Full Code Here

    fs.onUsed(player);
    assertEquals("You need a fishing rod for fishing.",
        player.events().get(0).get("text"));
    player.clearEvents();
    final StackableItem fishingRod = new StackableItem("fishing rod", "", "",
        null);
    fishingRod.setQuantity(1);
    fishingRod.setID(new ID(2, "testzone"));
    player.getSlot("bag").add(fishingRod);
    assertTrue(player.isEquipped("fishing rod"));
    fs.onUsed(player);
    assertEquals("You have started fishing.", player.events().get(0).get("text"));
    player.clearEvents();
View Full Code Here

    final SpeakerNPC npc = getNPC("Harold");
    final Engine en = npc.getEngine();
    player.addXP(1700);

    Item item = SingletonRepository.getEntityManager().getItem("axe");
    StackableItem playersMoney = (StackableItem) SingletonRepository
        .getEntityManager().getItem("money");
    Integer price = Integer.valueOf(1500);
    playersMoney.setQuantity(price);
    player.equipToInventoryOnly(item);
    player.equipToInventoryOnly(playersMoney);

    assertTrue(en.step(player, "hello"));
    assertEquals("Welcome to Semos trading center. How can I #help you?", getReply(npc));
View Full Code Here

TOP

Related Classes of games.stendhal.server.entity.item.StackableItem

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.