Package games.stendhal.common.parser

Examples of games.stendhal.common.parser.Expression


      }
      npc.say("You may not place more than " + TradingUtility.MAX_NUMBER_OFF_OFFERS + " offers.");
    }

    private int determineNumber(Sentence sentence) {
      Expression expression = sentence.getExpression(1,"");
      return expression.getAmount();
    }
View Full Code Here


      Expression expression = sentence.getExpression(1,"");
      return expression.getAmount();
    }

    private String determineItemName(Sentence sentence) {
      Expression expression = sentence.getExpression(1,"");
      return expression.getNormalized();
    }
View Full Code Here

  @Test
  public final void testJokerMatching() {
    final ExpressionMatcher matcher = new JokerExprMatcher();

    final Expression e1 = new Expression("abc", "VER");
    final Expression e2 = new Expression("a*c", "VER");
    final Expression e3 = new Expression("ab", "VER");
    final Expression e4 = new Expression("ab*", "SUB");
    final Expression e5 = new Expression("X", "SUB");

    assertTrue(matcher.match(e1, e2));
    assertFalse(matcher.match(e1, e3));
    assertTrue(matcher.match(e1, e4));
    assertFalse(matcher.match(e1, e5));
View Full Code Here

  /**
   * Tests for withoutParser.
   */
  @Test
  public final void testWithoutParser() {
    final Expression expr = new Expression("hello", "VER");
    final Sentence sentence = new SentenceImplementation(expr);

    assertTrue(sentence.matchesFull(sentence));
  }
View Full Code Here

        null,
        ConversationStates.QUEST_2_OFFERED,
        null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
            Expression obj = sentence.getObject(0);
            if (obj!=null && !obj.getNormalized().equals(itemName)) {
              raiser.say("I don't know " + obj.getOriginal() + ". Can you name me another cloak please?");
            } else {
              final Item item = SingletonRepository.getEntityManager().getItem(itemName);
              StringBuilder stringBuilder = new StringBuilder();
              stringBuilder.append("You haven't seen one before? Well, it's a ");
View Full Code Here

      String errorMsg = null;

      if (sentence.hasError()) {
        errorMsg = sentence.getErrorString();
      } else {
        final Expression object1 = sentence.getObject(0);
        final Expression preposition = sentence.getPreposition(0);
        final Expression object2 = sentence.getObject(1);

        if ((object1 != null) && (object2 != null) && (preposition != null)) {
            if (preposition.getNormalized().equals("on")) {
                betInfo.amount = object1.getAmount();
               
                // cheese
                betInfo.itemName = object1.getNormalized();
                betInfo.target = object2.getNormalized();
            } else {
              errorMsg = "missing preposition 'on'";
            }
          } else {
            errorMsg = "missing bet parameters";
View Full Code Here

TOP

Related Classes of games.stendhal.common.parser.Expression

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.