Package games.stendhal.server.entity.player

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


  /**
   * Tests for isPlayerAllowedToExecuteAdminCommand.
   */
  @Test
  public final void testIsPlayerAllowedToExecuteAdminCommand() {
    final Player pl = PlayerTestHelper.createPlayer("player");
    assertTrue(AdministrationAction.isPlayerAllowedToExecuteAdminCommand(
        pl, "", true));
    assertTrue(AdministrationAction.isPlayerAllowedToExecuteAdminCommand(
        pl, "adminlevel", true));
    pl.setAdminLevel(50);
    pl.clearEvents();
    assertEquals(true, AdministrationAction
        .isPlayerAllowedToExecuteAdminCommand(pl, "adminlevel", true));
    assertEquals(true,
        AdministrationAction.isPlayerAllowedToExecuteAdminCommand(pl,
            "supportanswer", true));
View Full Code Here


  /**
   * Tests for tellAllAction.
   */
  @Test
  public final void testTellAllAction() {
    final Player pl = PlayerTestHelper.createPlayer("dummy");
    MockStendhalRPRuleProcessor.get().addPlayer(pl);

    CommandCenter.execute(pl, new RPAction());
    assertEquals("Unknown command null. Please type /help to get a list.", pl.events().get(0).get("text"));

    pl.clearEvents();
    pl.setAdminLevel(5000);
    final RPAction action = new RPAction();
    action.put("type", "tellall");
    action.put("text", "huhu");
    CommandCenter.execute(pl, action);
    assertEquals("Administrator SHOUTS: huhu", pl.events().get(0).get("text"));
 
  }
View Full Code Here

  /**
   * Tests for supportAnswerAction.
   */
  @Test
  public final void testSupportAnswerAction() {
    final Player pl = PlayerTestHelper.createPlayer("player");
    final Player bob = PlayerTestHelper.createPlayer("bob");
    final Player anptherAdmin = PlayerTestHelper.createPlayer("anotheradmin");
    anptherAdmin.setAdminLevel(5000);
    MockStendhalRPRuleProcessor.get().addPlayer(pl);
    MockStendhalRPRuleProcessor.get().addPlayer(bob);
    MockStendhalRPRuleProcessor.get().addPlayer(anptherAdmin);

    pl.setAdminLevel(5000);
    final RPAction action = new RPAction();
    action.put("type", "supportanswer");
    action.put("text", "huhu");
    action.put("target", "bob");
    CommandCenter.execute(pl, action);
    assertEquals("Support (player) tells you: huhu \nIf you wish to reply, use /support.", bob.events().get(0).get("text"));
    assertEquals("player answers bob's support question: huhu", anptherAdmin.events().get(0).get("text"));

    bob.clearEvents();
    pl.clearEvents();
    pl.setAdminLevel(0);
    assertEquals("0", pl.get("adminlevel"));
View Full Code Here

   * Tests for teleportActionToInvalidZone.
   */
  @Test
  public final void testTeleportActionToInvalidZone() {

    final Player pl = PlayerTestHelper.createPlayer("player");
    final Player bob = PlayerTestHelper.createPlayer("bob");
    MockStendhalRPRuleProcessor.get().addPlayer(pl);
    MockStendhalRPRuleProcessor.get().addPlayer(bob);

    pl.setAdminLevel(5000);
    final RPAction action = new RPAction();
View Full Code Here

   */
  @Test
  public final void testTeleportActionToValidZone() {

    final StendhalRPZone zoneTo = new StendhalRPZone("zoneTo");
    final Player pl = PlayerTestHelper.createPlayer("player");
    MockStendhalRPRuleProcessor.get().addPlayer(pl);
    PlayerTestHelper.generatePlayerRPClasses();
    final Player bob = new Player(new RPObject()) {
      @Override
      public boolean teleport(final StendhalRPZone zone, final int x, final int y,
          final Direction dir, final Player teleporter) {
        assertEquals("zoneTo", zone.getName());
        setName("hugo");
        return true;

      }
    };
    bob.setName("bob");
    PlayerTestHelper.addEmptySlots(bob);

    MockStendhalRPRuleProcessor.get().addPlayer(bob);

    MockStendlRPWorld.get().addRPZone(zoneTo);
    pl.setAdminLevel(5000);
    final RPAction action = new RPAction();
    action.put("type", "teleport");
    action.put("text", "huhu");
    action.put("target", "bob");
    action.put("zone", "zoneTo");
    action.put("x", "0");
    action.put("y", "0");

    assertTrue(action.has("target") && action.has("zone")
        && action.has("x"));
    assertThat(bob.getName(), not(is("hugo")));
    CommandCenter.execute(pl, action);
    assertEquals("name must have changed, if action was executed", "hugo", bob.getName());
  }
View Full Code Here

  /**
   * Tests for teleportToActionPlayerNotThere.
   */
  @Test
  public final void testTeleportToActionPlayerNotThere() {
    final Player pl = PlayerTestHelper.createPlayer("player");
    pl.setAdminLevel(5000);
    final RPAction action = new RPAction();
    action.put("type", "teleportto");
    action.put("target", "blah");
    CommandCenter.execute(pl, action);
    assertEquals("Player \"blah\" not found", pl.events().get(0).get("text"));
  }
View Full Code Here

   * Tests for teleportToActionPlayerThere.
   */
  @Test
  public final void testTeleportToActionPlayerThere() {

    final Player pl = PlayerTestHelper.createPlayer("blah");

    pl.setAdminLevel(5000);

    MockStendhalRPRuleProcessor.get().addPlayer(pl);
    final StendhalRPZone zone = new StendhalRPZone("zone");
    zone.add(pl);
    final RPAction action = new RPAction();
    action.put("type", "teleportto");
    action.put("target", "blah");
    CommandCenter.execute(pl, action);
    assertEquals("Position [0,0] is occupied", pl.events().get(0).get("text"));
  }
View Full Code Here

  /**
   * Tests for onAlterActionWrongAttribute.
   */
  @Test
  public final void testOnAlterActionWrongAttribute() {
    final Player pl = PlayerTestHelper.createPlayer("bob");
    pl.setAdminLevel(5000);

    MockStendhalRPRuleProcessor.get().addPlayer(pl);

    final RPAction action = new RPAction();
    action.put("type", "alter");
    action.put("target", "bob");
    action.put("stat", "0");
    action.put("mode", "");
    action.put("value", 0);

    CommandCenter.execute(pl, action);
    assertEquals(
        "Attribute you are altering is not defined in RPClass(player)",
        pl.events().get(0).get("text"));
  }
View Full Code Here

   * Tests for onAlterAction.
   */
  @Test
  public final void testOnAlterAction() {

    final Player pl = PlayerTestHelper.createPlayer("bob");
    pl.setAdminLevel(5000);

    MockStendhalRPRuleProcessor.get().addPlayer(pl);

    final RPAction action = new RPAction();
    action.put("type", "alter");
    action.put("target", "bob");
    action.put("stat", "name");
    action.put("mode", "");
    action.put("value", 0);

    CommandCenter.execute(pl, action);
    assertEquals("Sorry, name cannot be changed.", pl.events().get(0).get("text"));
    action.put("stat", "adminlevel");
    pl.clearEvents();
    CommandCenter.execute(pl, action);
    assertEquals(
        "Use #/adminlevel #<playername> #[<newlevel>] to display or change adminlevel.",
        pl.events().get(0).get("text"));
  }
View Full Code Here

  /**
   * Tests for onAlterActionTitle.
   */
  @Test
  public final void testOnAlterActionTitle() {
    final Player pl = PlayerTestHelper.createPlayer("bob");
    pl.setAdminLevel(5000);

    MockStendhalRPRuleProcessor.get().addPlayer(pl);

    final RPAction action = new RPAction();
    action.put("type", "alter");
    action.put("target", "bob");
    action.put("stat", "title");
    action.put("mode", "");
    action.put("value", 0);

    CommandCenter.execute(pl, action);
    assertEquals("The title attribute may not be changed directly.", pl
        .events().get(0).get("text"));
  }
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.