Examples of Creature


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

   */
  @Test
  public void testAttack() throws Exception {
    MockStendhalRPRuleProcessor.get();
    final HandToHand hth = new HandToHand();
    final Creature creature = createMock(Creature.class);
    expect(creature.isAttackTurn(0)).andReturn(true);
    expect(creature.attack()).andReturn(true);
    creature.tryToPoison();
    replay(creature);
    hth.attack(creature);
    verify(creature);
  }
View Full Code Here

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

   */
  @Test
  public void testNotAttackTurnAttack() throws Exception {
    MockStendhalRPRuleProcessor.get();
    final HandToHand hth = new HandToHand();
    final Creature creature = createMock(Creature.class);
    expect(creature.isAttackTurn(0)).andReturn(false);
    replay(creature);
    hth.attack(creature);
    verify(creature);
  }
View Full Code Here

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

   * Tests for canAttackNow.
   */
  @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.creature.Creature

   */
  @Test
  public void testCanAttackNowBigCreature() {
    final StendhalRPZone zone = new StendhalRPZone("hthtest");
    final HandToHand hth = new HandToHand();
    final Creature creature = SingletonRepository.getEntityManager().getCreature("balrog");
    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

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

   */
  @Test
  public void testhasValidTargetNonAttacker() {
    HandToHand hth = new HandToHand();

    Creature nonAttacker = createMock(Creature.class);
    expect(nonAttacker.isAttacking()).andReturn(false);
    replay(nonAttacker);

    assertFalse("attacker has no target", hth.hasValidTarget(nonAttacker));
    verify(nonAttacker);
  }
View Full Code Here

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

   * Tests for hasValidTargetInvisibleVictim.
   */
  @Test
  public void testhasValidTargetInvisibleVictim() {

    Creature victim = createMock(Creature.class);
    expect(victim.isInvisibleToCreatures()).andReturn(true);

    Creature attacker = createMock(Creature.class);
    expect(attacker.isAttacking()).andReturn(true);
    expect(attacker.getAttackTarget()).andReturn(victim);

    replay(victim);
    replay(attacker);

    HandToHand hth = new HandToHand();
View Full Code Here

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

    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);

    expect(attacker.getZone()).andReturn(zoneB);

    replay(victim);
    replay(attacker);

    HandToHand hth = new HandToHand();
View Full Code Here

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

    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);

    expect(attacker.getZone()).andReturn(zone).times(2);

    replay(victim);
    replay(attacker);
    replay(zone);
View Full Code Here

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

  @Test
  public void testHasValidTarget() {
    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));
View Full Code Here

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

   */
  @Test
  public void testFindNewtarget() throws Exception {
    MockStendhalRPRuleProcessor.get();
    final HandToHand hth = new HandToHand();
    final Creature lonesomeCreature = new Creature();
    assertFalse(lonesomeCreature.isAttacking());
    hth.findNewTarget(lonesomeCreature);
    assertFalse(lonesomeCreature.isAttacking());

    final Creature creature = createMock(Creature.class);
    expect(creature.getPerceptionRange()).andReturn(5);
    expect(creature.getNearestEnemy(7)).andReturn(creature);
    creature.setTarget(creature);
    replay(creature);

    hth.findNewTarget(creature);

    verify(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.