Package games.stendhal.server.entity.creature

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


    veteran.setPosition(3, 4);
    assertTrue("has a valid target", strat.hasValidTarget(creature));
    assertEquals("attack player", veteran, creature.getAttackTarget());
   
    // Add a sheep. Pets are nice targets for killing
    final Sheep sheep = new Sheep(veteran);
    sheep.setPosition(4, 4);
    assertTrue("sanity check for enemy levels", veteran.getLevel() > sheep.getLevel());
    assertTrue("has a valid target", strat.hasValidTarget(creature));
    assertEquals("attack sheep", sheep, creature.getAttackTarget());
  }
View Full Code Here


    assertEquals(0.2, (new SpeakerNPC("bob")).getBaseSpeed(), 0.001);
    assertEquals(0.0, (new Creature()).getBaseSpeed(), 0.001);
    assertEquals(1.0, (PlayerTestHelper.createPlayer("player")).getBaseSpeed(),
        0.001);
    assertEquals(0.9, (new Cat()).getBaseSpeed(), 0.001);
    assertEquals(0.25, (new Sheep()).getBaseSpeed(), 0.001);

  }
View Full Code Here

 
  @Test
  public void startAttackingPet() {
    final Player jekyll = PlayerTestHelper.createPlayer("jekyll");
    final Player hyde = PlayerTestHelper.createPlayer("hyde");
    final Sheep sheep = new Sheep();
   
    zone.add(hyde);
    zone.add(sheep);
    // attacking wild sheep should be ok
    StendhalRPAction.startAttack(hyde, sheep);
    assertSame("Attacking a sheep in unprotected area", hyde.getAttackTarget(), sheep);
    hyde.stopAttack();
    // also if you are the owner
    sheep.setOwner(hyde);
    StendhalRPAction.startAttack(hyde, sheep);
    assertSame("Attacking a sheep in unprotected area", hyde.getAttackTarget(), sheep);
    hyde.stopAttack();
    // but attacking someone elses pet is a no-no
    sheep.setOwner(jekyll);
    StendhalRPAction.startAttack(hyde, sheep);
    assertNull("Attacking someone else's sheep", hyde.getAttackTarget());
    assertEquals("message at attacking someone else's sheep",
        "You pity jekyll's sheep too much to kill it.",
        hyde.events().get(0).get("text"));
    hyde.stopAttack();
    hyde.clearEvents();
    sheep.setOwner(null);
   
    // Protected. should fail
    protectMap();
    StendhalRPAction.startAttack(hyde, sheep);
    assertNull("Attacking a sheep in protected area ", hyde.getAttackTarget());
    assertEquals("message at attacking a sheep in protected area",
        "The powerful protective aura in this place prevents you from attacking that sheep.",
        getPrivateReply(hyde));
    hyde.stopAttack();
    hyde.clearEvents();
   
    // the same with an owned sheep
    sheep.setOwner(hyde);
    StendhalRPAction.startAttack(hyde, sheep);
    assertNull("Attacking a sheep in protected area ", hyde.getAttackTarget());
    assertEquals("message at attacking a sheep in protected area",
        "The powerful protective aura in this place prevents you from attacking hyde's sheep.",
        getPrivateReply(hyde));
    hyde.clearEvents();
   
    // ...regarless of the owner
    sheep.setOwner(jekyll);
    StendhalRPAction.startAttack(hyde, sheep);
    assertNull("Attacking a sheep in protected area ", hyde.getAttackTarget());
    assertEquals("message at attacking a sheep in protected area",
        "The powerful protective aura in this place prevents you from attacking jekyll's sheep.",
        getPrivateReply(hyde));
View Full Code Here

  @Override
  public boolean isZoneChangeAllowed() {
    /*
     * If we are too far from dependents, then disallow zone change
     */
    final Sheep sheep = getSheep();

    if (sheep != null) {
      if (squaredDistance(sheep) > (7 * 7)) {
        return false;
      }
View Full Code Here

                seller.say("You don't seem to have enough money.");
                return false;
              }
              seller.say("Here you go, a nice fluffy little sheep! Take good care of it, now...");

              final Sheep sheep = new Sheep(player);
              StendhalRPAction.placeat(seller.getZone(), sheep, seller.getX(), seller.getY() + 1);

              player.notifyWorldAboutChanges();

              return true;
View Full Code Here

                seller.say("You don't seem to have enough money.");
                return false;
              }
              seller.say("Here you go, a nice fluffy little sheep! Take good care of it, now...");

              final Sheep sheep = new Sheep(player);
              StendhalRPAction.placeat(seller.getZone(), sheep, seller.getX(), seller.getY() + 1);

              player.notifyWorldAboutChanges();

              return true;
View Full Code Here

    }

    @Override
    public int getCharge(ItemParserResult res, final Player player) {
      if (player.hasSheep()) {
        final Sheep sheep = player.getSheep();
        return getValue(res, sheep);
      } else {
        // npc's answer was moved to BuyerAdder.
        return 0;
      }
View Full Code Here

    @Override
    public boolean transactAgreedDeal(ItemParserResult res, final EventRaiser seller, final Player player) {
      // res.getAmount() is currently ignored.

      final Sheep sheep = player.getSheep();

      if (sheep != null) {
        if (seller.getEntity().squaredDistance(sheep) > 5 * 5) {
          seller.say("I can't see that sheep from here! Bring it over so I can assess it properly.");
        } else if (getValue(res, sheep) < SheepSellerNPC.BUYING_PRICE) {
          // prevent newbies from selling their sheep too early
          seller.say("Nah, that sheep looks too skinny. Feed it with red berries, and come back when it has become fatter.");
        } else {
          seller.say("Thanks! Here is your money.");
          payPlayer(res, player);
          player.removeSheep(sheep);

          player.notifyWorldAboutChanges();
          if(seller.getEntity() instanceof SheepBuyerSpeakerNPC) {
            ((SheepBuyerSpeakerNPC)seller.getEntity()).moveSheep(sheep);
          } else {
            // only to prevent that an error occurs and the sheep does not disappear
            sheep.getZone().remove(sheep);
          }

          return true;
        }
      } else {
View Full Code Here

    }

    @Override
    public int getCharge(ItemParserResult res, final Player player) {
      if (player.hasSheep()) {
        final Sheep sheep = player.getSheep();
        return Math.round(getUnitPrice(res.getChosenItemName()) * ((float) sheep.getWeight() / (float) Sheep.MAX_WEIGHT));
      } else {
        return 0;
      }
    }
View Full Code Here

    }

    @Override
    public boolean transactAgreedDeal(ItemParserResult res, final EventRaiser seller, final Player player) {
      // res.getAmount() is currently ignored.
      final Sheep sheep = player.getSheep();

      if (sheep != null) {
        if (seller.getEntity().squaredDistance(sheep) > 5 * 5) {
          seller.say("*drool* Sheep flesh! Bring da sheep here!");
        } else {
          seller.say("Mmm... Is look yummy! Here, you take dis gold!");
          payPlayer(res, player);

          player.removeSheep(sheep);
          player.notifyWorldAboutChanges();

          sheep.getZone().remove(sheep);

          return true;
        }
      } else {
        seller.say("Whut? Is not unnerstand... Maybe I hit you until you make sense!");
View Full Code Here

TOP

Related Classes of games.stendhal.server.entity.creature.Sheep

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.