Package games.stendhal.server.entity.player

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


   * Tests for teleclickmode.
   */
  @Test
  public final void testTeleclickmode() {

    final Player pl = PlayerTestHelper.createPlayer("hugo");
    pl.setAdminLevel(5000);
    final RPAction action = new RPAction();
    action.put("type", "teleclickmode");
    assertFalse(pl.isTeleclickEnabled());
    CommandCenter.execute(pl, action);
    assertTrue(pl.isTeleclickEnabled());
    CommandCenter.execute(pl, action);
    assertFalse(pl.isTeleclickEnabled());
  }
View Full Code Here


   * Tests for summonDagger.
   */
  @Test
  public final void testSummonDagger() {

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

    MockStendhalRPRuleProcessor.get().addPlayer(pl);

    zone.add(pl);
    pl.setPosition(1, 1);
    pl.put("adminlevel", 5000);
    final RPAction action = new RPAction();
    action.put("type", "summon");
    action.put("creature", "dagger");
    action.put("x", 0);
    action.put("y", 0);
    CommandCenter.execute(pl, action);
    assertEquals(1, pl.getID().getObjectID());
    final Item item = (Item) zone.getEntityAt(0, 0);
    assertEquals("dagger", item.get("subclass"));
  }
View Full Code Here

  /**
   * Tests for summonUnKnown.
   */
  @Test
  public final void testSummonUnKnown() {
    final Player pl = PlayerTestHelper.createPlayer("hugo");

    MockStendhalRPRuleProcessor.get().addPlayer(pl);

    zone.add(pl);
    pl.setPosition(1, 1);
    pl.put("adminlevel", 5000);
    final RPAction action = new RPAction();
    action.put("type", "summon");
    action.put("creature", "unknown");
    action.put("x", 0);
    action.put("y", 0);
    CommandCenter.execute(pl, action);
    assertEquals(1, pl.getID().getObjectID());
    assertNull(zone.getEntityAt(0, 0));
  }
View Full Code Here

  @Test
  public final void testJail() throws SQLException, IOException {
   
    MockStendlRPWorld.get().addRPZone(new StendhalRPZone("-1_semos_jail", 100, 100));

    final Player player = PlayerTestHelper.createPlayer("hugo");
    PlayerTestHelper.registerPlayer(player, "-1_semos_jail");
    player.setAdminLevel(5000);

    RPAction action = new RPAction();
    action.put("type", "jail");

    CommandCenter.execute(player, action);
    assertEquals("Usage: /jail <name> <minutes> <reason>", player.events().get(0).get("text"));

    if (!DAORegister.get().get(CharacterDAO.class).hasCharacter("offlineplayer")) {
      RPObject rpobject = new RPObject();
      rpobject.setRPClass("player");
      rpobject.put("name", "offlineplayer");
      DAORegister.get().get(CharacterDAO.class).addCharacter("offlineplayer", "offlineplayer", rpobject);
    }

    player.clearEvents();
    action = new RPAction();
    action.put("type", "jail");
    action.put("target", "offlineplayer");
    action.put("reason", "whynot");
    action.put("minutes", 1);

    CommandCenter.execute(player, action);
    assertEquals("You have jailed offlineplayer for 1 minutes. Reason: whynot.", player.events().get(0).get("text"));
    assertEquals("JailKeeper asks for support to ADMIN: hugo jailed offlineplayer for 1 minutes. Reason: whynot.", player.events().get(1).get("text"));
    assertEquals("Player offlineplayer is not online, but the arrest warrant has been recorded anyway.", player.events().get(2).get("text"));
    player.clearEvents();


    player.clearEvents();
    action = new RPAction();
    action.put("type", "jail");
    action.put("target", "notexistingplayerxckjvhyxkjcvhyxkjvchk");
    action.put("reason", "whynot");
    action.put("minutes", 1);

    CommandCenter.execute(player, action);
    assertEquals("No character with that name: notexistingplayerxckjvhyxkjcvhyxkjvchk", player.events().get(0).get("text"));
    player.clearEvents();


    MockStendhalRPRuleProcessor.get().addPlayer(player);
    action = new RPAction();
    action.put("type", "jail");
    action.put("target", "hugo");
    action.put("reason", "whynot");
    action.put("minutes", "noNumber");

    CommandCenter.execute(player, action);
    assertEquals("Usage: /jail <name> <minutes> <reason>", player.events().get(0).get("text"));
    player.clearEvents();

   
    action = new RPAction();
    action.put("type", "jail");
    action.put("target", "hugo");
    action.put("reason", "whynot");
    action.put("minutes", 1);

    assertTrue(CommandCenter.execute(player, action));
    assertThat(player.events().get(0).get("text"), startsWith("You have been jailed for 1 minutes. Reason: whynot."));
  }
View Full Code Here

  /**
   * Tests for avoidNFE.
   */
  @Test
  public final void testAvoidNFE() {
    final Player pl = PlayerTestHelper.createPlayer("hugo");

    MockStendhalRPRuleProcessor.get().addPlayer(pl);

    zone.add(pl);
    pl.setPosition(1, 1);
    pl.put("adminlevel", 5000);
    final RPAction action = new RPAction();
    action.put("type", "summon");
    action.put("creature", "unknown");
    action.put("x", "bag");
    action.put("y", "perch");
    CommandCenter.execute(pl, action);
    assertEquals(1, pl.getID().getObjectID());
    assertNull(zone.getEntityAt(0, 0));
  }
