/**
* Test for displaceItem.
*/
@Test
public void testDisplaceItem() {
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);
StackableItem[] items = localzone.getItemsOnGround().toArray(new StackableItem[0]);
assertEquals(1, items.length);
assertEquals(0, items[0].getX());
assertEquals(0, items[0].getY());
assertEquals(5, items[0].getQuantity());
// 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);
final DisplaceAction action = new DisplaceAction();
assertTrue(displace.has(EquipActionConsts.BASE_ITEM));
action.onAction(player, displace);
assertEquals(0, player.events().size());
items = localzone.getItemsOnGround().toArray(new StackableItem[0]);
assertEquals(2, items.length);
assertEquals(0, items[0].getX());
assertEquals(0, items[0].getY());
assertEquals(3, items[0].getQuantity());
assertEquals(0, items[1].getX());