Package games.stendhal.server.core.engine

Examples of games.stendhal.server.core.engine.StendhalRPZone


  /**
   * Test for displacing non-item entities.
   */
  @Test
  public void testDisplaceBlood() {
    final StendhalRPZone localzone = new StendhalRPZone("testzone", 20, 20);
    final Player player = createPlayer("bob");
    localzone.add(player);

    Entity entity = new Blood();
    localzone.add(entity);
    assertNotNull(localzone.getBlood(0, 0));

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

    new DisplaceAction().onAction(player, displace);
    assertEquals(0, player.events().size());
    assertNull(localzone.getBlood(0, 0));
    assertNotNull(localzone.getBlood(0, 1));
  }
View Full Code Here


  /**
   * Test for displacing too far.
   */
  @Test
  public void testDisplaceTooFar() {
    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());

    // 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", 100);
    displace.put("y", 100);

    new DisplaceAction().onAction(player, displace);
    assertEquals(1, player.events().size());
    assertEquals("You cannot throw that far.", player.events().get(0).get("text"));
    assertEquals(1, localzone.getItemsOnGround().size());
  }
View Full Code Here

  /**
   * Test for displacing to an occupied place.
   */
  @Test
  public void testDisplaceOccupied() throws IOException {
    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);
    assertEquals(1, player.events().size());
    assertEquals("There is no space there.", player.events().get(0).get("text"));
    assertEquals(1, localzone.getItemsOnGround().size());
  }
View Full Code Here

  private static final String QUEST_SLOT = "jenny_mill_flour";

  @BeforeClass
  public static void setUpBeforeClass() throws Exception {
    QuestHelper.setUpBeforeClass();
    StendhalRPZone zone = new StendhalRPZone("admin_test");
    new MillerNPC().configureZone(zone, null);

    setupZone(ZONE_NAME);
  }
View Full Code Here

  /**
   * Test for displacing items below some other player.
   */
  @Test
  public void testDisplaceOtherPlayer() {
    final StendhalRPZone localzone = new StendhalRPZone("testzone", 20, 20);

    final Player player = createPlayer("bob");
    player.setPosition(1, 1);
    localzone.add(player);

    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");
View Full Code Here

  public static void setUpBeforeClass() throws Exception {
    QuestHelper.setUpBeforeClass();

    MockStendlRPWorld.get();
   
    final StendhalRPZone zone = new StendhalRPZone("admin_test");
    // this is convoluted .. we need this for Blackjack quest
    // which must be loaded because ramon is defined there!
    MockStendlRPWorld.get().addRPZone(new StendhalRPZone("-1_athor_ship_w2"));
    // a lot of NPCs to load for this quest!
   
    new WizardNPC().configureZone(zone, null);
    new MakeupArtistNPC().configureZone(zone, null)
    new AnimalKeeperNPC().configureZone(zone, null);
View Full Code Here

  /**
   * Test for displacing with wrong quantities.
   */
  @Test
  public void testDisplaceWrongQuantity() {
    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();
    action.onAction(player, displace);
    items = localzone.getItemsOnGround().toArray(new StackableItem[0]);
    assertEquals(1, items.length);
    assertEquals(10, items[0].getQuantity());
  }
View Full Code Here

  @BeforeClass
  public static void setUpBeforeClass() throws Exception {
    QuestHelper.setUpBeforeClass();
   
    StendhalRPZone zone = new StendhalRPZone("admin_test");
    new ShopAssistantNPC().configureZone(zone, null);
   
    setupZone(ZONE_NAME);
  }
View Full Code Here

  /**
   * Tests for configureZone.
   */
  @Test
  public void testConfigureZone() {
    StendhalRPZone zone = new StendhalRPZone("testzone"20, 20);
    ZoneConfigurator conf = new NoTeleportIn();
    conf.configureZone(zone, null);
    assertFalse(zone.isTeleportInAllowed(0, 0));
    assertFalse(zone.isTeleportInAllowed(19, 19));
    assertTrue(zone.isTeleportOutAllowed(0, 0));
    assertTrue(zone.isTeleportOutAllowed(19, 19));
  }
View Full Code Here

  /**
   * Tests for configuring only part of the zone
   */
  @Test
  public void testConfigureSubZone() {
    StendhalRPZone zone = new StendhalRPZone("testzone"20, 20);
    ZoneConfigurator conf = new NoTeleportIn();
    Map<String, String> attributes = new HashMap<String, String>();
    attributes.put("x", "1");
    attributes.put("y", "1");
    attributes.put("width", "5");
    attributes.put("height", "5");
    conf.configureZone(zone, attributes);
    assertTrue("Outside the blocked area", zone.isTeleportInAllowed(0, 0));
    assertFalse("Inside the blocked area", zone.isTeleportInAllowed(1, 1));
    assertFalse("Inside the blocked area", zone.isTeleportInAllowed(5, 5));
    assertTrue("Outside the blocked area", zone.isTeleportInAllowed(6, 6));
    assertTrue(zone.isTeleportOutAllowed(0, 0));
    assertTrue(zone.isTeleportOutAllowed(19, 19));
  }
View Full Code Here

TOP

Related Classes of games.stendhal.server.core.engine.StendhalRPZone

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.