View Full Code Here

  /**
   * Tests for gag.
   */
  @Test
  public final void testGag() {
    final Player pl = PlayerTestHelper.createPlayer("hugo");
    pl.setAdminLevel(5000);
    RPAction action = new RPAction();
    action.put("type", "gag");

    CommandCenter.execute(pl, action);

    assertEquals("Usage: /gag name minutes reason", pl.events().get(0).get("text"));
    pl.clearEvents();
    action = new RPAction();
    action.put("type", "gag");
    action.put("target", "name");
    action.put("reason", "whynot");
    action.put("minutes", 1);

    CommandCenter.execute(pl, action);
    assertEquals("Player name not found", pl.events().get(0).get("text"));

    pl.clearEvents();

    MockStendhalRPRuleProcessor.get().addPlayer(pl);
    action = new RPAction();
    action.put("type", "gag");
    action.put("target", "hugo");
    action.put("reason", "whynot");
    action.put("minutes", "noNumber");

    CommandCenter.execute(pl, action);
    assertEquals("Usage: /gag name minutes reason", pl.events().get(0).get("text"));
    pl.clearEvents();

    action = new RPAction();
    action.put("type", "gag");
    action.put("target", "hugo");
    action.put("reason", "whynot");
    action.put("minutes", 1);

    CommandCenter.execute(pl, action);
    assertTrue(pl.events().get(0).get("text").startsWith(
        "You have gagged hugo for 1 minutes. Reason: "));
  }
View Full Code Here

   * Tests for isValidNonContained.
   */
  @Test
  public void testIsValidNonContained() {
    MockStendlRPWorld.get();
    final Player bob = PlayerTestHelper.createPlayer("bob");
    final StendhalRPZone zone = new StendhalRPZone("dropzone");
    final Item dropitem = ItemTestHelper.createItem();
    zone.add(dropitem);
    zone.add(bob);
    assertNotNull(dropitem.getID().getObjectID());
    final RPAction action = new RPAction();
    action.put(EquipActionConsts.BASE_ITEM, dropitem.getID().getObjectID());
    MockStendlRPWorld.get().addRPZone(zone);
    assertNotNull(bob.getZone());

    final SourceObject so = SourceObject.createSourceObject(action, bob);
    assertTrue(so.isValid());
  }
View Full Code Here

   * Tests for isValidContainedNoSlot.
   */
  @Test
  public void testIsValidContainedNoSlot() {
    MockStendlRPWorld.get();
    final Player bob = PlayerTestHelper.createPlayer("bob");
    final StendhalRPZone zone = new StendhalRPZone("dropzone");
    final Item dropitem = SingletonRepository.getEntityManager().getItem("money");
    assertNotNull(dropitem);
    zone.add(bob);
    assertTrue(bob.equipToInventoryOnly(dropitem));
    assertNotNull(dropitem.getID().getObjectID());
    final RPAction action = new RPAction();
    action.put(EquipActionConsts.BASE_ITEM, dropitem.getID().getObjectID());

    action.put(EquipActionConsts.BASE_OBJECT , bob.getID().getObjectID());

    MockStendlRPWorld.get().addRPZone(zone);
    assertNotNull(bob.getZone());

    final SourceObject so = SourceObject.createSourceObject(action, bob);
    assertFalse("no slot defined", so.isValid());
  }
View Full Code Here

   * Tests for isValidContained.
   */
  @Test
  public void testIsValidContained() {
    MockStendlRPWorld.get();
    final Player bob = PlayerTestHelper.createPlayer("bob");
    final StendhalRPZone zone = new StendhalRPZone("dropzone");
    final Item dropitem = SingletonRepository.getEntityManager().getItem("money");
    assertNotNull(dropitem);
    zone.add(bob);
    assertTrue(bob.equipToInventoryOnly(dropitem));
    assertNotNull(dropitem.getID().getObjectID());
    final RPAction action = new RPAction();
    action.put(EquipActionConsts.BASE_ITEM, dropitem.getID().getObjectID());

    action.put(EquipActionConsts.BASE_OBJECT , bob.getID().getObjectID());
    action.put(EquipActionConsts.BASE_SLOT, "bag");
    MockStendlRPWorld.get().addRPZone(zone);
    assertNotNull(bob.getZone());

    final SourceObject so = SourceObject.createSourceObject(action, bob);
    assertTrue("Unreachable slot", so.isValid());
  }
View Full Code Here

  /**
   * Tests for onDestroyEntityNotFOund.
   */
  @Test
  public final void testOnDestroyEntityNotFOund() {
    final Player pl = PlayerTestHelper.createPlayer("hugo");
    pl.setAdminLevel(5000);
    final RPAction action = new RPAction();
    action.put("type", "destroy");

    CommandCenter.execute(pl, action);
    assertEquals("Entity not found", 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.