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

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

  /**
   * @augments {adventurejs.Verb}
   * @class test
   * @ajsnode game.dictionary.verbs.test
   * @ajsconstruct MyGame.createVerb({ "name": "test", [...] });
   * @ajsconstructedby adventurejs.Dictionary#createVerb
   * @hideconstructor
   * @ajsinstanceof Verb
   * @ajsnavheading UtilityVerbs
   * @summary Summary.
   * @tutorial Scripting_VerbSubscriptions
   * @tutorial Verbs_VerbAnatomy
   * @tutorial Verbs_VerbProcess
   * @tutorial Verbs_ModifyVerbs
   * @tutorial Verbs_WriteVerbs
   * @classdesc Verbs start out as generic objects, which are converted
   * to verb class instances at runtime.
   * <br/><br/>
   * Verbs have access to the global Input object ( game.getInput() ),
   * which contains parsed player input.
   * @ajsverbreactions
   * @ajsverbphases doBeforeTry, doAfterTry, doBeforeSuccess, doAfterSuccess
   */
  A.Preverbs.test = {
    name: "test",
    prettyname: "test",
    past_tense: "tested",
    state: "tested",
    unstate: "untested",
    synonyms: ["test"],
    verb_noun_prep: [],
    verb_prep_noun: [],
    verb_prep_prep_noun: [],
    verb_prep_prep_prep_noun: [],
    verb_noun_prep_noun: [],
    verb_noun_prep_prep_noun: [],
    verb_noun_prep_noun_prep_noun: [],
    verb_prep_noun_prep_noun_prep_noun: [],

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

    /**
     * @memberof test
     * @ajsverbphrase
     * phrase1:
     * {
     *   accepts_noun: true,
     *   // requires_noun: true,
     *   // accepts_plural_noun: true,
     *   noun_must_be: {
     *     // direction: true,
     *     // not_direction: true,
     *     // tangible: true,
     *     // intangible: true,
     *     // character: true,
     *     // present: true,
     *     // visible: true,
     *     // reachable: true,
     *     // takeable: true,
     *     // known: true,
     *     // in_inventory: true,
     *     // not_in_inventory: true,
     *     // worn: true,
     *     // not_worn: true,
     *     // in_hands: true,
     *     // not_in_hands: true,
     *   },
     *   // accepts_preposition: true,
     *   // accepts_preposition_without_noun: true,
     *   // requires_preposition: true,
     *   // accepts_these_prepositions: [ 'from' ],
     *   // declines_these_prepositions: [ 'to' ],
     * },
     */

    phrase1: {
      accepts_noun: true,
      // requires_noun: true,
      accepts_plural_noun: true,
      noun_must_be: {
        // direction: true,
        // not_direction: true,
        // tangible: true,
        // intangible: true,
        // character: true,
        // present: true,
        // visible: true,
        // reachable: true,
        // takeable: true,
        // known: true,
        // in_inventory: true,
        // not_in_inventory: true,
        // worn: true,
        // not_worn: true,
        // in_hands: true,
        // not_in_hands: true,
      },
      accepts_preposition: true,
      accepts_preposition_without_noun: true,
      // requires_preposition: true,
      // accepts_these_prepositions: [ 'from' ],
      // declines_these_prepositions: [ 'to' ],
    },

    /**
     * @memberof test
     * @ajsverbphrase
     * phrase2:
     * {
     *   accepts_noun: true,
     *   // requires_noun: true,
     *   // accepts_plural_noun: true,
     *   noun_must_be: {
     *     // direction: true,
     *     // not_direction: true,
     *     // tangible: true,
     *     // intangible: true,
     *     // character: true,
     *     // present: true,
     *     // visible: true,
     *     // reachable: true,
     *     // takeable: true,
     *     // known: true,
     *     // in_inventory: true,
     *     // not_in_inventory: true,
     *     // worn: true,
     *     // not_worn: true,
     *     // in_hands: true,
     *     // not_in_hands: true,
     *   },
     *   // accepts_preposition: true,
     *   // accepts_preposition_without_noun: true,
     *   // requires_preposition: true,
     *   // accepts_these_prepositions: [ 'from' ],
     *   // declines_these_prepositions: [ 'to' ],
     * },
     */

    phrase2: {
      accepts_noun: true,
      // requires_noun: true,
      accepts_plural_noun: true,
      noun_must_be: {
        // direction: true,
        // not_direction: true,
        // tangible: true,
        // intangible: true,
        // character: true,
        // present: true,
        // visible: true,
        // reachable: true,
        // takeable: true,
        // known: true,
        // in_inventory: true,
        // not_in_inventory: true,
        // worn: true,
        // not_worn: true,
        // in_hands: true,
        // not_in_hands: true,
      },
      accepts_preposition: true,
      accepts_preposition_without_noun: true,
      // requires_preposition: true,
      // accepts_these_prepositions: [ 'from' ],
      // declines_these_prepositions: [ 'to' ],
    },

    /**
     * @memberof test
     * @ajsverbphrase
     * phrase3:
     * {
     *   accepts_noun: true,
     *   // requires_noun: true,
     *   // accepts_plural_noun: true,
     *   noun_must_be: {
     *     // direction: true,
     *     // not_direction: true,
     *     // tangible: true,
     *     // intangible: true,
     *     // character: true,
     *     // present: true,
     *     // visible: true,
     *     // reachable: true,
     *     // takeable: true,
     *     // known: true,
     *     // in_inventory: true,
     *     // not_in_inventory: true,
     *     // worn: true,
     *     // not_worn: true,
     *     // in_hands: true,
     *     // not_in_hands: true,
     *   },
     *   // accepts_preposition: true,
     *   // accepts_preposition_without_noun: true,
     *   // requires_preposition: true,
     *   // accepts_these_prepositions: [ 'from' ],
     *   // declines_these_prepositions: [ 'to' ],
     * },
     */

    phrase3: {
      accepts_noun: true,
      // requires_noun: true,
      accepts_plural_noun: true,
      noun_must_be: {
        // direction: true,
        // not_direction: true,
        // tangible: true,
        // intangible: true,
        // character: true,
        // present: true,
        // visible: true,
        // reachable: true,
        // takeable: true,
        // known: true,
        // in_inventory: true,
        // not_in_inventory: true,
        // worn: true,
        // not_worn: true,
        // in_hands: true,
        // not_in_hands: true,
      },
      accepts_preposition: true,
      accepts_preposition_without_noun: true,
      // requires_preposition: true,
      // accepts_these_prepositions: [ 'from' ],
      // declines_these_prepositions: [ 'to' ],
    },

    let_verb_handle_disambiguation: false,

    doTry: 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 msg = "";

      if (input.hasStructure("verb")) {
        // this.game.debug(` | ${this.name}.js | sentence structure 'verb'`);
        // msg += this.game.parser.getUnparsedMessage(input.input);
        // this.handleFailure(msg);
        // return false;
      }

      if (input.hasStructure("verb noun")) {
        // this.game.debug(` | ${this.name}.js | sentence structure 'verb'`);
        // msg += this.game.parser.getUnparsedMessage(input.input);
        // this.handleFailure(msg);
        // return false;
      }

      if (input.hasStructure("verb preposition")) {
        // this.game.debug(` | ${this.name}.js | sentence structure 'verb'`);
        // msg += this.game.parser.getUnparsedMessage(input.input);
        // this.handleFailure(msg);
        // return false;
      }

      if (input.hasStructure("verb preposition noun")) {
      }

      // sentence structure: verb noun preposition noun ----------
      if (input.hasStructure("verb noun preposition noun")) {
      }

      /*
       * If any block in doTry returns false, that ends the parse.
       * If the parser is working on stacked input (for example,
       * "do this THEN do that"), the parser will move to the next
       * item in the stack.
       */
    },

    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 indirect_object2 = input.getAsset(3);
      var indirect_preposition2 = input.getPreposition(3);
      var player = this.game.getPlayer();
      var msg = "";

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

      // apply state changes
      //this.setState(direct_object,false);

      // compose output
      msg += `$(We) ${this.name}`;
      msg += direct_preposition ? ` ${direct_preposition}` : ``;
      msg += direct_object ? ` ${direct_object.articlename}` : ``;
      msg += indirect_preposition ? ` ${indirect_preposition}` : ``;
      msg += indirect_object ? ` ${indirect_object.articlename}` : ``;
      msg += indirect_preposition2 ? ` ${indirect_preposition2}` : ``;
      msg += indirect_object2 ? ` ${indirect_object2.articlename}` : ``;
      msg += `. `;

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