Pre-release
Adventure.js Docs Downloads
Score: 0 Moves: 0
// lick.js

(function () {
  /*global adventurejs A*/
  "use strict";

  /**
   * @augments {adventurejs.Verb}
   * @class lick
   * @ajsnode game.dictionary.verbs.lick
   * @ajsconstruct MyGame.createVerb({ "name": "lick", [...] });
   * @ajsconstructedby adventurejs.Dictionary#createVerb
   * @hideconstructor
   * @ajsinstanceof Verb
   * @ajsnavheading SensationVerbs
   * @summary Verb meaning lick asset.
   * @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; lick toad</span>
   * You lick the toad. It tastes disgusting, like wet dirt,
   * but nothing happ... Oh. Oh. Something's definitely happening.
   * It comes in a rush: a feeling of anxiety, followed by a lack
   * of balance, things start spinning. Uh oh. This might have been
   * the wrong trip. And then. And then. And then... ah, it's alright.
   * You've settled in now. It's going to be an interesting night.
   * </pre>
   * <p>
   * <strong>Lick</strong> requires that the
   * {@link adventurejs.Tangible|Tangible}
   * {@link adventurejs.Asset|Asset} to be licked has asset.dov.lick.enabled set to true. No special logic is provided with the verb.
   * Authors wanting to make use of it may need to use a method such
   * as verb hooks. See
   * <a href="/doc/Scripting_VerbPhases.html">Verb Phases</a>
   * to learn more.
   * </p>
   * <p>
   * Lick and {@link taste|taste} behave identically if they're
   * not given any special reactions.
   * </p>
   * @ajsverbreactions
   * @ajsverbphases doBeforeTry, doAfterTry, doBeforeSuccess, doAfterSuccess
   */
  A.Preverbs.lick = {
    name: "lick",
    prettyname: "lick",
    past_tense: "licked",
    synonyms: ["lick"],

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

    /**
     * @memberof lick
     * @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 lick
     * @ajsverbparams
     * with_params: {},
     */
    with_params: {},

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

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

      // single use direct object?
      if (
        direct_object.DOVallowOnce(this.name) &&
        direct_object.DOVdidDo(this.name)
      ) {
        this.game.debug(
          `F1993 | ${this.name}.js | ${direct_object.id}.dov.${this.name}.once and ${direct_object.id}.dov.${this.name}.did_do `
        );
        msg += `$(We've) already ${this.past_tense} ${direct_object.articlename} enough. `;
        this.handleFailure(msg);
        return false;
      }

      if (!direct_object.hasDescription("taste")) {
        this.game.debug(
          `F1333 | ${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 direct_preposition = input.getPreposition(1);
      var indirect_object = input.getAsset(2);
      var indirect_preposition = input.getPreposition(2);
      var player = this.game.getPlayer();
      var results;
      var msg = "";

      this.game.debug(`F1334 | ${this.name}.js | print doSuccess `);

      // compose output
      msg += `$(We) lick ${direct_object.articlename}. `;
      if (direct_object.hasDescription("taste")) {
        msg += direct_object.getDescription("taste");
      }

      // print output
      this.handleSuccess(msg, direct_object);
      return true;
    },
  };
})();