Examples of Creature


Examples of games.stendhal.server.entity.creature.Creature

  /**
   * function for emulating killing of creature by player.
   * @param name - creature's name
   */
  private void killSpider(String name) {
    final Creature creature = new Creature();
    creature.put("class", "");
    creature.put("subclass", "");
    creature.setName(name);
    creature.setHP(1);
    creature.setAtkXP(1);
    creature.setDefXP(1);
    final Creature spider = new Creature(creature);
    spider.registerObjectsForNotification(observer);
    player.teleport(basement, 5, 5, null, player);
    StendhalRPAction.placeat(basement, spider, 51, 50);
    spider.onDead(player, true);
 
View Full Code Here

Examples of games.stendhal.server.entity.creature.Creature

   * Tests that a new creature does not have a target.
   */
  @Test
  public void testhasValidTargetNonAttacker() {
    AttackStrategy strat = new AttackWeakest();
    Creature loner = new Creature();
   
    assertFalse("attacker has no target", strat.hasValidTarget(loner));
  }
View Full Code Here

Examples of games.stendhal.server.entity.creature.Creature

   */
  @Test
  public void testhasValidTargetInvisibleVictim() {
    AttackStrategy strat = new AttackWeakest();

    Creature creature = new Creature();
    Player player = PlayerTestHelper.createPlayer("ghost");
    StendhalRPZone arena = new StendhalRPZone("arena");
    arena.add(creature);
    arena.add(player);
    creature.setTarget(player);
    assertTrue("has a valid target", strat.hasValidTarget(creature));
    player.setInvisible(true);
    assertFalse("has a valid target", strat.hasValidTarget(creature));
  }
View Full Code Here

Examples of games.stendhal.server.entity.creature.Creature

   
    StendhalRPZone jacuzzi = new StendhalRPZone("jacuzzi");
    Player player = PlayerTestHelper.createPlayer("elvis");
    PlayerTestHelper.registerPlayer(player, jacuzzi);
   
    Creature creature = new Creature();
    StendhalRPZone arena = new StendhalRPZone("arena");
    arena.add(creature);

    creature.setTarget(player);
    assertFalse("has a valid target", strat.hasValidTarget(creature));
  }
View Full Code Here

Examples of games.stendhal.server.entity.creature.Creature

    /*
     *  Need to use a real creature, because the
     *  creature needs to be offensive to see the
     *  targets.
     */
    final Creature creature = SingletonRepository.getEntityManager().getCreature("rat");
   
    Player veteran = PlayerTestHelper.createPlayer("test dummy");
    Player newbie = PlayerTestHelper.createPlayer("test dummy2");
   
    StendhalRPZone arena = new StendhalRPZone("arena");
    arena.add(creature);
    assertFalse("is not attacking", strat.hasValidTarget(creature));
    arena.add(veteran);
    arena.add(newbie);
   
    creature.setPosition(3, 3);
    veteran.setPosition(3, 4);
   
    // Should pick the nearest: veteran
    strat.findNewTarget(creature);
    assertTrue("has a valid target", strat.hasValidTarget(creature));
    assertEquals("attack nearest", veteran, creature.getAttackTarget());
  }
View Full Code Here

Examples of games.stendhal.server.entity.creature.Creature

    /*
     *  Need to use a real creature, because the
     *  creature needs to be offensive to see the
     *  targets.
     */
    final Creature creature = SingletonRepository.getEntityManager().getCreature("rat");
   
    Player veteran = PlayerTestHelper.createPlayer("veteran");
    Player newbie = PlayerTestHelper.createPlayer("newbie");
   
    // Give the arena a proper size so that pathfinding can work
    StendhalRPZone arena = new StendhalRPZone("arena", 10, 10);
    arena.add(creature);
    assertFalse("is not attacking", strat.hasValidTarget(creature));
    arena.add(veteran);
    arena.add(newbie);
   
    creature.setPosition(3, 3);
    veteran.setPosition(3, 5);
    newbie.setPosition(1, 5);
    assertFalse("sanity check; target not next to attacker", veteran.nextTo(creature));
    assertFalse("sanity check; target not next to attacker", newbie.nextTo(creature));
    assertTrue("sanity check; veteran is closer than newbie",
        creature.squaredDistance(veteran) < creature.squaredDistance(newbie));
   
    // Should pick the nearest: veteran
    strat.findNewTarget(creature);
    assertTrue("has a valid target", strat.hasValidTarget(creature));
    assertEquals("attack nearest", veteran, creature.getAttackTarget());
  }
