Examples of RPAction


Examples of marauroa.common.game.RPAction

   */
  @Test
  public void testEncoderDecoderMultipleMessageInARead() throws IOException, InvalidVersionException {
    Encoder enc = Encoder.get();

    RPAction action = new RPAction();
    action.put("one", 1);
    action.put("two", "2");

    MessageC2SAction message = new MessageC2SAction(null, action);

    byte[] result1 = enc.encode(message);

    action = new RPAction();
    action.put("three", 31);
    action.put("four", "4");

    message = new MessageC2SAction(null, action);

    byte[] result2 = enc.encode(message);
   
View Full Code Here

Examples of marauroa.common.game.RPAction

    final ActionListener listener = new ActionListener() {
      public void onAction(final Player player, final RPAction action) {
        player.put("success", "true");
      }
    };
    final RPAction action = new RPAction();
    action.put("type", "action");
    final Player caster = PlayerTestHelper.createPlayer("player");
    CommandCenter.register("action", listener);
    assertFalse(caster.has("success"));
    CommandCenter.execute(caster, action);
    assertTrue(caster.has("success"));
View Full Code Here

Examples of marauroa.common.game.RPAction

  /**
   * Tests for executeUnknown.
   */
  @Test
  public void testExecuteUnknown() {
    final RPAction action = new RPAction();

    action.put("type", "");
    final Player caster = PlayerTestHelper.createPlayer("bob");
    CommandCenter.execute(caster, action);
    assertEquals("Unknown command . Please type /help to get a list.", caster.events().get(0).get("text"));
  }
View Full Code Here

Examples of marauroa.common.game.RPAction

  public final void testAdminlevelAttribute() {
    Player player = PlayerTestHelper.createPlayer("bob");
    StendhalRPZone zone = new StendhalRPZone("testzone");
    zone.add(player);
    AlterAction action = new AlterAction();
    RPAction rpAction = new RPAction();
    rpAction.put("target", "#" + player.getID().getObjectID());
    rpAction.put("mode", "");
    rpAction.put("stat", "adminlevel");
    rpAction.put("value", "");
    assertTrue(player.events().isEmpty());
    action.perform(player, rpAction);
    assertFalse(player.events().isEmpty());
    assertEquals("Use #/adminlevel #<playername> #[<newlevel>] to display or change adminlevel.", player.events().get(0).get("text"));
  }
View Full Code Here

Examples of marauroa.common.game.RPAction

  public final void testTitleAttribute() {
    Player player = PlayerTestHelper.createPlayer("bob");
    StendhalRPZone zone = new StendhalRPZone("testzone");
    zone.add(player);
    AlterAction action = new AlterAction();
    RPAction rpAction = new RPAction();
    rpAction.put("target", "#" + player.getID().getObjectID());
    rpAction.put("mode", "");
    rpAction.put("stat", "title");
    rpAction.put("value", "");
    assertTrue(player.events().isEmpty());
    action.perform(player, rpAction);
    assertFalse(player.events().isEmpty());
    assertEquals("The title attribute may not be changed directly.", player.events().get(0).get("text"));
  }
View Full Code Here

Examples of marauroa.common.game.RPAction

  public final void testValidAttributeInvalidNumber() {
    Player player = PlayerTestHelper.createPlayer("bob");
    StendhalRPZone zone = new StendhalRPZone("testzone");
    zone.add(player);
    AlterAction action = new AlterAction();
    RPAction rpAction = new RPAction();
    rpAction.put("target", "#" + player.getID().getObjectID());
    rpAction.put("mode", "");
    rpAction.put("stat", "hp");
    rpAction.put("value", "");
    assertTrue(player.events().isEmpty());
    action.perform(player, rpAction);
    assertFalse(player.events().isEmpty());
    assertEquals("Please issue a numeric value instead of ''", player.events().get(0).get("text"));
  }
View Full Code Here

Examples of marauroa.common.game.RPAction

    Player player = PlayerTestHelper.createPlayer("bob");
    player.put("base_hp", 100);
    StendhalRPZone zone = new StendhalRPZone("testzone");
    zone.add(player);
    AlterAction action = new AlterAction();
    RPAction rpAction = new RPAction();
    rpAction.put("target", "#" + player.getID().getObjectID());
    rpAction.put("mode", "");
    rpAction.put("stat", "hp");
    rpAction.put("value", "50");
    assertEquals(100, player.getHP());
    action.perform(player, rpAction);
    assertEquals(50, player.getHP());
   
   
    player.setHP(100);
    rpAction.put("value", "-10");
    assertEquals(100, player.getHP());
    action.perform(player, rpAction);
    assertEquals(100, player.getHP());
   
    rpAction.put("value", "5");
    assertEquals(100, player.getHP());
    action.perform(player , rpAction);
    assertEquals(5, player.getHP());
  }
View Full Code Here

Examples of marauroa.common.game.RPAction

   */
  @Test
  public final void testNoSpell() {
    final Player pl = PlayerTestHelper.createPlayer("player");

    RPAction action = new RPAction();
    action.put("type", "spell");
    // no target
    assertTrue(CommandCenter.execute(pl, action));
    assertEquals(1, pl.events().size());
    assertEquals("Usage: #/spell <spellname>", pl.events().get(0).get("text"));
    pl.clearEvents();

    action = new RPAction();
    action.put("type", "spell");
    action.put("target", "");
    assertTrue(CommandCenter.execute(pl, action));
    assertEquals(1, pl.events().size());
    assertEquals("You did not enter a spell to cast.", pl.events().get(0).get("text"));
    pl.clearEvents();
  }
View Full Code Here

Examples of marauroa.common.game.RPAction

   */
  @Test
  public final void testWrongAction() {
    final Player pl = PlayerTestHelper.createPlayer("player");

    RPAction action = new RPAction();
    action.put("type", "anotheraction");
    action.put("target", "spell");
    new MagicExtn().onAction(pl, action);
    assertEquals(0, pl.events().size());
  }
View Full Code Here

Examples of marauroa.common.game.RPAction

    MockStendlRPWorld.get().addRPZone(zone);
    MockStendhalRPRuleProcessor.get().addPlayer(player);
    zone.add(player);
    assertNotNull(SingletonRepository.getRuleProcessor().getPlayer("bob"));
    AlterAction action = new AlterAction();
    RPAction rpAction = new RPAction();
    rpAction.put("target", "bob");
    rpAction.put("mode", "");
    rpAction.put("stat", "hp");
    rpAction.put("value", "50");
    assertEquals(100, player.getHP());
    action.perform(player, rpAction);
    assertEquals("reset to base", 10, player.getHP());
   
    player.setHP(100);
    rpAction.put("value", "-10");
    assertEquals(100, player.getHP());
    action.perform(player, rpAction);
    assertEquals(100, player.getHP());
   
    rpAction.put("value", "5");
    assertEquals(100, player.getHP());
    action.perform(player , rpAction);
    assertEquals(5, player.getHP());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.