Package games.stendhal.server.entity

Examples of games.stendhal.server.entity.Entity


  /**
   * Tests for searchPathEntityIntInt.
   */
  @Test
  public void testSearchPathEntityIntInt() {
    final Entity entity = new Entity() {
      // just to create an instance
    };
    final StendhalRPZone zone = new StendhalRPZone("test", 10, 10);
    zone.add(entity);
    assertArrayEquals(expected.toArray(), Path.searchPath(entity, 6, 6).toArray());
View Full Code Here


  @Test
  public void testEntityFromZoneByID() {
    int idRPO1 = 1;
    int idRPO2 = 2;
    StendhalRPZone zone = new StendhalRPZone(TEST_ENTITY_HELPER);
    RPObject rpo1 = new Entity() {};
    rpo1.setID(new RPObject.ID(idRPO1, zone.getID()));
    zone.add(rpo1);
    RPObject rpo2 = new Entity() {};
    rpo2.setID(new RPObject.ID(idRPO2, zone.getID()));
    zone.add(rpo2);
    Entity entityFromZoneByID = EntityHelper.entityFromZoneByID(idRPO1, zone);
    assertThat(entityFromZoneByID, is(rpo1));
    assertThat(entityFromZoneByID, not((is(rpo2))));
  }
View Full Code Here

    assertThat(entityFromZoneByID, not((is(rpo2))));
  }

  @Test
  public void testEntityFromTargetName() {
    Entity player = new Entity() {};
    StendhalRPZone zone = new StendhalRPZone(TEST_ENTITY_HELPER);
    zone.add(player);
    Entity entityFromTargetName = EntityHelper.entityFromTargetName("#3", player);
    assertThat(entityFromTargetName, not(notNullValue()));
    int idRPO1 = 1;
    Entity rpo1 = new Entity() {};
    RPObject rpo2 = new Entity() {};
    rpo2.put("test","test");
    rpo1.setID(new RPObject.ID(idRPO1, zone.getID()));
    rpo1.addSlot("test");
    rpo1.getSlot("test").add(rpo2);
    zone.add(rpo1);
    zone.add(rpo2);
    Entity entityFromTargetName2 = EntityHelper.entityFromTargetName("#3", player);
    assertThat(entityFromTargetName2, is(rpo2));
  }
View Full Code Here

    assertThat(entityFromTargetName2, is(rpo2));
  }

  @Test
  public void testEntityFromTargetNameAnyZone() {
    Entity player = new Entity() {};
    Entity entityFromTargetName = EntityHelper.entityFromTargetNameAnyZone("1", player);
    assertThat(entityFromTargetName, not(notNullValue()));
    int idRPO1 = 1;
    int idRPO2 = 2;
    StendhalRPZone zone = new StendhalRPZone(TEST_ENTITY_HELPER);
    Entity rpo1 = new Entity() {};
    rpo1.setID(new RPObject.ID(idRPO1, zone.getID()));
    zone.add(rpo1);
    RPObject rpo2 = new Entity() {};
    rpo2.setID(new RPObject.ID(idRPO2, zone.getID()));
    zone.add(rpo2);
    rpo1.addSlot("test");
    rpo1.getSlot("test").add(rpo2);
    Entity entityFromTargetName2 = EntityHelper.entityFromTargetNameAnyZone("#2", rpo1);
    assertThat(entityFromTargetName2, is(rpo2));
  }
View Full Code Here

    StendhalRPZone zone = new StendhalRPZone(TEST_ENTITY_HELPER);
    Player player = PlayerTestHelper.createPlayer("helpertester");
    player.setID(new RPObject.ID(2, zone.getID()));
    RPAction action = new RPAction();
    assertNull(EntityHelper.entityFromSlot(player, action));
    Entity rpo1 = new Entity() {};
    rpo1.setID(new RPObject.ID(1, TEST_ENTITY_HELPER));
    zone.add(rpo1);
    assertNull(EntityHelper.entityFromSlot(player, action));
    zone.add(player);
    player.getSlot("bag").add(rpo1);
    action.put(BASESLOT, "bag");
View Full Code Here

   */
  @Test
  public void testContainsNull() throws Exception {
   
    final Area area = new Area(null, null);
    final Entity entity = null;
    assertFalse(area.contains(entity));
  }
View Full Code Here

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

  }

  private void useItemOnGround(final Player player, final RPAction action) {
    // use is cast over something on the floor
    // evaluate the target parameter
    final Entity entity = EntityHelper.entityFromTargetName(
        action.get(TARGET), player);

    if (entity != null) {
      tryUse(player, entity);
    }
View Full Code Here

    }
  }

  private void useItemInSlot(final Player player, final RPAction action) {
    final EntitySlot slot = EntityHelper.getSlot(player, action);
    final Entity object = EntityHelper.entityFromSlot(player, action);
    if ((object != null) && canAccessSlot(player, slot, object.getBaseContainer())) {
      tryUse(player, object);
    }
  }
View Full Code Here

      logger.warn("missing action attribute in RPAction " + action);
      return;
    }

    if (actionStr.equals("offer_trade")) {
      Entity entity = EntityHelper.entityFromTargetName(action.get("target"), player);
      if ((entity == null) || (!(entity instanceof Player))) {
        return;
      }
      player.offerTrade((Player) entity);
    } else if (actionStr.equals("lock")) {
View Full Code Here

TOP

Related Classes of games.stendhal.server.entity.Entity

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.