Examples of RPAction


Examples of marauroa.common.game.RPAction

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

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

Examples of marauroa.common.game.RPAction

  @Test
  public final void testWrongSpell() {
    final Player pl = PlayerTestHelper.createPlayer("player");
    pl.setQuest("spells", "spell1;spell2");

    final RPAction action = new RPAction();
    action.put("type", "spell");
    action.put("target", "spellX");
    assertTrue(CommandCenter.execute(pl, action));
    assertEquals(2, pl.events().size());
    int idx = 0;
    assertEquals("Trying to cast a spell...", pl.events().get(idx++).get("text"));
    assertEquals("You can not cast this spell.", pl.events().get(idx++).get("text"));
View Full Code Here

Examples of marauroa.common.game.RPAction

    MockStendlRPWorld.get().addRPZone(zoneaway);
    MockStendhalRPRuleProcessor.get().addPlayer(playerAway);
   
    assertNotNull(SingletonRepository.getRuleProcessor().getPlayer("bobaway"));
    AlterAction action = new AlterAction();
    RPAction rpAction = new RPAction();
    rpAction.put("target", "bobaway");
    rpAction.put("mode", "");
    rpAction.put("stat", "hp");
    rpAction.put("value", "50");
    assertEquals(100, playerAway.getHP());
    action.perform(player, rpAction);
    assertEquals("reset to base", 10, playerAway.getHP());
   
    playerAway.setHP(100);
    rpAction.put("value", "-10");
    assertEquals(100, playerAway.getHP());
    action.perform(player, rpAction);
    assertEquals(100, playerAway.getHP());
   
    rpAction.put("value", "5");
    assertEquals(100, playerAway.getHP());
    action.perform(player , rpAction);
    assertEquals(5, playerAway.getHP());
  }
View Full Code Here

