Pre-release
Adventure.js Docs Downloads
Score: 0 Moves: 0
// verbs.js
// OK 09 2023
(function () {
  /*global adventurejs A*/
  "use strict";

  /**
   * @augments {adventurejs.Verb}
   * @class verbs
   * @ajsconstruct MyGame.createVerb({ "name": "verbs", [...] });
   * @ajsconstructedby adventurejs.Dictionary#createVerb
   * @hideconstructor
   * @ajsinstanceof Verb
   * @ajsnavheading UtilityVerbs
   * @ajsnode game.dictionary.verbs.verbs
   * @summary Verb that returns a list of all available verbs.
   * @tutorial Scripting_VerbSubscriptions
   * @tutorial Verbs_VerbAnatomy
   * @tutorial Verbs_VerbProcess
   * @tutorial Verbs_ModifyVerbs
   * @tutorial Verbs_WriteVerbs
   * @classdesc
   * <pre class="display border outline">
   * <span class="input">&gt; verbs</span>
   * - aft
   * - again
   * - ask about
   * - etc.
   * </pre>
   * <p>
   * Verbs returns a list of all active verbs.
   * </p>
   */
  A.Preverbs.verbs = {
    name: "verbs",
    synonyms: ["verbs"],

    /**
     * @ajsverbstructures
     * @memberof verbs
     */
    accepts_structures: ["verb"],

    do: function () {
      var input = this.game.getInput();
      var verbList = "Available verbs: ";
      var count = 0;
      for (var prop in this.dictionary.verbs) {
        if (count > 0) verbList += ", ";
        verbList += this.dictionary.verbs[prop].prettyname;
        count++;
      }
      verbList += ". ";
      this.game.print(verbList, input.output_class);
      return true;
    },
  };
})();