Package games.stendhal.server.entity.item

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


    assertEquals("I am an expert on #'wedding rings' and #'emerald rings', sometimes called the ring of #life.", getReply(npc));
    assertTrue(en.step(player, "emerald"));
    assertEquals("It is difficult to get the ring of life. Do a favour for a powerful elf in Nal'wor and you may receive one as a reward.", getReply(npc));
    assertTrue(en.step(player, "bye"));
    // -----------------------------------------------
    final RingOfLife ring = (RingOfLife) SingletonRepository.getEntityManager().getItem("emerald ring");
    player.getSlot("bag").add(ring);
    assertTrue(en.step(player, "hi"));
    assertEquals("Hi! Can I #help you?", getReply(npc));
    assertTrue(en.step(player, "help"));
    assertEquals("I am an expert on #'wedding rings' and #'emerald rings', sometimes called the ring of #life.", getReply(npc));
    assertTrue(en.step(player, "emerald"));
    assertEquals("I see you already have an emerald ring. If it gets broken, you can come to me to fix it.", getReply(npc));

    // break the ring don't give them money and make them lie that they have it
    ring.damage();
    assertTrue(en.step(player, "emerald"));
    assertEquals("What a pity, your emerald ring is broken. I can fix it, for a #price.", getReply(npc));
    assertTrue(en.step(player, "price"));
    assertEquals("The charge for my service is 80000 money, and I need 2 gold bars and 1 emerald to fix the ring. Do you want to pay now?", getReply(npc));
    assertTrue(en.step(player, "yes"));
View Full Code Here


   
    // -----------------------------------------------
    // this time say no they don't want to pay yet
    npc = SingletonRepository.getNPCList().get("Ognir");
    en = npc.getEngine();
    final RingOfLife ring = (RingOfLife) SingletonRepository.getEntityManager().getItem("emerald ring");
    ring.damage();
    player.getSlot("bag").add(ring);
    assertTrue(en.step(player, "hi"));
    assertEquals("Hi! Can I #help you?", getReply(npc));
    assertTrue(en.step(player, "help"));
    assertEquals("I am an expert on #'wedding rings' and #'emerald rings', sometimes called the ring of #life.", getReply(npc));
