Package games.stendhal.server.entity.item

Examples of games.stendhal.server.entity.item.Corpse


   * Tests for perform.
   */
  @Test
  public void testPerform() {
    DestroyAction destroyAction = new DestroyAction();
    Corpse corpse = new Corpse("rat", 0, 0);
    Player player = PlayerTestHelper.createPlayer("bob");
    StendhalRPZone zone = new StendhalRPZone("zone");
    zone.add(corpse);
    zone.add(player);
    RPAction rpAction = new RPAction();
    rpAction.put("target", "#" + corpse.getID().getObjectID());
    destroyAction.perform(player , rpAction);
    assertEquals("Removed  corpse with ID #1", player.events().get(0).get("text"));
  }
View Full Code Here


   */
  private void prepareCorpses() {
    final StendhalRPZone zone = SingletonRepository.getRPWorld().getZone("-6_kanmararn_city");

    // Now we create the corpse of the second NPC
    final Corpse tom = new Corpse("youngsoldiernpc", 5, 47);
    // he died first
    tom.setStage(4);
    tom.setName("Tom");
    tom.setKiller("a Dwarven patrol");
    // Add our new Ex-NPC to the game world
    zone.add(tom);

    // Add a refiller to automatically fill the corpse of unlucky Tom
    final CorpseRefiller tomRefiller = new CorpseRefiller(tom, "leather legs",
        "You see torn leather legs that are heavily covered with blood.");
    tomRefiller.start();

    // Now we create the corpse of the third NPC
    final Corpse charles = new Corpse("youngsoldiernpc", 94, 5);
    // he died second
    charles.setStage(3);
    charles.setName("Charles");
    charles.setKiller("a Dwarven patrol");
    // Add our new Ex-NPC to the game world
    zone.add(charles);
    // Add a refiller to automatically fill the corpse of unlucky Charles
    final CorpseRefiller charlesRefiller = new CorpseRefiller(charles, "note",
        "You read: \"IOU 250 money. (signed) McPegleg\"");
    charlesRefiller.start();

    // Now we create the corpse of the fourth NPC
    final Corpse peter = new Corpse("youngsoldiernpc", 11, 63);
    // he died recently
    peter.setStage(2);
    peter.setName("Peter");
    peter.setKiller("a Dwarven patrol");
    // Add our new Ex-NPC to the game world
    zone.add(peter);
    // Add a refiller to automatically fill the corpse of unlucky Peter
    final CorpseRefiller peterRefiller = new CorpseRefiller(
        peter,
View Full Code Here

      // Only allowed to use item of our own player.
      return false;
    }
   
    if (base instanceof Corpse) {
      Corpse corpse = (Corpse) base;
      if (!corpse.mayUse(player)) {
        player.sendPrivateText("Only " + corpse.getCorpseOwner() + " may access the corpse for now.");
       
        return false;
      }
    }
   
View Full Code Here

    // Establish how much xp points your are rewarded
    // give XP to everyone who helped killing this RPEntity
    rewardKillers(oldXP);

    // Add a corpse
    final Corpse corpse = makeCorpse(killerName);

    damageReceived.clear();
    playersToReward.clear();
    totalDamageReceived = 0;
View Full Code Here

   *
   * @param killer Name of the killer
   * @return The corpse of a dead RPEntity
   */
  protected Corpse makeCorpse(String killer) {
    return new Corpse(this, killer);
  }
View Full Code Here

  }
 
  /* returns true if entity is a corpse, it's not owner by that player, and the distance is far */
  private boolean isNotOwnCorpseAndTooFar(final Entity entity, final Player player, final int x, final int y) {
    if(entity instanceof Corpse) {
      Corpse corpse;
      try {
        corpse = (Corpse) entity;
        String owner = corpse.getCorpseOwner();
        if (owner!= null && !player.getTitle().equals(owner)) {
            int centerX = (int) (x + entity.getArea().getWidth() / 2);
            int centerY = (int) (y + entity.getArea().getHeight() / 2);     
            if (!(player.squaredDistance(centerX, centerY) < entity.getArea().getWidth() * entity.getArea().getHeight())) {
              player.sendPrivateText("You cannot throw that corpse so far while the protection of " + owner + " is heavy upon it.");
View Full Code Here

    assertFalse(ring.isBroken());
    assertFalse(ring2.isBroken());

    // dropItemsOn gets called before Player.onDead normally
    // not doing that will result in an NPE
    Corpse corpse = new Corpse(hasRingGood, "test");

    final PlayerDieer dierWithRingGood = new PlayerDieer(hasRingGood);
    dierWithRingGood.dropItemsOn(corpse);
    dierWithRingGood.onDead(new Entity() {
    });
View Full Code Here

          + " is not an item and therefore cannot be equipped");
      return invalidSource;
    }

    if (parent instanceof Corpse) {
      Corpse corpse = (Corpse) parent;
      if (!corpse.mayUse(player)) {
        logger.debug(player.getName() + " tried to access eCorpse owned by " + corpse.getCorpseOwner());
        player.sendPrivateText("Only " + corpse.getCorpseOwner() + " may access the corpse for now.");
        return invalidSource;
      }
    }

    source = new SourceObject(player, parent, slotName, (Item) entity);

    // handle logging of looting items
    if (parent instanceof Corpse) {
      Corpse corpse = (Corpse) parent;
      checkIfLootingIsRewardable(player, corpse, source, (Item) entity);
    }

    return source;
  }
View Full Code Here

   
    SourceObject source = new SourceObject(player, parent, slotName, (Item) entity);
   
    // handle logging of looting items
    if (parent instanceof Corpse) {
      Corpse corpse = (Corpse) parent;
      checkIfLootingIsRewardable(player, corpse, source, (Item) entity);
    }
   
    return source;
  }
View Full Code Here

TOP

Related Classes of games.stendhal.server.entity.item.Corpse

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.