Package games.stendhal.server.entity.item

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


   * Tests for getSlotNameToEquip.
   */
  @Test
  public void testGetSlotNameToEquip() {
    final RPEntity baglessentity = new MockRPentity();
    final Item item = createMock(Item.class);
    final List<String> slotnames = Arrays.asList("bag");
    expect(item.getPossibleSlots()).andReturn(slotnames);
    replay(item);
    assertEquals(null, baglessentity.getSlotNameToEquip(item));
    verify(item);

    reset(item);
    final RPEntity entityWithBag = new MockRPentity() {
      @Override
      public boolean hasSlot(final String arg0) {
        return true;
      }

      @Override
      public RPSlot getSlot(final String arg0) {
        return new RPSlot();
      }
    };
    expect(item.getPossibleSlots()).andReturn(slotnames);

    replay(item);
    assertEquals("bag", entityWithBag.getSlotNameToEquip(item));
    verify(item);

    reset(item);
    final RPEntity entityWithFullBag = new MockRPentity() {
      @Override
      public boolean hasSlot(final String arg0) {
        return true;
      }

      @Override
      public RPSlot getSlot(final String arg0) {
        return new RPSlot() {
          @Override
          public boolean isFull() {
            return true;
          }
        };
      }
    };
    expect(item.getPossibleSlots()).andReturn(slotnames);

    replay(item);
    assertEquals(null, entityWithFullBag.getSlotNameToEquip(item));
    verify(item);
  }
View Full Code Here


      for (final RPObject object : slot) {
        if (!(object instanceof Item)) {
          continue;
        }

        final Item item = (Item) object;

        if (item.getName().equals(name)) {
          found += item.getQuantity();

          if (found >= amount) {
            return true;
          }
        }
View Full Code Here

    this.itemName = itemName;
  }


  public boolean fire(final Player player, final Sentence sentence, final Entity entity) {
    final Item item = SingletonRepository.getEntityManager().getItem(itemName);
    return player.getSlotNameToEquip(item)!=null;
  }
View Full Code Here

  }

  @Override
  protected void doRegularBehaviour() {
    if(Rand.throwCoin()==1) {
      final Item item = SingletonRepository.getEntityManager().getItem(itemName);
      final IRPZone zone = speakerNPC.getZone();
      // place under NPC
      item.setPosition(speakerNPC.getX(), speakerNPC.getY());
      zone.add(item);
    }
    super.doRegularBehaviour();
  }
View Full Code Here

            return;
          }
          npc.say("Here your fabric is ready! Isn't it gorgeous?");
          player.addXP(100);
          player.addKarma(15);
          final Item fabric = SingletonRepository.getEntityManager().getItem(
                  mithrilcloak.getFabricName());
          fabric.setBoundTo(player.getName());
          player.equipOrPutOnGround(fabric);
          player.setQuest(mithrilcloak.getQuestSlot(), "got_fabric");
          player.notifyWorldAboutChanges();
        }
      });
View Full Code Here

            return;
          }
          npc.say("Here, your clasp is ready!");
          player.addXP(100);
          player.addKarma(15);
          final Item clasp = SingletonRepository.getEntityManager().getItem(
                  "mithril clasp");
          clasp.setBoundTo(player.getName());
          player.equipOrPutOnGround(clasp);
          player.setQuest(mithrilcloak.getQuestSlot(), "got_clasp");
          player.notifyWorldAboutChanges();
        }
      });
View Full Code Here

      boolean isStillFilled = false;
      // Check if the item is still in the corpse. Note that somebody
      // might have put other stuff into the corpse.
      for (final RPObject object : corpse.getSlot("content")) {
        if (object instanceof Item) {
          final Item item = (Item) object;
          if (equalsExpectedItem(item)) {
            isStillFilled = true;
          }
        }
      }
      try {
        if (!isStillFilled) {
          // recreate the item and fill the corpse
          final Item item = SingletonRepository.getEntityManager().getItem(
              itemName);
          item.setInfoString(corpse.getName());
          item.setDescription(description);
          corpse.add(item);
          corpse.notifyWorldAboutChanges();
        }
      } catch (final SlotIsFullException e) {
        // ignore, just don't refill the corpse until someone removes
View Full Code Here

    public GiveMapAction(boolean bind) {
      this.bind = bind;
    }

    public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
      final Item map = SingletonRepository.getEntityManager().getItem("map");
      map.setInfoString(npc.getName());
      map.setDescription("You see a hand drawn map, but no matter how you look at it, nothing on it looks familiar.");
      if (bind) {
        map.setBoundTo(player.getName());
      }
      player.equipOrPutOnGround(map);
      player.setQuest(QUEST_SLOT, "map");
    }
View Full Code Here

            return;
          }
          npc.say("Ah, thanks for reminding me. Here, Ida's scissors are ready. You better take them to her next as I don't know what she wanted them for.");
          player.addXP(100);
          player.addKarma(15);
          final Item scissors = SingletonRepository.getEntityManager().getItem(
                  "magical scissors");
          scissors.setBoundTo(player.getName());
          player.equipOrPutOnGround(scissors);
          player.setQuest(mithrilcloak.getQuestSlot(), "got_scissors");
          player.notifyWorldAboutChanges();
        }
      });
View Full Code Here

          }

          raiser.say("I have finished forging your new mithril shield. Enjoy. Now I will see what Trillium has stored behind the counter for me. ;)");
          player.addXP(95000);
          player.addKarma(25);
          final Item mithrilshield = SingletonRepository.getEntityManager().getItem("mithril shield");
          mithrilshield.setBoundTo(player.getName());
          player.equipOrPutOnGround(mithrilshield);
          player.notifyWorldAboutChanges();
          player.setQuest(QUEST_SLOT, "done");
        }
      });
View Full Code Here

TOP

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

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.