Package games.stendhal.server.entity

Examples of games.stendhal.server.entity.Entity


   */
  private static SourceObject createSource(RPAction action, final Player player) {
    List<String> path = action.getList(EquipActionConsts.SOURCE_PATH);
    Iterator<String> it = path.iterator();
    // The ultimate parent object
    Entity parent = EquipUtil.getEntityFromId(player, MathHelper.parseInt(it.next()));
    if (parent == null) {
      return invalidSource;
    }
   
    // Walk the slot path
    Entity entity = parent;
    String slotName = null;
    while (it.hasNext()) {
      slotName = it.next();
      if (!entity.hasSlot(slotName)) {
        player.sendPrivateText("Source " + slotName + " does not exist");
        logger.error(player.getName() + " tried to use non existing slot " + slotName + " of " + entity
            + " as source. player zone: " + player.getZone() + " object zone: " + parent.getZone());
      }
     
      final RPSlot slot = ((EntitySlot) entity.getSlot(slotName)).getWriteableSlot();
      if (!isValidBaseSlot(player, slot)) {
        return invalidSource;
      }
      if (!it.hasNext()) {
        logger.error("Missing item id");
        return invalidSource;
      }
      final RPObject.ID itemId = new RPObject.ID(MathHelper.parseInt(it.next()), "");
      if (!slot.has(itemId)) {
        logger.debug("Base item(" + entity + ") doesn't contain item(" + itemId + ") on given slot(" + slotName
            + ")");
        return invalidSource;
      }
     
      entity = (Entity) slot.get(itemId);
      if (!(entity instanceof Item)) {
        player.sendPrivateText("Oh, that " + entity.getDescriptionName(true)
            + " is not an item and therefore cannot be equipped");
        return invalidSource;
      }
    }
    // wipe parent, if the item is not contained
View Full Code Here


    }
    return true;
  }

  private Item getNonContainedItem(final RPObject.ID baseItemId) {
    Entity entity = null;
    if (SingletonRepository.getRPWorld().has(baseItemId)) {
      entity = (Entity) SingletonRepository.getRPWorld().get(baseItemId);
      if ((entity instanceof Item)) {
        if (isItemBelowOtherPlayer((Item) entity)) {
          entity = null;
View Full Code Here

  /**
   * returns true when this entity and the other is within the given distance.
   */
  @Override
  public boolean checkDistance(final Entity other, final double distance) {
    final Entity checker;
    if (parent != null) {
      checker = parent;
    } else {
      checker = item;
    }
View Full Code Here

    }
    return res;
  }

  String getEntityName() {
    Entity entity1 = getEntity();
    final String itemName;
    if (entity1.has("name")) {
      itemName = entity1.get("name");
    } else if (entity1 instanceof Item) {
      itemName = "item";
    } else {
      itemName = "entity";
    }
View Full Code Here

  @Override
  public void perform(final Player player, final RPAction action) {

    if (action.has(TARGET) && action.has(TEXT)) {
      final Entity changed = getTarget(player, action);

      if (changed == null) {
        logger.debug("Entity not found");
        player.sendPrivateText("Entity not found");
        return;
      }

      /*
       * It will contain a string like: name;atk;def;hp;xp
       */
      final String stat = action.get(TEXT);

      final String[] parts = stat.split(";");
      if (!(changed instanceof Creature)) {
        logger.debug("Target " + changed.getTitle() + " was not a creature.");
        player.sendPrivateText("Target " + changed.getTitle() + " was not a creature.");
        return;
      }

      if (parts.length != 5) {
        logger.debug("Incorrect stats string for creature.");
View Full Code Here

      logger.warn("destination is invalid. action is: " + action);
      // destination is not valid
      return;
    }

    final Entity entity = source.getEntity();
    final String itemName = source.getEntityName();

    if (source.moveTo(dest, player)) {
      if (entity instanceof Item) {
        final Item item = (Item) entity;
View Full Code Here

  public void build(EquipmentActionData data, Player player, RPAction action) {
    List<String> path = action.getList(EquipActionConsts.TARGET_PATH);
    Iterator<String> it = path.iterator();

    // get parent
    Entity parent = EquipUtil.getEntityFromId(player, MathHelper.parseInt(it.next()));
    Entity root = parent;
    if (parent == null) {
      data.setErrorMessage("");
      return;
    }
View Full Code Here

      @Override
      protected String getName(final Entity entity) {
        return entity.getTitle();
      }
    };
    final Entity ent = new EntityExtension();
    final Entity ent2 = new EntityExtension();
    assertTrue(storelist.getList().isEmpty());
    storelist.add(ent);
    assertFalse(storelist.getList().isEmpty());
    assertThat(storelist.getList().size(), is(1));
    storelist.add(ent2);
View Full Code Here

    zone.add(seed);
    seed.setPosition(1, 0);

    assertTrue(seed.onUsed(player));

    final Entity entity = player.getZone().getEntityAt(1, 0);
    assertNotNull(entity);
    if (entity instanceof FlowerGrower) {
      final FlowerGrower flg = (FlowerGrower) entity;
      flg.setToFullGrowth();
      flg.onUsed(player);
View Full Code Here

    zone.add(seed);
    seed.setPosition(1, 0);

    assertTrue(seed.onUsed(player));

    final Entity entity = player.getZone().getEntityAt(1, 0);
    assertNotNull(entity);
    if (entity instanceof FlowerGrower) {
      final FlowerGrower flg = (FlowerGrower) entity;
      flg.setToFullGrowth();
      flg.onUsed(player);
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.