Package games.stendhal.server.entity.item

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


    final StendhalRPZone localzone = new StendhalRPZone("testzone", 20, 20);
    final Player player = createPlayer("bob");
    localzone.add(player);

    // first put some seeds on the floor
    StackableItem item = (StackableItem) SingletonRepository.getEntityManager().getItem("seed");
    item.setQuantity(5);
    localzone.add(item);
    assertEquals(1, localzone.getItemsOnGround().size());
    assertEquals(0, localzone.getItemsOnGround().toArray(new StackableItem[0])[0].getX());
    assertEquals(0, localzone.getItemsOnGround().toArray(new StackableItem[0])[0].getY());

    LayerDefinition collisionLayer = new LayerDefinition(10, 10);
    collisionLayer.setName("collision");
    collisionLayer.build();
    collisionLayer.set(0, 1, 255);
    localzone.addCollisionLayer("collisionlayer", collisionLayer);

    // now test the displacement action
    final RPAction displace = new RPAction();
    displace.put("type", "displace");
    displace.put("baseitem", item.getID().getObjectID());
    displace.put("quantity", "2");
    displace.put("x", player.getX());
    displace.put("y", player.getY()+1);

    new DisplaceAction().onAction(player, displace);
View Full Code Here


    final Player player2 = createPlayer("alice");
    player2.setPosition(0, 0);
    localzone.add(player2);

    final StackableItem item = (StackableItem) SingletonRepository.getEntityManager().getItem("money");
    localzone.add(item);

    final RPAction displace = new RPAction();
    displace.put("type", "displace");
    displace.put("baseitem", item.getID().getObjectID());
    displace.put("quantity", "1");
    displace.put("x", player.getX());
    displace.put("y", player.getY() + 1);

    final DisplaceAction action = new DisplaceAction();
View Full Code Here

    final StendhalRPZone localzone = new StendhalRPZone("testzone", 20, 20);
    final Player player = createPlayer("bob");
    localzone.add(player);

    // first put some money on the floor
    StackableItem money = (StackableItem) SingletonRepository.getEntityManager().getItem("money");
    money.setQuantity(10);
    localzone.add(money);
    StackableItem[] items = localzone.getItemsOnGround().toArray(new StackableItem[0]);
    assertEquals(1, items.length);
    assertEquals(10, items[0].getQuantity());

    // now test the displacement action with a too high quantity
    final RPAction displace = new RPAction();
    displace.put("type", "displace");
    displace.put("baseitem", money.getID().getObjectID());
    displace.put("quantity", "20");
    displace.put("x", player.getX());
    displace.put("y", player.getY() + 1);

    final DisplaceAction action = new DisplaceAction();
View Full Code Here

    en.step(player, "hi");
    assertTrue(npc.isTalking());
    assertEquals(
        "Hallo! Glad to see you in my kitchen where I make #pizza and #sandwiches.",
        getReply(npc));
    final StackableItem cheese = new StackableItem("cheese", "", "", null);
    cheese.setQuantity(2);
    cheese.setID(new ID(2, ZONE_NAME));
    player.getSlot("bag").add(cheese);
    final StackableItem bread = new StackableItem("bread", "", "", null);
    bread.setQuantity(1);
    bread.setID(new ID(1, ZONE_NAME));
    player.getSlot("bag").add(bread);
    final StackableItem ham = new StackableItem("ham", "", "", null);
    ham.setID(new ID(3, ZONE_NAME));
    player.getSlot("bag").add(ham);
    assertEquals(2, player.getNumberOfEquipped("cheese"));
    assertEquals(1, player.getNumberOfEquipped("bread"));
    assertEquals(1, player.getNumberOfEquipped("ham"));
View Full Code Here

    en.step(player, "hi");
    assertTrue(npc.isTalking());
    assertEquals(
        "Hallo! Glad to see you in my kitchen where I make #pizza and #sandwiches.",
        getReply(npc));
    final StackableItem cheese = new StackableItem("cheese", "", "", null);
    cheese.setQuantity(4);
    cheese.setID(new ID(2, ZONE_NAME));
    player.getSlot("bag").add(cheese);
    final StackableItem bread = new StackableItem("bread", "", "", null);
    bread.setQuantity(2);
    bread.setID(new ID(1, ZONE_NAME));
    player.getSlot("bag").add(bread);
    final StackableItem ham = new StackableItem("ham", "", "", null);
    ham.setQuantity(2);
    ham.setID(new ID(3, ZONE_NAME));
    player.getSlot("bag").add(ham);
    assertEquals(4, player.getNumberOfEquipped("cheese"));
    assertEquals(2, player.getNumberOfEquipped("bread"));
    assertEquals(2, player.getNumberOfEquipped("ham"));
