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

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

  /**
   * @augments {adventurejs.Verb}
   * @class jump_across
   * @ajsnode game.dictionary.verbs.jump_across
   * @ajsconstruct MyGame.createVerb({ "name": "jump_across", [...] });
   * @ajsconstructedby adventurejs.Dictionary#createVerb
   * @hideconstructor
   * @ajsinstanceof Verb
   * @ajsnavheading DeprecatedVerbs
   * @summary Summary.
   * @ajssynonyms jump across, hop across
   * @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; jump across light years</span>
   * You jump across the light years, spanning entire constellations
   * of stars. Gaseous nebulae stream past, coating you in sparkling
   * particles. Here, a new civilization rises in your wake.
   * There, another is destroyed by your passing shadow. Worlds
   * come to know you as creator and destroyer, yin and yang,
   * alpha and omega. You arrive at your destination, refreshed,
   * and brush away multicolored crystals of frozen liquids.
   * </pre>
   * <p>
   * <strong>Jump across</strong> requires that the
   * {@link adventurejs.Tangible|Tangible}
   * {@link adventurejs.Asset|Asset} to be jumped across has its
   * <a class="code" href="/doc/adventurejs.Tangible.html#property_can_jump_across">can.jump_across</a>
   * property 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>
   */
  A.Preverbs.jump_across = {
    name: "jump_across",
    prettyname: "jump across",
    synonyms: [],
    verb_prep_noun: ["hop across", "jump across"],

    player_must_be: {
      not_constrained: true,
      not_on_floor: true,
      not_nested_elsewhere: true,
    },

    phrase1: {
      accepts_noun: true,
      requires_noun: true,
      noun_must_be: {
        known: true,
        tangible: true,
        present: true,
        visible: true,
        reachable: true,
      },
    },

    doTry: function () {
      var input = this.game.getInput();
      var direct_object = input.getAsset(1);
      var player = this.game.getPlayer();
      var nest_preposition = player.getNestPreposition();
      var nest_parent_id = player.getNestId();
      var nest_parent_object = player.getNestAsset();

      // can't jump across object
      if (false === direct_object.can.jump_across) {
        var msg = "$(We) can't jump over " + direct_object.articlename + ". ";
        this.handleFailure(msg);
        return null;
      }

      return true;
    },

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

      var msg = "$(We) jump across " + direct_object.articlename + ". ";

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