View Full Code Here

Examples of games.stendhal.server.entity.creature.Creature

    /*
     *  Need to use a real creature, because the
     *  creature needs to be offensive to see the
     *  targets.
     */
    final Creature creature = SingletonRepository.getEntityManager().getCreature("rat");
   
    Player veteran = PlayerTestHelper.createPlayer("veteran");
    Player newbie = PlayerTestHelper.createPlayer("newbie");
   
    StendhalRPZone arena = new StendhalRPZone("arena");
    arena.add(creature);
    assertFalse("is not attacking", strat.hasValidTarget(creature));
    arena.add(veteran);
    arena.add(newbie);
    veteran.addXP(10000);
    newbie.addXP(100);
   
    assertTrue("sanity check for player levels", veteran.getLevel() > newbie.getLevel());
   
    creature.setPosition(3, 3);
    veteran.setPosition(3, 4);
   
    // Should pick the nearest: veteran
    strat.findNewTarget(creature);
    assertTrue("has a valid target", strat.hasValidTarget(creature));
    assertEquals("attack nearest", veteran, creature.getAttackTarget());
   
    // move newbie near. this should result in switching targets
    newbie.setPosition(2, 3);
    assertTrue("has a valid target", strat.hasValidTarget(creature));
    assertEquals("attack weakest", newbie, creature.getAttackTarget());
   
    // move veteran away for a moment
    veteran.setPosition(3, 5);
    // should make no difference
    assertTrue("has a valid target", strat.hasValidTarget(creature));
    assertEquals("attack weakest", newbie, creature.getAttackTarget());
    veteran.setPosition(3, 4);
    // and neither should putting him back (unlike newbie's arrival)
    assertTrue("has a valid target", strat.hasValidTarget(creature));
    assertEquals("attack weakest", newbie, creature.getAttackTarget());
  }
View Full Code Here

Examples of games.stendhal.server.entity.creature.Creature

    /*
     *  Need to use a real creature, because the
     *  creature needs to be offensive to see the
     *  targets.
     */
    final Creature creature = SingletonRepository.getEntityManager().getCreature("rat");
    final Creature scrollCreature = new AttackableCreature(SingletonRepository.getEntityManager().getCreature("rat"));
   
    Player veteran = PlayerTestHelper.createPlayer("veteran");
   
    StendhalRPZone arena = new StendhalRPZone("arena");
    arena.add(creature);
    assertFalse("is not attacking", strat.hasValidTarget(creature));
    arena.add(veteran);
    arena.add(scrollCreature);
    veteran.addXP(10000);
   
    assertTrue("sanity check for enemy levels", veteran.getLevel() > scrollCreature.getLevel());
   
    creature.setPosition(3, 3);
    scrollCreature.setPosition(2, 4);
   
    // Should pick the nearest: scrollCreature
    strat.findNewTarget(creature);
    assertTrue("has a valid target", strat.hasValidTarget(creature));
    assertEquals("attack nearest", scrollCreature, creature.getAttackTarget());
View Full Code Here

Examples of games.stendhal.server.entity.creature.Creature

    called = false;
    MockStendlRPWorld.get();
    MockStendhalRPRuleProcessor.get();
    final StendhalRPZone zone = new StendhalRPZone("blabl");
    CreatureTestHelper.generateRPClasses();
    final Creature creature = new Creature() {
      @Override
      public int heal(final int amount) {
        called = true;
        return amount;
      }
    };
    zone.add(creature);
    creature.setBaseHP(100);
    creature.setHP(50);
    creature.setHealer(null);
    creature.logic();
    assertThat(creature.getHP(), is(50));
    creature.setHealer("10,1");
    creature.logic();
    assertTrue(called);

  }
View Full Code Here

Examples of games.stendhal.server.entity.creature.Creature

    gate.open();
    StendhalRPZone zone = new StendhalRPZone("room", 5, 5);
    gate.setPosition(3, 3);
    zone.add(gate);
    assertTrue("Sanity check", gate.isOpen());
    final Creature creature = SingletonRepository.getEntityManager().getCreature("rat");
    creature.setPosition(3, 3);
    zone.add(creature);
    System.err.println("RESISTANCE: " + creature.getResistance());
    gate.close();
    assertTrue("Rat in the way", gate.isOpen());
    // A "ghostmode" rat
    creature.setResistance(0);
    gate.close();
    assertFalse("Ghost in the way", gate.isOpen());
  }
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.