Examples of RPEntity


Examples of games.stendhal.server.entity.RPEntity

  @Test
  public void testUseGateNotNExtTo() throws Exception {
    final Gate gate = new Gate();
    gate.setPosition(5, 5);
    assertFalse(gate.isOpen());
    final RPEntity user = new RPEntity() {

      @Override
      protected void dropItemsOn(final Corpse corpse) {

      }
View Full Code Here

Examples of games.stendhal.server.entity.RPEntity

   */
  @Test
  public void testIsObstacle() throws Exception {
    final Gate gate = new Gate();

    final RPEntity user = new RPEntity() {

      @Override
      protected void dropItemsOn(final Corpse corpse) {

      }
View Full Code Here

Examples of games.stendhal.server.entity.RPEntity

  public void testhasValidTargetDifferentZones() {

    StendhalRPZone zoneA = new StendhalRPZone("A");
    StendhalRPZone zoneB = new StendhalRPZone("B");

    RPEntity victim = createMock(RPEntity.class);
    expect(victim.isInvisibleToCreatures()).andReturn(false);
    expect(victim.getZone()).andReturn(zoneA);

    Creature attacker = createMock(Creature.class);
    expect(attacker.isAttacking()).andReturn(true);
    expect(attacker.getAttackTarget()).andReturn(victim);
View Full Code Here

Examples of games.stendhal.server.entity.RPEntity

  public void testhasValidTargetvisibleVictim() {
    ID id = new RPObject.ID(1, "zone");
    StendhalRPZone zone = createMock(StendhalRPZone.class);
    expect(zone.has(id)).andReturn(false);

    RPEntity victim = createMock(RPEntity.class);
    expect(victim.isInvisibleToCreatures()).andReturn(false);
    expect(victim.getZone()).andReturn(zone);
    expect(victim.getID()).andReturn(id);

    Creature attacker = createMock(Creature.class);
    expect(attacker.isAttacking()).andReturn(true);
    expect(attacker.getAttackTarget()).andReturn(victim);
View Full Code Here

Examples of games.stendhal.server.entity.RPEntity

    final StendhalRPZone zone = new StendhalRPZone("hthtest");

    final HandToHand hth = new HandToHand();
    final Creature creature = new Creature();
    assertFalse("is not attacking", hth.hasValidTarget(creature));
    final RPEntity victim = new RPEntity() {

      @Override
      public boolean isInvisibleToCreatures() {
        return mockinvisible;
      }

      @Override
      protected void dropItemsOn(final Corpse corpse) {

      }

      @Override
      public void logic() {

      }
    };
    victim.put("id", 1);
    creature.setTarget(victim);
    mockinvisible = true;
    assertTrue(victim.isInvisibleToCreatures());
    assertFalse("victim is invisible", hth.hasValidTarget(creature));
    mockinvisible = false;
    assertFalse(victim.isInvisibleToCreatures());
    zone.add(victim);
    assertFalse("not in same zone", hth.hasValidTarget(creature));
    zone.add(creature);
    assertFalse("in same zone, on same spot and dead", hth.hasValidTarget(creature));

    creature.setTarget(victim);
    victim.setHP(1);
    assertTrue("in same zone, on same spot", hth.hasValidTarget(creature));

    victim.setPosition(12, 0);
    assertTrue("in same zone, not too far away", hth.hasValidTarget(creature));
    victim.setPosition(13, 0);
    assertFalse("in same zone, too far away", hth.hasValidTarget(creature));
  }
View Full Code Here

Examples of games.stendhal.server.entity.RPEntity

        distances.put(enemy, squaredDistance);
      }
    }

    // now choose the nearest enemy for which there is a path
    RPEntity chosen = null;
    while ((chosen == null) && (distances.size() > 0)) {
      double shortestDistance = Double.MAX_VALUE;
      for (final Map.Entry<RPEntity, Double> enemy : distances.entrySet()) {
        final double distance = enemy.getValue();
        if (distance < shortestDistance) {
View Full Code Here

Examples of games.stendhal.server.entity.RPEntity

   * @throws NullPointerException if attacktarget is null
   */

  public void tryToPoison() {

    final RPEntity entity = getAttackTarget();
    if (poisoner.attack(entity)) {
      new GameEvent(getName(), "poison", entity.getName()).raise();
      entity.sendPrivateText("You have been poisoned by " + Grammar.a_noun(getName()));
    }
  }
View Full Code Here

Examples of games.stendhal.server.entity.RPEntity

  @Override
  public boolean attack() {
    boolean res = super.attack();

    // count hits for corpse protection
    final RPEntity defender = this.getAttackTarget();
    if (defender instanceof Player) {
      if (hitPlayers == null) {
        hitPlayers = new CounterMap<String>();
      }
      hitPlayers.add(defender.getName());
    }

    return res;
  }
View Full Code Here

Examples of games.stendhal.server.entity.RPEntity

        return ((Player) entity).getName();
      }
    }

    // which player did we attack last?
    RPEntity target = getAttackTarget();
    if ((target != null) && (target instanceof Player)) {
      if (getZone() == target.getZone()) {
        return target.getName();
      }
    }

    return null;
  }
View Full Code Here

Examples of games.stendhal.server.entity.RPEntity

    buildMagicSchoolCellarArea(zone, attributes);
  }
 
  protected void updatePlayerQuest(final CircumstancesOfDeath circ) {
    final String victim = circ.getVictim().getName();
    final RPEntity killer = circ.getKiller();
    Logger.getLogger(SpidersCreatures.class).debug(
        "in "+circ.getZone().getName()+
        ": "+victim+
        " killed by "+killer.getName());
    // check if was killed by other animal/pet
    if(!circ.getKiller().getClass().getName().equals(Player.class.getName()) ) {
      return;
    }
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.