View Full Code Here

   * Tests for orderEmeraldRing.
   */
  @Test
  public void testOrderEmeraldRing() {
   
    final RingOfLife ring = (RingOfLife) SingletonRepository.getEntityManager().getItem("emerald ring");
    ring.damage();
    player.equipToInventoryOnly(ring);
   
    PlayerTestHelper.equipWithMoney(player, 80000);
    PlayerTestHelper.equipWithStackableItem(player, "gold bar", 2);
    PlayerTestHelper.equipWithStackableItem(player, "emerald", 1);
View Full Code Here

  /**
   * Tests for giveBoundRingGetBoundRing.
   */
  @Test
  public void testgiveBoundRingGetBoundRing() {
    final RingOfLife ring = (RingOfLife) SingletonRepository.getEntityManager().getItem("emerald ring");
    ring.damage();
    player.equipToInventoryOnly(ring);
    ring.setBoundTo(player.getName());
    orderfixandfetchordered(player);
    final Item ringafter = player.getFirstEquipped("emerald ring");
    assertTrue(ringafter.isBound());
    assertTrue(player.isBoundTo(ringafter));
    assertEquals("You see an emerald ring, known as ring of life. Wear it, and you risk less from death.", ringafter.getDescription());
View Full Code Here

  /**
   * Tests for giveUnboundRingGetUnboundRing.
   */
  @Test
  public void testgiveUnboundRingGetUnboundRing() {
    final RingOfLife ring = (RingOfLife) SingletonRepository.getEntityManager().getItem("emerald ring");
    ring.damage();
    player.equipToInventoryOnly(ring);
   
    assertFalse(ring.isBound());
    orderfixandfetchordered(player);
    final Item ringafter = player.getFirstEquipped("emerald ring");
    assertFalse(ringafter.isBound());
 
  }
View Full Code Here

      final List<RingOfLife> ringList = player.getAllEquippedWorkingRingOfLife();
      // A very unlucky player might drop the ring too
      for (Item item : drops) {
        if (item instanceof RingOfLife) {
          RingOfLife ring = (RingOfLife) item;
          if (!ring.isBroken()) {
            ringList.add((RingOfLife) item);
          }
        }
      }
     
View Full Code Here

    zone.add(hasRingGood);
    zone.add(hasRingBad);
    zone.add(hasNoRingGood);
                zone.add(hasNoRingBad);
   
    final RingOfLife ring = new RingOfLife();
    hasRingGood.equip("bag", ring);
    final RingOfLife ring2 = new RingOfLife();
    hasRingBad.equip("bag", ring2);

    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() {
    });

    final PlayerDieer dierWithRingBad = new PlayerDieer(hasRingBad);
    dierWithRingBad.dropItemsOn(corpse);
    dierWithRingBad.onDead(new Entity() {
    });

    final PlayerDieer dierWithoutRingGood = new PlayerDieer(hasNoRingGood);
    dierWithoutRingGood.dropItemsOn(corpse);
    dierWithoutRingGood.onDead(new Entity() {
    });
    final PlayerDieer dierWithoutRingBad = new PlayerDieer(hasNoRingBad);
    dierWithoutRingBad.dropItemsOn(corpse);
    dierWithoutRingBad.onDead(new Entity() {
    });

    assertTrue(ring.isBroken());
                assertTrue(ring2.isBroken());
   
    assertThat("ring wearer, good loses max 1 percent", hasRingGood.getXP(), greaterThan(9899));
    assertThat("ring wearer, good loses min 0 percent", hasRingGood.getXP(), lessThan(10001));

    assertThat("ring wearer, bad loses max 2 percent", hasRingBad.getXP(), greaterThan(9799));
View Full Code Here

                   new NotCondition(new QuestStateStartsWithCondition(QUEST_SLOT, FORGING))),
      ConversationStates.QUEST_ITEM_BROUGHT,
      null,
      new ChatAction() {
        public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
          final RingOfLife emeraldRing = (RingOfLife) player.getFirstEquipped("emerald ring");
         
            if (emeraldRing.isBroken()) {
              npc.say("What a pity, your emerald ring is broken. I can fix it, for a #price.");
            } else {
              // ring is not broken so he just lets player know
              // where it can be fixed
              npc.say("I see you already have an emerald ring. If it gets broken, you can come to me to fix it.");
              npc.setCurrentState(ConversationStates.ATTENDING);
            }
         
        }
      });
   
    npc.add(ConversationStates.ATTENDING,
        Arrays.asList("emerald ring", "life", "emerald"),
        new AndCondition(new NotCondition(new PlayerHasItemWithHimCondition("emerald ring")),
                 new NotCondition(new QuestStateStartsWithCondition(QUEST_SLOT, FORGING))),

        ConversationStates.ATTENDING,
        "It is difficult to get the ring of life. Do a favour for a powerful elf in Nal'wor and you may receive one as a reward."
        , null);
 
    npc.add(ConversationStates.ATTENDING,
        Arrays.asList("emerald ring", "life", "emerald"),
        new AndCondition(new QuestStateStartsWithCondition(QUEST_SLOT, FORGING),
            new NotCondition(new QuestStateStartsWithCondition(QUEST_SLOT, FORGING + "unbound")),
            new TimePassedCondition(QUEST_SLOT,1,REQUIRED_MINUTES)),
        ConversationStates.ATTENDING,
        "I'm pleased to say, your ring of life is fixed! It's good as new now.",
        new MultipleActions(
            new IncreaseXPAction(500),
            new SetQuestAction(QUEST_SLOT, "done"),
            new EquipItemAction("emerald ring", 1, true)));
   
    npc.add(ConversationStates.ATTENDING,
        Arrays.asList("emerald ring", "life", "emerald"),
        new AndCondition(new QuestStateStartsWithCondition(QUEST_SLOT, FORGING),
            new QuestStateStartsWithCondition(QUEST_SLOT, FORGING + "unbound"),
            new TimePassedCondition(QUEST_SLOT,1,REQUIRED_MINUTES)),
        ConversationStates.ATTENDING,
        "I'm pleased to say, your ring of life is fixed! It's good as new now.",
        new MultipleActions(
            new IncreaseXPAction(500),
            new SetQuestAction(QUEST_SLOT, "done"),
            new EquipItemAction("emerald ring", 1, false)));

    npc.add(ConversationStates.ATTENDING,
        Arrays.asList("emerald ring", "life", "emerald"),
        new AndCondition(new QuestStateStartsWithCondition(QUEST_SLOT, FORGING),
            new NotCondition(new TimePassedCondition(QUEST_SLOT,1,REQUIRED_MINUTES))),
        ConversationStates.IDLE, null,
        new SayTimeRemainingAction(QUEST_SLOT,1, REQUIRED_MINUTES,"I haven't finished fixing your ring of life. Please check back in"));
   
   
    npc.add(ConversationStates.QUEST_ITEM_BROUGHT,
        "price",
        null,
        ConversationStates.QUEST_ITEM_BROUGHT,
        "The charge for my service is " + REQUIRED_MONEY
          + " money, and I need " + REQUIRED_GOLD
          + " gold bars and " + REQUIRED_GEM
          + " emerald to fix the ring. Do you want to pay now?",
        null);

    npc.add(ConversationStates.QUEST_ITEM_BROUGHT,
        ConversationPhrases.YES_MESSAGES,
        new AndCondition(
            new PlayerHasItemWithHimCondition("gold bar", REQUIRED_GOLD),
            new PlayerHasItemWithHimCondition("money", REQUIRED_MONEY),
            new PlayerHasItemWithHimCondition("emerald", REQUIRED_GEM)),
        ConversationStates.IDLE,
        "Okay, that's all I need to fix the ring. Come back in "
            + REQUIRED_MINUTES
            + " minutes and it will be ready. Bye for now.",
        new MultipleActions(
            new DropItemAction("gold bar", REQUIRED_GOLD),
            new DropItemAction("emerald", REQUIRED_GEM),
            new DropItemAction("money", REQUIRED_MONEY),
            new ChatAction() {
              public void fire(final Player player,
                  final Sentence sentence,
                  final EventRaiser npc) {
                final RingOfLife emeraldRing = (RingOfLife) player.getFirstEquipped("emerald ring");
                if (player.isBoundTo(emeraldRing)) {
                  player.setQuest(QUEST_SLOT, "forging;"
                      + System.currentTimeMillis());
                } else {
                  player.setQuest(QUEST_SLOT, "forgingunbound;"
View Full Code Here

  @Override
  public List<String> getHistory(final Player player) {
    final List<String> res = new ArrayList<String>();
    if (player.isEquipped("emerald ring")) {
      final RingOfLife emeraldRing = (RingOfLife) player.getFirstEquipped("emerald ring");
      if (emeraldRing.isBroken()) {
        res.add("Oh no! My ring of life is broken. I must look for an expert craftsman to help me fix it.");
      }
    }
    if (!player.hasQuest(QUEST_SLOT)) {
      return res;
View Full Code Here

    for (final String slotName : Constants.CARRYING_SLOTS) {
      final RPSlot slot = getSlot(slotName);

      for (final RPObject object : slot) {
        if (object instanceof RingOfLife) {
          final RingOfLife ring =  (RingOfLife) object;
          if (!ring.isBroken()) {
            result.add(ring);
          }

        }
      }
View Full Code Here

TOP

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

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.