View Full Code Here

    HouseUtilities.clearCache();

    assertTrue(en.step(player, "50"));
    assertEquals("You do not have enough money to buy a house!", getReply(npc));
   
    final StackableItem money = (StackableItem)SingletonRepository.getEntityManager().getItem("money");
    money.setQuantity(120000);
    player.equipToInventoryOnly(money);
   
    // don't answer anything
    assertFalse(en.step(player, "42"));
   
View Full Code Here

    en.step(player, "hi");
    assertTrue(npc.isTalking());
    assertEquals(
        "Hallo! Glad to see you in my kitchen where I make #pizza and #sandwiches.",
        getReply(npc));
    final StackableItem cheese = new StackableItem("cheese", "", "", null);
    cheese.setQuantity(6);
    cheese.setID(new ID(2, ZONE_NAME));
    player.getSlot("bag").add(cheese);
    final StackableItem bread = new StackableItem("bread", "", "", null);
    bread.setQuantity(3);
    bread.setID(new ID(1, ZONE_NAME));
    player.getSlot("bag").add(bread);
    final StackableItem ham = new StackableItem("ham", "", "", null);
    ham.setQuantity(10);
    ham.setID(new ID(3, ZONE_NAME));
    player.getSlot("bag").add(ham);
    assertEquals(6, player.getNumberOfEquipped("cheese"));
    assertEquals(3, player.getNumberOfEquipped("bread"));
    assertEquals(10, player.getNumberOfEquipped("ham"));
View Full Code Here

   *
   * @param player
   *            The player who sells
   */
  protected void payPlayer(ItemParserResult res, final Player player) {
    final StackableItem money = (StackableItem) SingletonRepository.getEntityManager().getItem("money");
    money.setQuantity(getCharge(res, player));
    player.equipOrPutOnGround(money);
  }
View Full Code Here

      npc.say("Welcome back! I'm still busy with your order to "
          + getProductionActivity() + " " + Grammar.quantityplnoun(numberOfProductItems, getProductName(), "a")
          + " for you. Come back in "
          + getApproximateRemainingTime(player) + " to get it.");
    } else {
      final StackableItem products = (StackableItem) SingletonRepository.getEntityManager().getItem(
          getProductName());

      products.setQuantity(numberOfProductItems);

      if (isProductBound()) {
        products.setBoundTo(player.getName());
      }

      if (player.equipToInventoryOnly(products)) {         
        npc.say("Welcome back! I'm done with your order. Here you have "
          + Grammar.quantityplnoun(numberOfProductItems,
              getProductName(), "the") + ".");
        player.setQuest(questSlot, "done");
        // give some XP as a little bonus for industrious workers
        player.addXP(numberOfProductItems);
        player.notifyWorldAboutChanges();
        player.incProducedCountForItem(getProductName(), products.getQuantity());
        SingletonRepository.getAchievementNotifier().onProduction(player);
      } else {
        npc.say("Welcome back! I'm done with your order. But right now you cannot take the "
            + Grammar.plnoun(numberOfProductItems, getProductName())
            + ". Come back when you have space.");
View Full Code Here

              npc.say("Haaaa heee woooo hoo!");
            } else {
              npc.say("The boss gave me these " 
                  + Grammar.quantityplnoun(numberOfProductItems, "silk thread", "")
                  + ". Price gets his students to do his dirty work for him.");
              final StackableItem products = (StackableItem) SingletonRepository.getEntityManager().getItem(
                                                              "silk thread");
             
              player.addXP(100);
              products.setQuantity(numberOfProductItems);
              products.setBoundTo(player.getName());
              player.setQuest(mithrilcloak.getQuestSlot(), "got_thread");
              player.equipOrPutOnGround(products);
              player.notifyWorldAboutChanges();
            }
          }
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.