Examples of marauroa.common.game.RPAction

  @Test
  public final void testUnhandledSpell() {
    final Player pl = PlayerTestHelper.createPlayer("player");
    pl.setQuest("spells", "spell1;spell2");

    final RPAction action = new RPAction();
    action.put("type", "spell");
    action.put("target", "spell1");
    assertTrue(CommandCenter.execute(pl, action));
    assertEquals(2, pl.events().size());
    int idx = 0;
    assertEquals("Trying to cast a spell...", pl.events().get(idx++).get("text"));
    assertEquals("The spell you tried to cast doesn't exist!", pl.events().get(idx++).get("text"));
View Full Code Here

Examples of marauroa.common.game.RPAction

  public final void testHealSpell() {
    final Player pl = PlayerTestHelper.createPlayer("player");
    pl.setQuest("spells", "heal");
    pl.setHP(35); // decrease heal points

    RPAction action = new RPAction();
    action.put("type", "spell");
    action.put("target", "heal");
    assertTrue(CommandCenter.execute(pl, action));
    assertEquals(2, pl.events().size());
    int idx = 0;
    assertEquals("Trying to cast a spell...", pl.events().get(idx++).get("text"));
    assertEquals("You do not have enough available mana to use this spell.", pl.events().get(idx++).get("text"));
    pl.clearEvents();
    assertEquals(35, pl.getHP());

    // increase Mana value to enable the player casting the raise stats spell
    pl.setMana(20);
    action = new RPAction();
    action.put("type", "spell");
    action.put("target", "heal");
    assertTrue(CommandCenter.execute(pl, action));
    assertEquals(2, pl.events().size());
    idx = 0;
    assertEquals("Trying to cast a spell...", pl.events().get(idx++).get("text"));
    assertEquals("You have been healed.", pl.events().get(idx++).get("text"));
View Full Code Here

Examples of marauroa.common.game.RPAction

  @Test
  public void testEntityFromSlot() {
    StendhalRPZone zone = new StendhalRPZone(TEST_ENTITY_HELPER);
    Player player = PlayerTestHelper.createPlayer("helpertester");
    player.setID(new RPObject.ID(2, zone.getID()));
    RPAction action = new RPAction();
    assertNull(EntityHelper.entityFromSlot(player, action));
    Entity rpo1 = new Entity() {};
    rpo1.setID(new RPObject.ID(1, TEST_ENTITY_HELPER));
    zone.add(rpo1);
    assertNull(EntityHelper.entityFromSlot(player, action));
    zone.add(player);
    player.getSlot("bag").add(rpo1);
    action.put(BASESLOT, "bag");
    action.put(BASEOBJECT, player.getID().getObjectID());
    action.put(BASEITEM, 1);
    assertThat(EntityHelper.entityFromSlot(player, action), is(rpo1));
  }
View Full Code Here

Examples of marauroa.common.game.RPAction

   * Tests for hasNeededAttributes.
   */
  @Test
  public final void testHasNeededAttributes() {
    AlterAction action = new AlterAction();
    RPAction rpAction = new RPAction();
    assertFalse(action.hasNeededAttributes(rpAction));
    rpAction.put("target", "");
    assertFalse(action.hasNeededAttributes(rpAction));
    rpAction.put("mode", "");
    assertFalse(action.hasNeededAttributes(rpAction));
    rpAction.put("stat", "");
    assertFalse(action.hasNeededAttributes(rpAction));
    rpAction.put("value", "");
    assertTrue(action.hasNeededAttributes(rpAction));
  }
View Full Code Here

Examples of marauroa.common.game.RPAction

    pl.setLevel(16);
    pl.setDef(23);
    pl.setAtkXP(20);
    pl.setAtk(10);

    RPAction action = new RPAction();
    action.put("type", "spell");
    action.put("target", "raise stats");
    assertTrue(CommandCenter.execute(pl, action));
    List<String> replies = getAllPrivateReplies(pl);
    assertEquals(2, replies.size());
    assertEquals("Trying to cast a spell...", replies.get(0));
    assertEquals("You do not have enough mana to cast this spell.", replies.get(1));
    assertEquals(50, pl.getXP());
    assertEquals(16, pl.getLevel());
    assertEquals(23, pl.getDef());
    assertEquals(20, pl.getAtkXP());
    assertEquals(10, pl.getAtk());

    // increase Mana value to enable the player casting the raise stats spell
    pl.setMana(120);
    action = new RPAction();
    action.put("type", "spell");
    action.put("target", "raise stats");
    assertTrue(CommandCenter.execute(pl, action));
    replies = getAllPrivateReplies(pl);
    assertEquals(2, replies.size());
    assertEquals("Trying to cast a spell...", replies.get(0));
    assertEquals("Your stats have been raised.", replies.get(1));
View Full Code Here

Examples of marauroa.common.game.RPAction

   */
  @Test
  public void testDropInvalidSourceSlot() {
    final Player player = createTestPlayer("george");

    final RPAction drop = new RPAction();
    drop.put("type", "drop");
    drop.put("baseobject", player.getID().getObjectID());
    drop.put("baseslot", "nonExistingSlotXXXXXX");
    drop.put("baseitem", -1);

    final EquipmentAction action = new DropAction();
    action.onAction(player, drop);
    Assert.assertEquals("Source nonExistingSlotXXXXXX does not exist", player.events().get(0).get("text"));
  }
View Full Code Here

Examples of marauroa.common.game.RPAction

   */
  @Test
  public void testDropNonExistingItem() {
    final Player player = createTestPlayer("bob");

    final RPAction drop = new RPAction();
    drop.put("type", "drop");
    drop.put("baseobject", player.getID().getObjectID());
    drop.put("baseslot", "bag");
    drop.put("x", player.getX());
    drop.put("y", player.getY() + 1);
    drop.put("quantity", "1");
    drop.put("baseitem", -1);

    final EquipmentAction action = new DropAction();
    action.onAction(player, drop);
    // Assert.assertEquals("There is no such item in the bag of bob", player.events().get(0).get("text"));
  }
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.