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

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

  /**
   * @augments {adventurejs.Verb}
   * @class enter
   * @ajsnode game.dictionary.verbs.enter
   * @ajsconstruct MyGame.createVerb({ "name": "enter", [...] });
   * @ajsconstructedby adventurejs.Dictionary#createVerb
   * @hideconstructor
   * @ajsinstanceof Verb
   * @ajsnavheading DirectionVerbs
   * @summary Verb meaning enter specified asset, or travel in.
   * @ajssynonyms enter, in
   * @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; enter</span>
   * You enter the bathysphere, which drops prematurely, spins,
   * and fills with water, causing you to drown.
   * </pre>
   * <p>
   * Direction verb: <strong>enter</strong>.
   * To learn about {@link adventurejs.Exit|Exits},
   * see <a href="/doc/GetStarted_CreateAnExit.html">Create an Exit</a>.
   * </p>
   * @ajsverbphases doBeforeTry, doAfterTry, doBeforeSuccess, doAfterSuccess
   */
  A.Preverbs.enter = {
    name: "enter",
    past_tense: "entered",
    synonyms: ["enter", "in"],
    is_direction: true,
    type: { direction: true },

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

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

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

    doTry: function () {
      var input = this.game.getInput();
      var direct_object = input.getAsset(1);
      if (direct_object) {
        input.setPreposition(1, "in");
        input.setStructure("verb preposition noun");
        this.game.dictionary.doVerb("go");
        return null;
      }
      return true;
    },

    doSuccess: function () {
      var input = this.game.getInput();
      this.game.tryTravel(this.name);
      return true;
    },
  };
})();