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

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

  /**
   * @augments {adventurejs.Verb}
   * @class think
   * @ajsnode game.dictionary.verbs.think
   * @ajsconstruct MyGame.createVerb({ "name": "think", [...] });
   * @ajsconstructedby adventurejs.Dictionary#createVerb
   * @hideconstructor
   * @ajsinstanceof Verb
   * @ajsnavheading Conversation Verbs
   * @summary Verb meaning think, as in "think about love letters".
   * @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; </span>
   *
   * </pre>
   * <p>
   * Description of the verb.
   * </p>
   * @ajsverbreactions
   * @ajsverbphases doBeforeTry, doAfterTry, doBeforeSuccess, doAfterSuccess
   * @TODO everything - copied this from tell, which also is todo
   */
  A.Preverbs.think = {
    name: "think",
    prettyname: "think about",
    past_tense: "told",
    synonyms: ["thinkabout"],
    verb_prep_noun: ["think about"], // think about thing
    verb_noun_prep_noun: ["think about"], // think person about thing

    /**
     * @memberof think
     * @ajsverbphrase
     * phrase1:
     * {
     *   accepts_noun: true,
     *   requires_noun: true,
     *   noun_must_be:
     *   {
     *     known: true,
     *     present: true,
     *   },
     * },
     */
    phrase1: {
      accepts_noun: true,
      requires_noun: true,
      noun_must_be: {
        known: true,
        present: true,
      },
    },

    /**
     * @memberof think
     * @ajsverbphrase
     * phrase2:
     * {
     *   accepts_noun: true,
     *   requires_noun: true,
     *   noun_must_be:
     *   {
     *     known: true,
     *   },
     * },
     */
    phrase2: {
      accepts_noun: true,
      requires_noun: true,
      noun_must_be: {
        known: true,
      },
    },

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

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

      // no indirect object given
      // if( "undefined" === typeof input.parsedNoun2 )
      // {
      //   input.parsedNoun2 = A.clone.call(this.game, input.parsedNoun1 );
      //   input.parsedNoun1 = undefined;
      //   input.setSoftPrompt({ noun1: true, verb: 'think' });
      //   var msg = "To whom would you like to think it? ";
      //   this.handleFailure(msg);
      //   return null;
      // }

      // can't talk to non-characters
      if (!(direct_object instanceof adventurejs.Character)) {
        this.game.debug(
          ` | ${this.name}.js | ${direct_object.id} is not class Character `
        );
        msg += `${direct_object.Articlename} doesn't listen. `;
        this.handleFailure(msg);
        return null;
      }

      return true;
    },

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

      this.game.debug(`F1855 | ${this.name}.js | print doSuccess `);
      // think x about y
      msg += `$(We) think ${direct_object.articlename} about ${indirect_object.articlename}. `;

      // transfer of knowledge

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