Examples of ItemParserResult


Examples of games.stendhal.common.grammar.ItemParserResult

 
  @Override
  public ChatCondition getTransactionCondition() {
    return new ChatCondition() {
      public boolean fire(Player player, Sentence sentence, Entity npc) {
        ItemParserResult res = parse(sentence);
        return canDealWith(res.getChosenItemName());
      }
    };
  }
View Full Code Here

Examples of games.stendhal.common.grammar.ItemParserResult

          @Override
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
            if (sentence.hasError()) {
              fireSentenceError(player, sentence, npc);
            } else {
              ItemParserResult res = behaviour.parse(sentence);

              // don't use res.wasFound() and avoid to call fireRequestError()
              fireRequestOK(res, player, sentence, npc);
            }
          }

          @Override
          public void fireRequestOK(final ItemParserResult res, Player player, Sentence sentence, EventRaiser npc) {
            stake = res.getAmount();

            if (stake < MIN_STAKE) {
              npc.say("You must stake at least " + MIN_STAKE + " pieces of gold.");
            } else if (stake > MAX_STAKE) {
              npc.say("You can't stake more than " + MAX_STAKE + " pieces of gold.");
View Full Code Here

Examples of games.stendhal.common.grammar.ItemParserResult

        null,
        false,
        ConversationStates.HEAL_OFFERED,
            null, new ChatAction() {
              public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
                currentBehavRes = new ItemParserResult(true, "heal", 1, null);
                        String badboymsg = "";
                int cost = healerBehaviour.getCharge(currentBehavRes, player);
                if (player.isBadBoy()) {
                  cost = cost * 2;
                  badboymsg = " Its more for nasty ones.";
View Full Code Here

Examples of games.stendhal.common.grammar.ItemParserResult

    engine.add(ConversationStates.ATTENDING, "heal", null,
        false, ConversationStates.ATTENDING,
        null, new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
            ItemParserResult res = new ItemParserResult(true, "heal", 1, null);

            int cost = healerBehaviour.getCharge(res, player);
            currentBehavRes = res;
           
            String badboymsg = "";
View Full Code Here

Examples of games.stendhal.common.grammar.ItemParserResult

  /**
   * Tests for setAmount.
   */
  @Test
  public void testSetAmount() {
    ItemParserResult beh = new ItemParserResult(true, "X", 1, null);
    beh.setAmount(0);
    assertEquals(1, beh.getAmount());
    beh.setAmount(1001);
    assertEquals(1, beh.getAmount());
    beh.setAmount(1000);
    assertEquals(1000, beh.getAmount());
    beh.setAmount(2);
    assertEquals(2, beh.getAmount());
  }
View Full Code Here

Examples of games.stendhal.common.grammar.ItemParserResult

    assertFalse(sentence.hasError());

    Set<String> items = new HashSet<String>();
    items.add("gold");
    Behaviour beh = new Behaviour(items);
    ItemParserResult res = beh.parse(sentence);
    assertTrue(res.wasFound()); // only gold, silver -> unambiguous
    assertEquals(50, res.getAmount());
    assertEquals("gold", res.getChosenItemName());

    items.add("silver");
    beh = new Behaviour(items);
    res = beh.parse(sentence);
    assertFalse(res.wasFound()); // gold, silver -> ambiguous
    assertEquals(50, res.getAmount());
  }
View Full Code Here

Examples of games.stendhal.common.grammar.ItemParserResult

    pricelist.put("lilia seed", 10);
    pricelist.put("daisies seed", 20);
    final SpeakerNPC speakerNPC = new SpeakerNPC("hugo");

    sb = new SeedSellerBehaviour(pricelist);
    ItemParserResult res = new ItemParserResult(true, "lilia seed",1, null);
    final Player bob = PlayerTestHelper.createPlayer("bob");
    PlayerTestHelper.equipWithMoney(bob, 100);
    sb.transactAgreedDeal(res, new EventRaiser(speakerNPC), bob);
    final Item seed = bob.getFirstEquipped("seed");
    assertNotNull(seed);
View Full Code Here

Examples of games.stendhal.common.grammar.ItemParserResult

  public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
    if (sentence.hasError()) {
      fireSentenceError(player, sentence, npc);
    } else {
      ItemParserResult res = behaviour.parse(sentence);

      if (res.wasFound()) {
        fireRequestOK(res, player, sentence, npc);
      } else {
        fireRequestError(res, player, sentence, npc);
      }
    }
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.