Package games.stendhal.server.entity.player

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


   */
  @Test
  public final void testOnAlterActionHP() {
    final AdministrationAction aa = new AlterAction();

    final Player pl = PlayerTestHelper.createPlayer("bob");
    pl.setAdminLevel(5000);
    pl.setBaseHP(100);
    pl.setHP(100);
    MockStendhalRPRuleProcessor.get().addPlayer(pl);

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

    aa.onAction(pl, action);
    assertEquals("may not change HP to 0 ", 100, pl.getHP());

    action.put("value", 120);
    aa.onAction(pl, action);
    assertEquals("may  not change HP over base_hp", 100, pl.getHP());

    action.put("value", 90);
    aa.onAction(pl, action);
    assertEquals("may  change HP to 90 ", 90, pl.getHP());

    action.put("value", 90);
    action.put("mode", "sub");
    assertEquals("may  change HP to 90 ", 90, pl.getHP());
  }
View Full Code Here


  /**
   * Tests for onAlterActionHPsub.
   */
  @Test
  public final void testOnAlterActionHPsub() {
    final Player pl = PlayerTestHelper.createPlayer("bob");
    pl.setAdminLevel(5000);
    pl.setBaseHP(100);
    pl.setHP(100);
    MockStendhalRPRuleProcessor.get().addPlayer(pl);

    final RPAction action = new RPAction();
    action.put("type", "alter");
    action.put("target", "bob");
    action.put("stat", "hp");
    action.put("mode", "sub");
    action.put("value", 90);
    assertEquals(100, pl.getHP());

    CommandCenter.execute(pl, action);
    assertEquals(10, pl.getHP());
    CommandCenter.execute(pl, action);
    assertEquals(10, pl.getHP());
  }
View Full Code Here

   * Tests for onAlterActionHPadd.
   */
  @Test
  public final void testOnAlterActionHPadd() {

    final Player pl = PlayerTestHelper.createPlayer("bob");
    pl.setAdminLevel(5000);
    pl.setBaseHP(100);
    pl.setHP(10);
    MockStendhalRPRuleProcessor.get().addPlayer(pl);

    final RPAction action = new RPAction();
    action.put("type", "alter");
    action.put("target", "bob");
    action.put("stat", "hp");
    action.put("mode", "add");
    action.put("value", 80);
    assertEquals(10, pl.getHP());

    CommandCenter.execute(pl, action);
    assertEquals(90, pl.getHP());
    CommandCenter.execute(pl, action);
    assertEquals("set to max base_hp", 100, pl.getHP());
  }
View Full Code Here

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

    MockStendhalRPRuleProcessor.get().addPlayer(pl);

    pl.setAdminLevel(5000);
    final RPAction action = new RPAction();
    action.put("type", "altercreature");
    action.put("target", "bob");
    action.put("text", "blabla");

    CommandCenter.execute(pl, action);
    assertEquals("Entity not found", pl.events().get(0).get("text"));
  }
View Full Code Here

   * Tests for summonAlterCreature.
   */
  @Test
  public final void testSummonAlterCreature() {

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

    MockStendhalRPRuleProcessor.get().addPlayer(pl);
    final StendhalRPZone zone = new StendhalRPZone("testzone") {
      @Override
      public synchronized boolean collides(final Entity entity, final double x,
          final double y) {

        return false;
      }
    };
    zone.add(pl);
    pl.setPosition(1, 1);
    pl.setAdminLevel(5000);
    RPAction action = new RPAction();
    action.put("type", "summon");
    action.put("creature", "rat");
    action.put("x", 0);
    action.put("y", 0);
    CommandCenter.execute(pl, action);
    assertEquals(1, pl.getID().getObjectID());
    final Creature rat = (Creature) zone.getEntityAt(0, 0);
    assertEquals("rat", rat.get("subclass"));

    action = new RPAction();
    action.put("type", "altercreature");
View Full Code Here

  @Test
  public void testOnAction() {
    final FaceAction fa = new FaceAction();
    final RPAction action = new RPAction();
    PlayerTestHelper.generatePlayerRPClasses();
    final Player player = new Player(new RPObject()) {
      @Override
      public void stop() {
        stopCalled = true;
      }
View Full Code Here

  /**
   * Tests for invisible.
   */
  @Test
  public final void testInvisible() {
    final Player pl = PlayerTestHelper.createPlayer("hugo");
    pl.setAdminLevel(5000);
    final RPAction action = new RPAction();
    action.put("type", "invisible");
    assertFalse(pl.isInvisibleToCreatures());
    CommandCenter.execute(pl, action);
    assertTrue(pl.isInvisibleToCreatures());
    CommandCenter.execute(pl, action);
    assertFalse(pl.isInvisibleToCreatures());
  }
View Full Code Here

  @Before
  public final void setup() {
    final StendhalRPZone zone = new StendhalRPZone(ZONE_NAME);
    MockStendlRPWorld.get().addRPZone(zone);

    final Player pl1 = PlayerTestHelper.createPlayer("player1");
    PlayerTestHelper.registerPlayer(pl1, zone);

    final Player pl2 = PlayerTestHelper.createPlayer("player2");
    PlayerTestHelper.registerPlayer(pl2, zone);
  }
View Full Code Here

  @Test
  public final void testMagic() {
    final StendhalRPWorld world = MockStendlRPWorld.get();
    final StendhalRPZone zone = world.getZone(ZONE_NAME);

    final Player admin = PlayerTestHelper.createPlayer("admin");
    admin.setAdminLevel(400);
    PlayerTestHelper.registerPlayer(admin, zone);

    RPAction action = new RPAction();
    action.put("type", "marry");
    assertTrue(CommandCenter.execute(admin, action));
    assertEquals("Usage: #/marry #<player1> #<player2>",
        admin.events().get(0).get("text"));
    admin.clearEvents();

    action = new RPAction();
    action.put("type", "marry");
    action.put("target", "player1");
    action.put("args", "player2");
    assertTrue(CommandCenter.execute(admin, action));
    assertEquals(
        "You have successfully married \"player1\" and \"player2\".",
        admin.events().get(0).get("text"));
    admin.clearEvents();

    assertTrue(CommandCenter.execute(admin, action));
    assertEquals(
        "player1 is already married to player2. player2 is already married to player1.",
        admin.events().get(0).get("text"));
    admin.clearEvents();
  }
View Full Code Here

  /**
   * Tests for summonRat.
   */
  @Test
  public final void testSummonRat() {
    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", "rat");
    action.put("x", 0);
    action.put("y", 0);
    CommandCenter.execute(pl, action);
    assertEquals(1, pl.getID().getObjectID());
    final Creature rat = (Creature) zone.getEntityAt(0, 0);
    assertEquals("rat", rat.get("subclass"));
    assertTrue("RaidCreature", rat instanceof RaidCreature);
  }
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.