Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0
// taste.js

(function () {
  /* global adventurejs A */

  /**
   * @augments {adventurejs.Verb}
   * @class taste
   * @ajsnode game.dictionary.verbs.taste
   * @ajsconstruct MyGame.createVerb({ "name": "taste", [...] });
   * @ajsconstructedby adventurejs.Dictionary#createVerb
   * @hideconstructor
   * @ajsinstanceof Verb
   * @ajsnavheading SensationVerbs
   * @summary Verb meaning taste, as in "taste toad venom".
   * @tutorial Verbs_Subscriptions
   * @tutorial AdvancedVerbs_VerbAnatomy
   * @tutorial AdvancedVerbs_VerbProcess
   * @tutorial AdvancedVerbs_ModifyVerbs
   * @tutorial AdvancedVerbs_ModifyVerbs
   * @classdesc
   * <pre class="display border outline">
   * <span class="ajs-player-input">&gt; taste fruit</span>
   * You taste the forbidden fruit. Did you think that only tasting it and not eating it would protect you from the curse of knowledge? Well, forget it, buddy. Now you know. NOW. YOU. KNOW. Now get outta my garden!
   * </pre>
   * <p>
   * <strong>Taste</strong> requires that the
   * {@link adventurejs.Tangible|Tangible}
   * {@link adventurejs.Asset|Asset} to be tasted has
   * asset.dov.taste.enabled
   * set to true. By default, no special results will occur.
   * Authors wanting to make use of it may need to use a method such
   * as verb hooks. See
   * <a href="/doc/Verbs_PhaseHooks.html">Verb Phases</a>
   * to learn more.
   * </p>
   * <p>
   * Taste and {@link lick|lick} behave identically if they're
   * not given any special reactions.
   * </p>
   * @ajsverbreactions
   * @ajsverbphases doBeforeTry, doAfterTry, doBeforeSuccess, doAfterSuccess
   */
  A.Preverbs.taste = {
    name: "taste",
    prettyname: "taste",
    past_tense: "tasted",
    synonyms: ["taste"],
    gerund: "tasting",

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

    /**
     * @memberof taste
     * @ajsverbphrase
     * phrase1:
     * {
     *   accepts_noun:true,
     *   requires_noun: true,
     *   noun_must_be:
     *   {
     *     known: true,
     *     tangible: true,
     *     present: true,
     *     visible: true,
     *     reachable: true,
     *   },
     * },
     */
    phrase1: {
      accepts_noun: true,
      requires_noun: true,
      noun_must_be: {
        known: true,
        tangible: true,
        present: true,
        visible: true,
        reachable: true,
      },
    },

    /**
     * @memberof taste
     * @ajsverbparams
     * with_params: {},
     */
    with_params: {},

    doTry: function () {
      var input = this.game.getInput();
      var direct_object = input.getAsset(1);
      var msg = "";

      if (!direct_object.isDOV("taste")) {
        this.game.debug(
          `D1432 | ${this.name}.js | ${direct_object.id}.dov.taste.enabled is false `
        );
        msg += `{We} can't taste ${direct_object.name}. `;
        this.handleFailure(msg);
        return null;
      }

      // single use direct object?
      if (
        direct_object.allowVerbOnce(this.name, "dov") &&
        direct_object.didVerb(this.name, "dov")
      ) {
        this.game.debug(
          `D1994 | ${this.name}.js | ${direct_object.id}.dov.${this.name}.once and ${direct_object.id}.did.${this.name}.directly `
        );
        msg += `{We've} already ${this.past_tense} enough of ${direct_object.articlename}. `;
        this.handleFailure(msg);
        return false;
      }

      if (!direct_object.hasDescription("taste")) {
        this.game.debug(
          `D1433 | ${this.name}.js | ${direct_object.id}.descriptions.taste is unset `
        );
        msg += `${direct_object.Articlename} has no particular taste. `;
        this.handleFailure(msg);
        return null;
      }

      return true;
    },

    doSuccess: function () {
      var input = this.game.getInput();
      var direct_object = input.getAsset(1);
      var msg = "";

      // compose output
      msg += `{We} gently nibble at ${direct_object.articlename}. `;
      msg += this.game.getDescription({
        asset: direct_object,
        identifier: "taste",
      });

      // --------------------------------------------------
      // print output
      // --------------------------------------------------
      return this.handleSuccess(msg);
    },
  };
})(); // taste