Package games.stendhal.server.entity.item

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


public class ConsumableTestHelperTest {

  @Test
  public void testCreate() throws Exception {

    ConsumableItem eater = ConsumableTestHelper.createEater("consume");
    assertThat(eater, is(ConsumableItem.class));

    ConsumableItem createImmunizer = ConsumableTestHelper.createImmunizer("consume");
    assertThat(createImmunizer, is(ConsumableItem.class));
  }
View Full Code Here


    ItemTestHelper.generateRPClasses();
    Map<String, String> attributes = new HashMap<String, String>();
    attributes.put("amount", "1");
    attributes.put("regen", "1");
    attributes.put("frequency", "1");
    return new ConsumableItem(name, "class", "subclass", attributes);
  }
View Full Code Here

    ItemTestHelper.generateRPClasses();
    Map<String, String> attributes = new HashMap<String, String>();
    attributes.put("amount", "1");
    attributes.put("regen", "0");
    attributes.put("frequency", "1");
    return new ConsumableItem(name, "class", "subclass", attributes);
  }
View Full Code Here

    assertEquals(startTurn + 1, TurnNotifier.get().getCurrentTurnForDebugging());
   
   
    Immunizer immu = new Immunizer();
   
    ConsumableItem item = ConsumableTestHelper.createImmunizer("antidote");
    item.put("id", 1);
    Player player = PlayerTestHelper.createPlayer("herrkules");
    assertFalse(player.isImmune());
    assertTrue(immu.feed(item, player));
    assertTrue(player.isImmune());
    ConsumableItem item2 = ConsumableTestHelper.createImmunizer("antidote");
    item2.put("id", 2);

    assertEquals(2, TurnNotifier.get().getRemainingTurns(new AntidoteEater(player)));
   
    TurnNotifier.get().logic(TurnNotifier.get().getCurrentTurnForDebugging() + 1);
   
View Full Code Here

    attributes.put("frequency", "1");
    attributes.put("id", "1");
    final StendhalRPWorld world = SingletonRepository.getRPWorld();
    final StendhalRPZone zone = new StendhalRPZone("test");
    world.addRPZone(zone);
    final ConsumableItem c200_1 = new ConsumableItem("cheese", "", "", attributes);
    zone.add(c200_1);
    final Poisoner poisoner = new Poisoner();
    final Player bob = PlayerTestHelper.createPlayer("player");
    poisoner.feed(c200_1, bob);
    assertTrue(bob.isPoisoned());
View Full Code Here

   * Tests for poisoner.
   */
  @Test
  public void testPoisoner() {
    final String poisontype = "greater poison";
    final ConsumableItem poison = (ConsumableItem) SingletonRepository.getEntityManager().getItem(poisontype);

    final Poisoner poisoner = new Poisoner(100, poison);
    final Player victim = PlayerTestHelper.createPlayer("bob");
    poisoner.attack(victim);
    assertTrue(victim.isPoisoned());
View Full Code Here

   * Tests for poisonerProbabilityZero.
   */
  @Test
  public void testPoisonerProbabilityZero() {
    final String poisontype = "greater poison";
    final ConsumableItem poison = (ConsumableItem) SingletonRepository.getEntityManager().getItem(poisontype);

    final Poisoner poisoner = new Poisoner(0, poison);
    final Player victim = PlayerTestHelper.createPlayer("bob");
    poisoner.attack(victim);
    assertFalse(victim.isPoisoned());
View Full Code Here

  }

  public void consume(final int turn) {
    Collections.sort(itemsToConsume);
    if (itemsToConsume.size() > 0) {
      final ConsumableItem food = itemsToConsume.get(0);
      if (food.consumed()) {
        itemsToConsume.remove(0);
      } else {
        if (turn % food.getFrecuency() == 0) {
          logger.debug("Consumed item: " + food);
          final int amount = food.consume();
          if (isChoking()) {
            put("choking", amount);
          } else {
            if (has("choking")) {
              remove("choking");
View Full Code Here

  public boolean attack(final RPEntity victim) {
    final int roll = Rand.roll1D100();
    if (roll <= probability) {
      if (victim instanceof Player) {
        final Player player = (Player) victim;
        if (player.poison(new ConsumableItem(poison))) {
          return true;
        }
      }
    }
    return false;
View Full Code Here

  private static Logger logger = Logger.getLogger(PoisonerFactory.class);

  public static Attacker get(final String profile) {
    if (profile != null) {
      final String[] poisonparams = profile.split(",");
      final ConsumableItem poison = (ConsumableItem) SingletonRepository.getEntityManager().getItem(poisonparams[1]);

      if (poison == null) {
        logger .error("Cannot create poisoner with " + poisonparams[1]);
        return nonpoisonous;
      }
View Full Code Here

TOP

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

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.