Examples of RPEntity


Examples of games.stendhal.server.entity.RPEntity

  @Override
  public void perform(final Player player, final RPAction action) {
    if (action.has(TARGET)) {
      final String name = action.get(TARGET);
      RPEntity teleported = SingletonRepository.getRuleProcessor().getPlayer(name);

      if (teleported == null) {
        teleported = SingletonRepository.getNPCList().get(name);
        if (teleported == null) {

          final String text = "Player \"" + name + "\" not found";
          player.sendPrivateText(text);
          logger.debug(text);
          return;
        }
      }

      final StendhalRPZone zone = teleported.getZone();
      final int x = teleported.getX();
      final int y = teleported.getY();

      player.teleport(zone, x, y, null, player);
      new GameEvent(player.getName(), TELEPORTTO, action.get(TARGET), zone.getName(), Integer.toString(x), Integer.toString(y)).raise();
    }
  }
View Full Code Here

Examples of games.stendhal.server.entity.RPEntity

    }

    final StringBuilder st = new StringBuilder();

    if (target instanceof RPEntity) {
      final RPEntity inspected = (RPEntity) target;

      // display type and name/title of the entity if they are available

      final String type = inspected.get("type");
      st.append("Inspected ");
      if (type != null) {
        st.append(type);
      } else {
        st.append("entity");
      }
      st.append(" is ");

      String name = inspected.getName();
      if (name == null) {
        name = inspected.getTitle();
      }
      if (name != null) {
        st.append("called \"");
        st.append(name);
        st.append("\"");
      } else {
        st.append("unnamed");
      }

      st.append(" and has the following attributes:");

      // st.append(target.toString());
      // st.append("\n===========================\n");
      st.append("\nID: " + action.get("target") + " in " + inspected.getZone().getName() + " at (" + + inspected.getX() + ", " + + inspected.getY()+")");
      st.append("\nATK:    " + inspected.getAtk() + "("
          + inspected.getAtkXP() + ")");
      st.append("\nDEF:    " + inspected.getDef() + "("
          + inspected.getDefXP() + ")");
      st.append("\nHP:     " + inspected.getHP() + " / "
          + inspected.getBaseHP());
      st.append("\nXP:     " + inspected.getXP());
      st.append("\nLevel:  " + inspected.getLevel());
      st.append("\nKarma:  " + inspected.getKarma());
      st.append("\nequips");
     
      for (final RPSlot slot : inspected.slots()) {
        // showing these is either irrelevant, private, or spams too much
        if (slot.getName().equals("!buddy")
          || slot.getName().equals("!ignore")
          || slot.getName().equals("!visited")
          || slot.getName().equals("!tutorial")
View Full Code Here

Examples of games.stendhal.server.entity.RPEntity

     */
    if (!(entity instanceof RPEntity)) {
      return;
    }

    final RPEntity rpentity = (RPEntity) entity;

    /*
     * Only effect players?
     */
    if (playersOnly && !(rpentity instanceof Player)) {
View Full Code Here

Examples of games.stendhal.server.entity.RPEntity

     */
    if (!(entity instanceof RPEntity)) {
      return;
    }

    final RPEntity rpentity = (RPEntity) entity;

    /*
     * Only effect players?
     */
    if (playersOnly && !(rpentity instanceof Player)) {
      return;
    }

    if (targets.contains(rpentity.getID())) {
      handleMovement(rpentity);
      removeTarget(rpentity);
      handleRemoved(rpentity);
    }
  }
View Full Code Here

Examples of games.stendhal.server.entity.RPEntity

     */
    if (!(entity instanceof RPEntity)) {
      return;
    }

    final RPEntity rpentity = (RPEntity) entity;

    if (targets.contains(rpentity.getID())) {
      handleMovement(rpentity);
    }
  }
View Full Code Here

Examples of games.stendhal.server.entity.RPEntity

    while (iter.hasNext()) {
      final RPEntity.ID id = iter.next();

      if (zone.has(id)) {
        final RPEntity entity = (RPEntity) zone.get(id);

        if (area.intersects(entity.getArea())) {
          if (!handleInterval(entity)) {
            handleRemoved(entity);
            iter.remove();
          }
        } else {
View Full Code Here

Examples of games.stendhal.server.entity.RPEntity

  private void destroyRing(SlotOwner container, final WeddingRing ring, final RPSlot slot) {
    // The players need to be told first, while the ring still
    // exist in the world
    informNearbyPlayers(ring);

    RPEntity player = null;
    if (container instanceof RPEntity) {
      player = (RPEntity) container;
    }

    new ItemLogger().destroy(player, slot, ring, "another ring");
View Full Code Here

Examples of games.stendhal.server.entity.RPEntity

   */
  @Test
  public final void testOnUsed() {
    final Chest ch = new Chest();
    assertFalse(ch.isOpen());
    ch.onUsed(new RPEntity() {

      @Override
      protected void dropItemsOn(final Corpse corpse) {
      }

      @Override
      public void logic() {

      }
    });

    assertTrue(ch.isOpen());
    ch.onUsed(new RPEntity() {

      @Override
      protected void dropItemsOn(final Corpse corpse) {
      }

View Full Code Here

Examples of games.stendhal.server.entity.RPEntity

  @Test
  public void testCanAttackNow() {
    final HandToHand hth = new HandToHand();
    final Creature creature = new Creature();
    assertFalse("no target yet", hth.canAttackNow(creature));
    final RPEntity victim = new RPEntity() {

      @Override
      protected void dropItemsOn(final Corpse corpse) {

      }

      @Override
      public void logic() {

      }
    };
    victim.put("id", 1);
    creature.setTarget(victim);
    assertTrue("new ones stand on same positon", hth.canAttackNow(creature));
    victim.setPosition(10, 10);
    assertFalse("too far away", hth.canAttackNow(creature));

  }
View Full Code Here

Examples of games.stendhal.server.entity.RPEntity

    assertNotNull(creature);
    assertThat(creature.getWidth(), is(6.0));
    assertThat(creature.getHeight(), is(6.0));
    creature.setPosition(10, 10);
    assertFalse("no target yet", hth.canAttackNow(creature));
    final RPEntity victim = PlayerTestHelper.createPlayer("bob");
    victim.setHP(1);
    zone.add(creature);
    zone.add(victim);
    creature.setTarget(victim);

    for (int i = 9; i < 12; i++) {
      for (int j = 9; j < 13; j++) {
        victim.setPosition(i, j);
        assertTrue(creature.nextTo(victim));
        assertTrue(victim.nextTo(creature));
        assertTrue("can attack now (" + i + "," + j + ")", hth.canAttackNow(creature));
      }
    }

    victim.setPosition(8, 13);
    assertFalse(creature.nextTo(victim));
    assertFalse(victim.nextTo(creature));
    assertFalse("can attack now ", hth.canAttackNow(creature));

  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.