예제 #1
0
  /** Tests for successful placement of an offer. */
  @Test
  public void testSuccessfullOfferPlacement() {
    final SpeakerNPC npc = getNPC("Harold");
    final Engine en = npc.getEngine();
    player.addXP(1700);

    Item item = SingletonRepository.getEntityManager().getItem("axe");
    StackableItem playersMoney =
        (StackableItem) SingletonRepository.getEntityManager().getItem("money");
    Integer price = Integer.valueOf(1500);
    playersMoney.setQuantity(price);
    player.equipToInventoryOnly(item);
    player.equipToInventoryOnly(playersMoney);

    assertTrue(en.step(player, "hello"));
    assertEquals("Welcome to Semos trading center. How can I #help you?", getReply(npc));

    assertTrue(en.step(player, "sell axe 150000"));
    assertEquals(
        "Do you want to sell an axe for 150000 money? It would cost you 1500 money.",
        getReply(npc));

    assertTrue(en.step(player, "yes"));
    assertEquals(
        "I added your offer to the trading center and took the fee of 1500.", getReply(npc));

    assertTrue(en.step(player, "bye"));
    assertEquals(
        "Visit me again to see available offers, make a new offer or fetch your earnings!",
        getReply(npc));
  }
예제 #2
0
  @Test
  public void quest() {

    final Player player = PlayerTestHelper.createPlayer("player");

    final Engine en = hayunn.getEngine();
    en.step(player, "hi");
    // we assume the player has already completed the meet hayunn quest
    // so that we know which of the greetings he will use
    player.setQuest("meet_hayunn", "done");
    assertTrue(player.isQuestCompleted("meet_hayunn"));
    assertTrue(hayunn.isTalking());
    assertEquals(
        "Hi. I bet you've been sent here to learn about adventuring from me. First, lets see what you're made of. Go and kill a rat outside, you should be able to find one easily. Do you want to learn how to attack it, before you go?",
        getReply(hayunn));
    en.step(player, "quest");
    assertEquals(
        "My mouth is dry, but I can't be seen to abandon this teaching room! Could you bring me some #beer from the #tavern?",
        getReply(hayunn));
    en.step(player, "yes");
    assertTrue(player.hasQuest("beer_hayunn"));
    en.step(player, "bye");
    assertFalse(hayunn.isTalking());
    assertEquals("start", player.getQuest("beer_hayunn"));
    final StackableItem beer = new StackableItem("beer", "", "", null);
    beer.setQuantity(1);
    beer.setID(new ID(2, "testzone"));
    player.getSlot("bag").add(beer);
    assertEquals(1, player.getNumberOfEquipped("beer"));
    en.step(player, "hi");
    en.step(player, "yes");
    assertEquals("done", player.getQuest("beer_hayunn"));
    en.step(player, "bye");
    // reject
    final Player player2 = PlayerTestHelper.createPlayer("player");

    en.step(player2, "hi");
    player2.setQuest("meet_hayunn", "done");
    assertTrue(player2.isQuestCompleted("meet_hayunn"));
    assertTrue(hayunn.isTalking());
    assertEquals(
        "Hi. I bet you've been sent here to learn about adventuring from me. First, lets see what you're made of. Go and kill a rat outside, you should be able to find one easily. Do you want to learn how to attack it, before you go?",
        getReply(hayunn));
    en.step(player2, "quest");
    assertEquals(
        "My mouth is dry, but I can't be seen to abandon this teaching room! Could you bring me some #beer from the #tavern?",
        getReply(hayunn));
    en.step(player2, "no");
    assertTrue(player2.hasQuest("beer_hayunn"));
    assertEquals("rejected", player2.getQuest("beer_hayunn"));
    en.step(player2, "bye");
  }
 private void equipPlayer(Player player) {
   StackableItem money = (StackableItem) SingletonRepository.getEntityManager().getItem("money");
   money.setQuantity(5000);
   player.equipToInventoryOnly(money);
   StackableItem potions =
       (StackableItem) SingletonRepository.getEntityManager().getItem("greater potion");
   potions.setQuantity(5000);
   player.equipToInventoryOnly(potions);
   if (!player.isEquipped("chaos dagger")) {
     Item first = (Item) player.getSlot("rhand").getFirst();
     player.drop(first);
     Item dagger = SingletonRepository.getEntityManager().getItem("chaos dagger");
     player.equip("rhand", dagger);
   }
   if (!player.isEquipped("chaos shield")) {
     Item first = (Item) player.getSlot("lhand").getFirst();
     player.drop(first);
     Item shield = SingletonRepository.getEntityManager().getItem("chaos shield");
     player.equip("lhand", shield);
   }
   if (!player.isEquipped("black helmet")) {
     Item first = (Item) player.getSlot("head").getFirst();
     player.drop(first);
     Item helmet = SingletonRepository.getEntityManager().getItem("black helmet");
     player.equip("head", helmet);
   }
   if (!player.isEquipped("elvish legs")) {
     Item first = (Item) player.getSlot("legs").getFirst();
     player.drop(first);
     Item legs = SingletonRepository.getEntityManager().getItem("elvish legs");
     player.equip("legs", legs);
   }
   if (!player.isEquipped("killer boots")) {
     Item first = (Item) player.getSlot("feet").getFirst();
     player.drop(first);
     Item boots = SingletonRepository.getEntityManager().getItem("killer boots");
     player.equip("feet", boots);
   }
   if (!player.isEquipped("green dragon cloak")) {
     Item first = (Item) player.getSlot("cloak").getFirst();
     player.drop(first);
     Item cloak = SingletonRepository.getEntityManager().getItem("green dragon cloak");
     player.equip("cloak", cloak);
   }
 }
예제 #4
0
  /** Test selling a container item. */
  @Test
  public void testSellContainer() {
    final SpeakerNPC npc = getNPC("Harold");
    final Engine en = npc.getEngine();
    player.addXP(1700);

    Item item = SingletonRepository.getEntityManager().getItem("keyring");
    StackableItem playersMoney =
        (StackableItem) SingletonRepository.getEntityManager().getItem("money");
    Integer price = Integer.valueOf(1500);
    playersMoney.setQuantity(price);
    player.equipToInventoryOnly(item);
    player.equipToInventoryOnly(playersMoney);

    Item key = SingletonRepository.getEntityManager().getItem("dungeon silver key");
    item.getSlot("content").add(key);

    assertTrue(en.step(player, "hello"));
    assertEquals("Welcome to Semos trading center. How can I #help you?", getReply(npc));

    // Try first selling it when it's not empty
    assertTrue(en.step(player, "sell keyring 150000"));
    assertEquals("Please empty your keyring first.", getReply(npc));
    assertTrue(player.isEquipped("keyring"));
    assertTrue(player.isEquipped("dungeon silver key"));

    // Then after emptying it
    item.getSlot("content").clear();
    assertTrue(en.step(player, "sell keyring 150000"));
    assertEquals(
        "Do you want to sell a keyring for 150000 money? It would cost you 1500 money.",
        getReply(npc));

    assertTrue(en.step(player, "yes"));
    assertEquals(
        "I added your offer to the trading center and took the fee of 1500.", getReply(npc));
    assertFalse(player.isEquipped("keyring"));
    assertFalse(player.isEquipped("dungeon silver key"));

    assertTrue(en.step(player, "bye"));
    assertEquals(
        "Visit me again to see available offers, make a new offer or fetch your earnings!",
        getReply(npc));
  }