Package games.stendhal.server.entity.player

Examples of games.stendhal.server.entity.player.Player


  /**
   * Tests for ghostmode.
   */
  @Test
  public final void testGhostmode() {
    final Player hugo = PlayerTestHelper.createPlayer("hugo");
    hugo.put("adminlevel", 5000);
   
    final Player bob = PlayerTestHelper.createPlayer("bob21233");
    bob.put("buddies", hugo.getName(), true);

    final Player jack = PlayerTestHelper.createPlayer("jack");
   
    MockStendhalRPRuleProcessor.get().addPlayer(hugo);
    MockStendhalRPRuleProcessor.get().addPlayer(bob);
    MockStendhalRPRuleProcessor.get().addPlayer(jack);
   
    final RPAction action = new RPAction();

    action.put("type", "ghostmode");
    assertFalse(hugo.isInvisibleToCreatures());
    assertFalse(hugo.isGhost());

    CommandCenter.execute(hugo, action);

    assertTrue(hugo.isInvisibleToCreatures());
    assertTrue(hugo.isGhost());

    assertEquals(null, bob.get("online"));
    assertEquals("hugo", bob.get("offline"));
   
    assertEquals(null, jack.get("online"));
    assertEquals(null, jack.get("offline"));

    bob.remove("offline");
    bob.clearEvents();
    CommandCenter.execute(hugo, action);

    assertTrue(hugo.isInvisibleToCreatures());
    assertFalse(hugo.isGhost());
   
    assertEquals("hugo", bob.get("online"));
    assertEquals(null, bob.get("offline"));
       
    assertEquals(null, jack.get("online"));
    assertEquals(null, jack.get("offline"));
  }
View Full Code Here


   * Tests for onWrongAction.
   */
  @Test
  public void testOnWrongAction() {
    final OutfitAction oa = new OutfitAction();
    final Player player = PlayerTestHelper.createPlayer("player");
    final RPAction action = new RPAction();
    oa.onAction(player, action);
    assertTrue("no exception thrown", true);
  }
View Full Code Here

   * Tests for onActionWrongValue.
   */
  @Test(expected = NumberFormatException.class)
  public void testOnActionWrongValue() {
    final OutfitAction oa = new OutfitAction();
    final Player player = PlayerTestHelper.createPlayer("player");
    final RPAction action = new RPAction();
    action.put("value", "schnick");
    oa.onAction(player, action);
  }
View Full Code Here

   * Tests for onAction.
   */
  @Test
  public void testOnAction() {
    final OutfitAction oa = new OutfitAction();
    final Player player = PlayerTestHelper.createPlayer("player");
    final RPAction action = new RPAction();
    assertNotNull(player.get("outfit"));
    action.put("value", 1);
    oa.onAction(player, action);
    assertTrue(player.has("outfit"));
    assertEquals("1", player.get("outfit"));

    action.put("value", 51515151);
    oa.onAction(player, action);
    assertTrue(player.has("outfit"));
    assertEquals("invalid player outfit", "1", player.get("outfit"));
  }
View Full Code Here

  /**
   * Tests for onAction.
   */
  @Test
  public void testOnAction() {
    final Player bob = PlayerTestHelper.createPlayer("bob");
    final RPAction action = new RPAction();
    action.put("type", "away");
    final AwayAction aa = new AwayAction();
    aa.onAction(bob, action);
    assertEquals(null, bob.getAwayMessage());
    action.put("message", "bla");
    aa.onAction(bob, action);
    assertEquals("bla", bob.getAwayMessage());
  }
View Full Code Here

  /**
   * Tests for onInvalidAction.
   */
  @Test
  public void testOnInvalidAction() {
    final Player bob = PlayerTestHelper.createPlayer("bob");
    bob.clearEvents();
    final RPAction action = new RPAction();
    action.put("type", "bla");
    action.put("message", "bla");
    final AwayAction aa = new AwayAction();
    aa.onAction(bob, action);
    assertEquals(null, bob.getAwayMessage());
  }
