Beispiel #1
0
 /** Displays the next user prompt and abandons the conversation if the next prompt is null. */
 public void outputNextPrompt() {
   if (currentPrompt == null) {
     abandon(new ConversationAbandonedEvent(this));
   } else {
     context
         .getForWhom()
         .sendRawMessage(prefix.getPrefix(context) + currentPrompt.getPromptText(context));
     if (!currentPrompt.blocksForInput(context)) {
       currentPrompt = currentPrompt.acceptInput(context, null);
       outputNextPrompt();
     }
   }
 }
Beispiel #2
0
  /**
   * Passes player input into the current prompt. The next prompt (as determined by the current
   * prompt) is then displayed to the user.
   *
   * @param input The user's chat text.
   */
  public void acceptInput(String input) {
    if (currentPrompt != null) {

      // Echo the user's input
      if (localEchoEnabled) {
        context.getForWhom().sendRawMessage(prefix.getPrefix(context) + input);
      }

      // Test for conversation abandonment based on input
      for (ConversationCanceller canceller : cancellers) {
        if (canceller.cancelBasedOnInput(context, input)) {
          abandon(new ConversationAbandonedEvent(this, canceller));
          return;
        }
      }

      // Not abandoned, output the next prompt
      currentPrompt = currentPrompt.acceptInput(context, input);
      outputNextPrompt();
    }
  }