View Full Code Here

    SingletonRepository.getNPCList().add(new SpeakerNPC("Balduin"));
    final WeaponsCollector2 wc = new WeaponsCollector2();
    wc.addToWorld();
    final SpeakerNPC npc = wc.getNPC();
    final Engine en = npc.getEngine();
    final Player pl = PlayerTestHelper.createPlayer("player");

    // set previous quest to done
    pl.setQuest("weapons_collector", "done");

    assertTrue(en.stepTest(pl, ConversationPhrases.GREETING_MESSAGES.get(0)));
    assertEquals(
        "Greetings, old friend. If you are willing, I have another #quest for you.",
        getReply(npc));
View Full Code Here

    final WeaponsCollector2 wc = new WeaponsCollector2();
 
    wc.addToWorld();
    final SpeakerNPC npc = wc.getNPC();
    final Engine en = npc.getEngine();
    final Player pl = PlayerTestHelper.createPlayer("player");

    // set previous quest to done
    pl.setQuest("weapons_collector", "done");

    assertTrue(en.stepTest(pl, "hello"));
    assertEquals(
        "Greetings, old friend. If you are willing, I have another #quest for you.",
        getReply(npc));

    assertTrue(en.stepTest(pl, "quest"));
    assertEquals(
        "Recent adventurers to these parts describe strange new creatures with weapons"
            + " I have never seen. Would you fight these creatures and bring their weapons to me?",
        getReply(npc));

    assertTrue(en.stepTest(pl, ConversationPhrases.YES_MESSAGES.get(0)));
    assertEquals(
        "Wonderful. Now, the #list is small but the risk may be great. If you return safely, I have another reward for you.",
        getReply(npc));

    assertTrue(en.stepTest(pl, "list"));
    assertEquals(
        "There are 3 weapons still missing from my newest collection: #'morning star', #staff, and #'great sword'."
            + " Do you have anything like that with you?",
        getReply(npc));

    assertTrue(en.stepTest(pl, "no"));
    assertEquals("Let me know as soon as you find them. Farewell.",
        getReply(npc));

    // start another conversation
    assertTrue(en.stepTest(pl, "hi"));
    assertEquals(
        "Welcome back. I hope you have come to help me with my latest #list of weapons.",
        getReply(npc));

    assertTrue(en.stepTest(pl, "list"));
    assertEquals(
        "There are 3 weapons still missing from my newest collection: #'morning star', #staff, and #'great sword'."
            + " Do you have anything like that with you?",
        getReply(npc));

    assertTrue(en.stepTest(pl, "yes"));
    assertEquals("What did you find?", getReply(npc));

    Item weapon = new Item("morning star", "", "", null);
    pl.getSlot("bag").add(weapon);

    assertTrue(en.stepTest(pl, "morning star"));
    assertEquals("Thank you very much! Do you have anything more for me?",
        getReply(npc));

    assertTrue(en.stepTest(pl, "morning star"));
    assertEquals(
        "I already have that one. Do you have any other weapon for me?",
        getReply(npc));

    for (final String cloakName : wc.getNeededItems()) {
      weapon = new Item(cloakName, "", "", null);
      pl.getSlot("bag").add(weapon);
      en.step(pl, cloakName);
    }

    assertEquals(
        "At last, my collection is complete! Thank you very much; here, take this pair of swords in exchange!",
View Full Code Here

  @Test
  public void testOnAction() {

    final StopAction sa = new StopAction();
    PlayerTestHelper.generatePlayerRPClasses();
    final Player player = new Player(new RPObject()) {
      @Override
      public void stopAttack() {
        stopattack = true;

      }
View Full Code Here

   * Tests for onActionnotAtplayer.
   */
  @Test
  public void testOnActionnotAtplayer() {
    final WrapAction wrap = new WrapAction();
    final Player player = PlayerTestHelper.createPlayer("bob");
    final RPAction action = new RPAction();
    action.put("type", "wrap");
    action.put("args", "");
    wrap.onAction(player, action);
    assertThat(player.events().get(0).get("text"), is("You don't have any null"));
    player.clearEvents();

    action.put("args", "blabla");
    wrap.onAction(player, action);
    assertThat(player.events().get(0).get("text"), is("You don't have any null blabla"));

    player.clearEvents();

    action.put("target", "what");
    action.put("args", "blabla");
    wrap.onAction(player, action);
    assertThat(player.events().get(0).get("text"), is("You don't have any what blabla"));
  }
View Full Code Here

TOP

Related Classes of games.stendhal.server.entity.player.Player

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.