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

Verb: close demo structures phrases params phases actions methods properties

Instance of: adventurejs.Verb

Defined in: adventure/dictionary/verbs/close.js, line 7

More info: VerbSubscriptions VerbAnatomy VerbProcess ModifyVerbs WriteVerbs

Runtime node: game.dictionary.verbs.close

Synonyms: close, shut

> close can of snakes
You close the can of snakes, though you can never put the snakes back in the can.

Close a Tangible Asset. Requires that the Asset has asset.dov.close.enabled set to true and asset.is.closed is false.

close demo + example code


// OpenGame.js
// ----------
/*global adventurejs A OpenGame*/

var OpenGame = new adventurejs.Game("OpenGame", "OpenGameDisplay").set({
  // title, version, and author are shown in the title bar
  title: "Open Game",
  version: "0.0.1",
  author: "Ivan Cockrum",

  description: "This is my great game! Thanks for playing!",
});

OpenGame.settings.set({
  // if this is true, lists of exits will
  // show the names of rooms they lead to
  show_room_names_in_exit_descriptions: true,

  // if this is true, lists of exits will
  // only include room names known to player
  show_room_names_in_exit_descriptions_only_when_room_is_known: false,

  // if this is true, lists of exits will only
  // show room names for exits player has used
  show_room_names_in_exit_descriptions_only_after_exit_has_been_used: false,

  // if this is true, verbose room descriptions
  // will only be shown on first visit
  print_verbose_room_descriptions_on_first_visit: true,

  // if this is true, adventurejs will print
  // debug messages to the game display
  print_debug_messages: true,

  // set this to set a default response to
  // player input that is not understood
  if_parser_has_no_response_print_this: "I have no response to your input. ",

  // set this to provide a default
  // response to blank input
  if_input_is_empty_print_this: "I didn't see any input. ",

  // alternately, game can be set to print
  // the current room description with
  // if_input_is_empty_print_room_description: true
});

// Foyer

OpenGame.createAsset({
  class: "Room",
  name: "Open Foyer",

  descriptions: {
    look: `Welcome to the Open Demo, where you can try opening and closing things, and locking and unlocking and picking locks, with the verbs open, close, lock, unlock, pick. Visit the other rooms in this demo to find some demonstrations. `,
    brief: `Try verbs. Open, close, lock, unlock, pick. `,
  },

  exits: {
    // This is a shortcut for creating an Exit. It's useful
    // for exits that don't have any special properties or
    // an Aperture, which is an Exit's physical presence.
    east: "Sitting Room",
  },
}); // Open Foyer

// Player

OpenGame.createAsset({
  class: "Player",
  name: "Tim Hunter",
  place: { in: "Open Foyer" },
  is: { active: true },
});

// Scoring

OpenGame.scorecard.set({
  // This is how you set score events for your game.
  // You can add as few or as many as you like,
  // and set points to whatever number you like.
  // The names are up to you, so set them however you like.
  score_events: {
    "open window": 1,
    "take ann": 1,
    "open library door": 1,
    "open top drawer": 1,
    "open chest": 1,
    "take andy": 1,

    // Let's say you want the game to start with
    // some points already set. You can do that like this.
    "preset points": { points: 5, complete: true, recorded: true },

    // You can set negative points too. These unset points cancel
    // out the preset points above.
    "unset points": { points: -5, complete: true, recorded: true },
  },

  // To attach a score event to your custom function, use
  // OpenGame.scorecard.completeEvent('open window');
  // You'll see these sprinkled throughout this demo code.

  // Adventurejs has built-in scoring functions,
  // but you may, if you like, write custom score handling.

  // this returns a string
  // score_message: `$(Our) score went up! `,

  // this returns a custom function
  // score_message: function(){
  //   return `Dude, you totally just got ${this.diff} points!`
  // },

  // Or maybe you just want to tweak the score display.
  // By default score appears in 0/0 format, but let's
  // say you'd like it to say "Score: 0 out of 0".
  // score_format: function()
  // {
  //   return `Score: ${this.score} out of ${this.total}`;
  // }

  // score_message and score_format have access to some vars:
  // - this.score (old score)
  // - this.newscore (new score)
  // - this.diff (difference between old/new )
  // - this.total (total of points available)
});


// SittingRoom.js
// ----------
/*global adventurejs A OpenGame*/

OpenGame.createAsset({
  class: "Room",
  article: "the",
  name: "Sitting Room",
  descriptions: {
    look: "The sitting room has many things on which to sit. None of them are objects though, because this is not a sitting demo. I suppose we should have called it an opening room. Shut up about it already! Instead, try opening and closing things: the playground window, the library door, the chest. Oh, did I mention that there's a window and a door? ",
    brief: "Don't sit. Window. Door. ",
  },
  exits: {
    west: "Open Foyer",
  },
});

// Sitting Room Out

OpenGame.createAsset({
  class: "Exit",
  direction: "out",
  place: { in: "Sitting Room" },
  destination: "Playground",
  descriptions: {
    for_exits_list: `out the window to the 
    Playground`,
    travel: `$(We) climb clumsily out the window and tumble 
    to the playground, where you land on your bottom on a 
    soft tuft of grass. `,
  },
  aperture: "inside window",
});

// Sitting Room Out - Playground Window

OpenGame.createAsset({
  class: "Window",
  name: "inside window",
  synonyms: ["playground window", "playground"],
  place: { in: "Sitting Room" },
  direction: "out",
  descriptions: {
    // Note that this code block uses a combination of Javascript
    // native template literals and Adventurejs custom templates:
    // ${OpenGame} and $(inside window). The one with {squiggly}
    // brackets is Javascript. The one with (parentheses) is Adventurejs.

    // These can be used in combination, with one important caveat.
    // For many properties, Adventurejs can accept a string or array
    // or function. Adventurejs custom templates are only evaluated
    // immediately before being output. But, Javascript template
    // literals used in a string are evaluated when the property
    // containing the string is created. So in order to use template
    // literals, it's important to wrap the string in a function
    // that will only be evaluated when called by Adventurejs.

    look: () => `
      Through the window, $(we) can see a child's playground. 
      Currently the window is 
      $(inside window is| locked or| unlocked) and 
      $(inside window is| open or| closed).
      ${
        !OpenGame.$("inside window")._didDo("unlock")
          ? `The window locks and unlocks by way of a simple  
        sash latch that doesn't require any key. `
          : ""
      } 
      ${
        OpenGame.$("inside window").$is("locked")
          ? "Try opening the window without first unlocking it. "
          : ""
      } 
      ${
        !OpenGame.$("inside window").$is("closed")
          ? `$(We) might just climb through it. `
          : ""
      }
      `,

    // This commented block below is an alternate version.
    // It may appear like it should work the same way,
    // but because it has a template literal in a string property,
    // it would throw an error when the game is launched.

    // look: `The window is
    // $(inside window is| open or| closed) and
    // $(inside window is| locked or| unlocked).
    // It locks by way of a simple sash latch that doesn't require any key.
    // ${OpenGame.$('inside window').$is('locked')?
    //   'Try entering "unlock window then open it".':''}
    //   Beyond the window, $(we) can see a child's playground. `,

    // Here, we've set a description to use if a player
    // inputs "look through window".
    through: "You can see a small child's playground through the window. ",

    // And here, we're redirecting "look out window"
    // to "look through window" so we can capture both
    // possibilities without duplicating the code.
    out: function () {
      return this.descriptions.through;
    },
  },

  is: {
    closed: true,
    locked: true,
  },
  dov: {
    // window.dov.unlock.with_nothing
    // allows the window to be unlocked without use of a key.
    unlock: {
      with_nothing: true,
      on_first_success: function () {
        if (!this.is.closed) {
          // In some circumstances, when a user inputs 'open thing',
          // the verb open may redirect to 'unlock thing'. If that
          // happened here, we want to account for it by returning
          // our custom open.on_first_success function.
          return this.dov.open.on_first_success();
        } else {
          return "$(We) should easily be able to open it now. ";
        }
      },
    },

    // lock and unlock params have to be set independently.
    // This is so that you could, for instance, set it so that
    // once the player unlocks it, it can't be locked again.
    lock: { with_nothing: true },

    open: {
      // on_first_success calls this function and
      // appends this string to the native verb output,
      // only the first time the player opens the window.
      on_first_success: function () {
        OpenGame.scorecard.completeEvent("open window");
        return "Now that it's open $(we) just might climb out of it. ";
      },

      // on_first_failure only prints a message
      on_first_failure: `But it's just a simple sash 
      latch that doesn't need any key to unlock it. `,
    },
  },

  // This inside window is linked to the outside window.
  // Apertures, aka doors and windows, only exist in one room.
  // For a door to be in two rooms, we actually need two doors:
  // one side in one room, the other side in the other room.
  // We handle each side as a unique asset. In order to keep them
  // in sync we use the linked_asset property, so that if one is
  // set as open, so is the other one.
  linked_asset: "outside window",
});

// Sitting Room North

OpenGame.createAsset({
  class: "Exit",
  direction: "north",
  place: { in: "Sitting Room" },
  destination: "Library",
  descriptions: {
    //look: "It looks frosty that way. ",

    // for_exits_list is a special description for exits,
    // that lets authors customize how individual exits
    // are described when the player is presented with a
    // list of exits.
    for_exits_list:
      "through the door north to the Library",
  },
  aperture: "library door",
});

// Sitting Room North Door - library Door

OpenGame.createAsset({
  class: "Door",
  name: "library door",
  place: { in: "Sitting Room" },
  is: {
    closed: true,
    locked: true,
  },
  dov: {
    //close: true, // already set for all instances of Door class
    open: {
      on_first_success: function () {
        OpenGame.scorecard.completeEvent("open library door");
        return "Now you can enter the Library.  ";
      },
    },

    // Note here how we're setting it so the library door can be
    // unlocked with the brass key.
    unlock: {
      with_assets: ["brass key"],
      with_nothing: false,
    },

    // We set the assets for each verb, lock and unlock, explicitly
    // because it's common that an author might want a player to
    // unlock a door and then never have to interact with it again.
    // So if we want the key to also lock the door, we have to say so.
    lock: {
      with_assets: ["brass key"],
      with_nothing: false,
    },
  },
  linked_asset: "sitting room door",
  direction: "north",
  descriptions: {
    look: "A lovely Victorian nine panel oak door with frosted glass and a scuffed brass lock plate. ",
    through: function () {
      // Here we're setting a description for "look through door"
      // that returns a different value depending on whether the
      // door is open or closed.
      // "through" is what we call an Aspect, along with behind,
      // in, on, under, and many other prepositions. Any Aspect
      // can have a unique description set this way.
      if (!OpenGame.$("library door").$is("closed")) {
        return "Through the open door you can see shelves stuffed with books and books and books. ";
      } else {
        return "The glass panes in the door's upper half are quite heavily frosted, and don't reveal anything beyond. ";
      }
    },
  },
});

// coffee table

OpenGame.createAsset({
  class: "Table",
  name: "coffee table",
  place: { in: "Sitting Room" },
  description:
    "It's a low, rectangular coffee table, apparently hand carved from oak. ",
  adjectives: "wood, wooden, carved, oak",
  aspects: {
    on: {
      player: { can: { enter: false } },
    },
  },
  dov: {
    go: {
      doBeforeTry: function (params) {
        // See how we're using a Verb Hook here. This is a way
        // to inject custom code into a verb when it is applied
        // to a particular asset. In this case by hooking into
        // go.doBeforeTry, we interrupt the verb before it can
        // run its default doTry conditional logic,
        // and print our own failure message. This basically means:
        // we don't care what the default logic has to say; you
        // just don't put your fat feet on the fine furniture.
        // See /doc/Scripting_VerbPhases.html for more info.
        OpenGame.print(
          "I mean, $(we) could, but it would just be rude. ",
          "concatenate_output"
        );
        return false;
      },
    },
    sit: {
      // Here, we're setting sit, stand and lie to use
      // the same code as go.doBeforeTry. This is one way
      // you could apply the same custom logic to multiple
      // verbs on an object. There are also other ways to
      // achieve similar results, such as unsubscribing
      // the asset from these verbs, or using verb actions.
      doBeforeTry: function () {
        return this.dov.go.doBeforeTry();
      },
    },
    stand: {
      doBeforeTry: function () {
        return this.dov.go.doBeforeTry();
      },
    },
    lie: {
      doBeforeTry: function () {
        return this.dov.go.doBeforeTry();
      },
    },
  },

  // Here's an example of a verb effect hook.
  // This will be superceded by the verb phases up above; to see
  // it in action you'll have to comment out the verb phases block.
  // Verb reactions are called when a particular action occurs,
  // such as moving the player onto an asset, regardless of what
  // verb caused it; go, or climb, or jump, or sit, or lie.
  // Every verb that results in moving the player into a thing
  // tries to call thing.doNestThatToThis(player).
  // doNestThatToThis is a very broad effect hook that will catch
  // a lot of circumstances. Other effect hooks may be broad or narrow.
  // See /doc/Scripting_VerbActions.html for more info.
  doNestThatToThis: {
    // Nesting only applies to characters.
    // Tim Hunter is the name of our player character in this game.
    "Tim Hunter": function () {
      this.game.print(
        "Whoa there, podner! Let's keep those fat feet off the fine furniture. "
      );
      return false;
    },
  },

  // Alternately, if you wanted the same verb effect hook to apply to
  // all assets, you could define it as a function itself rather
  // than creating nested objects. This is also valid.
  // In this case, since the doNestThatToThis function is on the
  // coffee table, it would prevent all characters from nesting.

  // doNestThatToThis: function()
  // {
  //   this.game.print("Whoa there, podner! Let's keep those fat feet off the fine furniture. ");
  //   return false;
  // },
});


// Library.js
// ----------
/*global adventurejs A OpenGame*/

OpenGame.createAsset({
  class: "Room",
  name: "Library",
  descriptions: {
    look: `The library is stuffed with books near 
    to the point of inducing claustrophia. But also cozy? 
    It's hard to say precisely. $(We) scan the 
    overflowing shelves. Sadly, none of the books are objects. 
    Instead, take a look at the bureau and its drawers. `,

    brief: "Books. Desk. Door south. ",
  },
}); // Library

// Sitting Room south Exit

OpenGame.createAsset({
  class: "Exit",
  direction: "south",
  place: { in: "Library" },
  destination: "Sitting Room",
  descriptions: {
    //look: "A heavy Victorian nine panel oak door with frosted panes. ",
    for_exits_list:
      "south to the Sitting Room",
  },
  aperture: "sitting room door",
});

// Sitting Room south door
// Exits have no physical properties. In order to apply
// physical properties to an exit, it needs an Aperture.
// Apertures can be manipulated like other tangible assets.

OpenGame.createAsset({
  class: "Door",
  name: "sitting room door",
  place: { in: "Library" },
  direction: "south",
  descriptions: {
    look: "It's a Victorian 9 panel oak door. ",
    open: "The sitting room door is open. ",
    closed: "The sitting room door is closed. ",

    // Assets can have a number of descriptions to use in
    // different contexts. Descriptions can be strings or
    // arrays or functions. This example shows a function
    // that uses native Javascript logic to return a string.
    // See /doc/tutorial-Subscription.html for more info.
    through: function () {
      // This is one way to refer to objects in custom code:
      // GameName.$( "asset name" ).is("property")
      // See /doc/Scripting_CustomCode.html for more info.
      if (!OpenGame.$("sitting room door").$is("closed")) {
        return "Through the open door $(we) can see the Sitting Room. ";
      } else {
        return "$(We) can't see anything through the door's frosted panes. ";
      }
    },
  },
  linked_asset: "library door",
  is: {
    closed: true,
    locked: true,
  },
  dov: {
    open: true,
    close: true,
    unlock: { with_assets: ["brass key"] },
    lock: { with_assets: ["brass key"] },
  },
});

// bureau desk

OpenGame.createAsset({
  class: "Desk",
  name: "bureau desk",
  adjectives: ["oak", "wood", "wooden", "substantial"],
  synonyms: [],
  place: { in: "Library" },
  descriptions: {
    // Note that this description is an ordinary string property. Elsewhere in this demo
    // we're using traditional functions or arrow functions because they include
    // Javascript template literals. This example only includes Adventurejs custom
    // templates, which do not get evaluated until output, and are safe to use in strings.
    // See /doc/Scripting_CustomTemplates.html for more info.
    look: `
      It's a substantial oak bureau desk with multiple drawers stacked vertically, 
      top, middle and bottom. The top drawer is $( top drawer is| open or| closed ), 
      the middle drawer is $( middle drawer is| open or| closed ), and the bottom 
      drawer is $( bottom drawer is| open or| closed ). `,
  },
  aspects: {
    on: {
      player: { can: { enter: false } },
    },
  },
});

// top drawer

OpenGame.createAsset({
  class: "Drawer",
  name: "top drawer",
  adjectives: ["desk", "scratched"],
  synonyms: ["lock", "lock plate", "scratches"],

  // Note how we're using top_drawer.description here whereas we've used
  // desk.descriptions.look above. All assets can have multiple
  // descriptions. Setting asset.description is a shortcut to setting
  // asset.descriptions.look, for when an asset only needs one description.
  description: `The top drawer's copper lock plate 
    seems to be particularly scratched up. 
    Currently the drawer is $( top drawer is| open or| closed ). `,

  place: { attached: "bureau desk" },
  is: {
    // Note how we're setting known:true here.
    // By default, players can't interact with
    // assets until they're known.
    // Also by default, attached assets don't
    // become known until a player examines
    // the asset they're attached to.
    known: true,

    closed: true,
    locked: true,
    listed_in_parent: false,
  },
  dov: {
    // Adventurejs treats 'pick' and 'unlock' as distinct verbs.
    // If a player tries to use 'unlock' where 'pick' is defined,
    // the parser will try to redirect to 'pick'.

    pick: { with_assets: ["copper hairpin"] },
    // Pick and unlock are distinct verbs, to allow authors to
    // create precise situations. But, making them distinct can
    // lead to finicky situations that are unpleasant for players.
    // It's a fine line. We could either set it so that both verbs
    // work the same way:
    // unlock: { with_assets: ['copper hairpin'] },
    // Or we give the player a hint, if we don't want unlock to work.
    unlock: { on_failure: `$(We) might be able to pick it with something. ` },

    open: {
      on_first_failure: "Bet you didn't see that coming, huh? ",
      on_first_success: function () {
        OpenGame.scorecard.completeEvent("open top drawer");
        //return "  ";
      },
    },
  },
});

// middle drawer

OpenGame.createAsset({
  class: "Drawer",
  name: "middle drawer",
  synonyms: "middle desk drawer",
  description: "The middle drawer is $( middle drawer is| open or| closed ). ",
  adjectives: "desk",
  place: { attached: "bureau desk" },
  is: {
    known: true,
    closed: true,
    listed_in_parent: false,
  },
});

// bottom drawer

OpenGame.createAsset({
  class: "Drawer",
  name: "bottom drawer",
  synonyms: "bottom desk drawer",
  description: "The bottom drawer is $( bottom drawer is| open or| closed ). ",
  adjectives: "desk",
  place: { attached: "bureau desk" },
  is: {
    known: true,
    closed: true,
    listed_in_parent: false,
  },
});

// drawers collection

// Collections are a special class that allows players to refer
// to a group of objects and try to apply a verb to all of them,
// or get back a combined description.
// See doc/adventurejs.Collection.html for more info.
OpenGame.createAsset({
  class: "Collection",
  name: "desk drawers",
  place: { attached: "bureau desk" },
  collection: ["top drawer", "middle drawer", "bottom drawer"],
  synonyms: ["drawers", "three drawers"],
  is: {
    known: true,
    listed_in_parent: false,
  },
  descriptions: {
    look: function () {
      var openCount = [];
      var closedCount = [];
      var msg = "";

      msg += `The bureau has three drawers stacked vertically: 
      top, middle and bottom, each with a copper lock plate. 
      The top drawer's lock appears to be rather scratched up. 
      Currently, `;

      // Note how we're using 'this' here. Under normal circumstances
      // nested properties don't have access to their top level object.
      // Adventurejs uses asset.descriptions.look.call(asset)
      // to ensure that asset descriptions can refer to their asset.
      // Any property that relies on getStringOrArrayOrFunction()
      // will have 'this' scoped to its parent asset.
      // See /doc/Scripting_StringArrayFunction.html for more info.
      for (var i in this.collection) {
        // this.collection contains asset names.
        // We want to get references to the asset objects.
        // One way to do this is with GameName.$("my asset")
        // See /doc/Scripting_CustomCode.html for more info.
        let drawer = OpenGame.$(this.collection[i]);

        // Once we have an asset reference, asset.$is(property)
        // is a safe way to try to get asset properties.
        drawer.$is("closed")
          ? closedCount.push(drawer.name)
          : openCount.push(drawer.name);
      }

      if (0 === openCount.length) {
        msg += "all three drawers are closed.";
      } else if (0 === closedCount.length) {
        msg += "all three drawers are open.";
      } else if (2 == openCount.length) {
        msg += `the ${openCount[0]} and ${openCount[1]} 
        are open, while the ${closedCount[0]} is closed. `;
      } else if (2 == closedCount.length) {
        msg += `the ${closedCount[0]} and ${closedCount[1]} 
        are open, while the ${openCount[0]} is open. `;
      }

      return msg;
    },
  },
});


// Playground.js
// ----------
/*global adventurejs A OpenGame*/

OpenGame.createAsset({
  class: "Room",
  article: "the",
  name: "Playground",
  descriptions: {
    look: `Fireflies speckle the dusk with softly pulsing 
    motes of light. $(We've) come to a modest child's playground 
    around back of the house. The playground has many things with 
    which to play, but none of them are objects, and we're not 
    going to get into it, ok? A window leads back into the house. `,

    brief: `Play here. Go window. `,
  },
  room_scenery: {
    fireflies: {
      enabled: true,
      description:
        "Fireflies pulse gently here and there, lending a charming quality to the darkening playground. ",
    },
    grass: {
      enabled: true,
      description:
        "Occasional tufts of glossy medium height grass dot the yard. ",
    },
  },
});

// Playground in

OpenGame.createAsset({
  class: "Exit",
  direction: "in",
  place: { in: "Playground" },
  destination: "Sitting Room",
  descriptions: {
    for_exits_list: `in to the Sitting Room`,
    travel: `$(We) grab hold of the window sill, scrabble awkwardly up 
    the siding, and heft $(ourself) over the sill and in through the window, 
    where $(we) tumble into the sitting room. `,
  },
  aperture: "outside window",
});

// outside window

OpenGame.createAsset({
  class: "Window",
  name: "outside window",
  place: { in: "Playground" },
  direction: "in",
  descriptions: {
    // See how this example uses a traditional function.
    // Traditional functions are able to be scoped to their
    // top level assets which means you can use 'this' with them.
    // By contrast if you look at the code for the inside
    // window description, you'll see that it uses an arrow
    // function. Arrow functions are permitted, but because
    // they can't be scoped to their parent asset, they
    // can't use 'this'.
    look: function () {
      return `
      Though the sitting room seemed dimly lit, as it is 
      now dusk outside, the light through the window seems 
      quite bright from out here.
      The window is $(inside window is| open or| closed).
      ${
        !this.is.closed
          ? "$(We) should be able to climb back inside. "
          : "$(We'll) need to open the window if $(we) hope to get back through it. "
      }
      `;
    },

    // We could instead have used a traditional function here,
    // and those do receive scope, which would have let us use
    // 'this' to refer to the window.

    through:
      "The wan light of the sitting room seems quite bright from out here. ",
    in: function () {
      return this.descriptions.in;
    },
  },
  is: {
    closed: true,
    locked: true,
  },
  dov: {
    lock: { with_nothing: true },
    unlock: { with_nothing: true },
  },

  // Apertures, aka doors and windows etc, may exist in two places
  // one side in one room, and another side in another room.
  // We handle each side as a unique asset. In order to keep them
  // in sync, meaning open/closed and locked/unlocked, we use the
  // linked_asset property. This outside window asset is linked to
  // its other side, a corresponding inside window asset.
  linked_asset: "inside window",
});


// Objects.js
// ----------
/*global adventurejs A OpenGame*/

OpenGame.createAsset({
  class: "Chest",
  name: "small antique chest",
  indefinite_article: "an",
  place: { on: "coffee table" },

  descriptions: {
    look: function () {
      let msg = `It's a small antique Victorian chest, 
      lacquered in a glossy prussian blue and bound with 
      ornate blue steel straps that are pitted with age. 
      Its lid is 
      $(small antique chest is| locked or| unlocked) and 
      $(small antique chest is| open or| closed). `;
      if (this.game.$("small antique chest").$is("open")) {
        msg += `The chest is lined with a rich egg yolk 
          yellow brocade that presents a startling contrast 
          to its dark exterior. `;
      }
      return msg;
    },
  },
  adjectives: ["victorian", "prussian", "blue", "steel", "glossy", "old"],
  synonyms: ["straps"],
  is: {
    locked: true,
    closed: true,
  },
  dov: {
    open: {
      with_nothing: true,
      on_first_failure: `$(We) didn't think it was going to be that easy, did $(we)? `,
      on_first_success: function () {
        OpenGame.scorecard.completeEvent("open chest");
        //return "  ";
      },
    },
    unlock: {
      with_assets: ["blue steel key"],
    },
    lock: {
      with_assets: ["blue steel key"],
    },
  },
});

OpenGame.createAsset({
  class: "Paper",
  name: "goldenrod sheet",
  description: `It's a sheet of goldenrod colored paper with 
    a child's drawing on it. The drawing appears to feature  
    a girl with fire engine red hair. The name "Copper" is 
    scrawled above her in big childlike letters. `,
  place: { in: "top drawer" },
});

OpenGame.createAsset({
  class: "Key",
  name: "brass key",
  synonyms: ["glass bead"],
  article: "a",
  adjectives: ["burnished", "chonky"],
  place: { on: "coffee table" },
  description: `It's a burnished brass key with chonky teeth 
  and a small glass bead mounted in the head. `,
  iov: {
    unlock: {
      // Adventurejs offers many ways to override its default
      // actions and output. If
      // asset.dov.unlock.on_failure
      // is a string, it will be appended to the default unlock
      // failure message. In this case, we want to completely
      // override the output, so we call this.game.overrideOutput()
      // this.game is the same as OpenGame when called from a scoped function.
      // on_failure: function(){ this.game.overrideOutput(
      //   `Whoops! This brass key doesn't unlock that ${OpenGame.getInput().getAsset(1).name}. `
      // )},
      on_first_failure: function () {
        this.game.overrideOutput(
          `Whoops! Looks like $(we) can't unlock ${
            OpenGame.getInput().getAsset(1).articlename
          } with the brass key. `
        );
      },

      on_success: `Now you can open the door. `,
      then_destroy: `Oh no! The brass key broke! `,

      // There's something missing here. We haven't set this key to
      // unlock: { with_assets: ['sitting room door'] },
      // to indicate that this key can open that lock.
      // That's because we've already set that lock to
      // unlock: { with_assets: ['brass key'] }
      // When assets are linked through verb subscriptions,
      // you only have to set one or the other. Two-way connections
      // will be completed during game initialization.
    },
  },
  dov: {
    take: { on_first_success: "Now to find something to unlock with it. " },
  },
}); // brass Key

OpenGame.createAsset({
  class: "Key",
  name: "blue steel key",
  synonyms: ["blue key", "steel key"],
  adjectives: ["victorian"],
  iov: {
    unlock: { with_assets: ["small antique chest"] },
  },
  description: "It's an ornate Victorian key made of blue steel. ",
  // article: "a",
  place: { in: "top drawer" },
});

// OpenGame.createAsset({
//   class: "Key",
//   name: "tiny brass key",
//   description: "It's a tiny key, made of brass. ",
//   article: "a",
//   adjectives: ["tiny", "brass"],
//   // place: { in: "Sitting Room" },
//   iov: { 'unlock': {then_destroy: { with_result: "foo" }, }, },
// });

// OpenGame.createAsset({
//   class: "Key",
//   name: "giant brass key",
//   description: "It's a giant novelty key that looks like it's made of brass. ",
//   article: "a",
//   adjectives: "giant, brass",
//   // place: { in: "Sitting Room" },
// });

OpenGame.createAsset({
  class: "Doll",
  name: "Raggedy Ann doll",
  place: { in: "Playground" },
  descriptions: {
    look: function () {
      return `It's a threadworn Raggedy Ann doll, either well 
      loved or abandoned, it's hard to tell which. 
      ${
        OpenGame.$("copper hairpin").$is("attached", this)
          ? "A patch of her red hair is gathered into a loose pigtail by a hairpin. "
          : "Her messy red hair is by turns tangled and patchy. "
      } `;
    },
  },
  aspects: {
    attached: {
      list_in_room: false,
      list_in_examine: false,
    },
  },
  dov: {
    attach: {
      with_nothing: true,
    },
    take: {
      on_first_success: function () {
        OpenGame.scorecard.completeEvent("take ann");
        //return " ";
      },
    },
  },
});

OpenGame.createAsset({
  class: "Doll",
  name: "Raggedy Andy doll",
  place: { in: "small antique chest" },
  descriptions: {
    look: function () {
      return `It's a well-loved Raggedy Andy doll in a patched 
      sailor suit. His red hair is partially covered by a cap 
      that appears to be sewn on. " } `;
    },
  },
  dov: {
    take: {
      on_first_success: function () {
        OpenGame.scorecard.completeEvent("take andy");
        //return " ";
      },
    },
  },
});

OpenGame.createAsset({
  class: "Lockpick",
  name: "copper hairpin",
  synonyms: ["pin", "beads", "tines", "head"],
  adjectives: ["hammered"],
  article: "the",
  dov: {
    attach: {
      with_nothing: true,
    },
    take: {
      on_first_success:
        "Good catch. It looks like it might be used to pick a lock. ",
      on_success: "$(We) twirl it between $(our) nimble fingers. ",
    },
  },
  iov: {
    pick: {
      with_assets: ["top drawer"],
      then_destroy:
        "The hairpin snaps into pieces! $(We'll) have to find Raggedy Ann a new one. ",
      on_failure:
        "And just as well, as the copper is quite soft and probably won't serve long. ",
    },
  },
  descriptions: {
    throw: "It skitters across the floor. ",
    look: `The hammered copper hairpin has two tines and  
    a butterfly shaped head with tiny beads affixed to it, in  
    a vaguely art nouveau style. It's actually quite nice. `,
  },
  place: { attached: "raggedy ann doll" },
});

close sentence structures

accepts_structures: [
  "verb noun",
  "verb noun preposition noun"
]
accepts_structures: [
  "verb noun",
  "verb noun preposition noun"
]
accepts_structures: [
  "verb noun",
  "verb noun preposition noun"
]
accepts_structures: [
  "verb noun",
  "verb noun preposition noun"
]

The Adventurejs parser uses multiple filtering methods to try to interpret player input. Sentence structures are defined for each verb in order to narrow down the sentence structures that a verb can accept. For example, the verb "hit" might accept "verb noun" as in "hit troll", or "verb noun preposition noun" as in "hit troll with sword", whereas an intransitive verb like "jump" might accept "verb" as a complete sentence. This helps to filter player input. Input that isn't accepted will return a warning to the player.

  • It is possible for authors to modify a verb's structures through the use of patchVerb.
  • To learn more about modifying verbs, see Modify Verbs.

close phrases

phrase1:
{
  accepts_noun: true,
  noun_must_be:
  {
    known: true,
    tangible: true,
    present: true,
    visible: true,
    reachable: true,
  },
},
phrase2:
{
  accepts_noun: true,
  noun_must_be:
  {
    in_inventory: true,
    known: true,
  },
  accepts_preposition: true,
  requires_preposition: true,
  accepts_these_prepositions: ["with"],
},
phrase2:
{
  accepts_noun: true,
  noun_must_be:
  {
    in_inventory: true,
  },
  accepts_preposition: true,
  requires_preposition: true,
  accepts_these_prepositions: ["with"],
},
phrase2:
{
  accepts_noun: true,
  noun_must_be:
  {
    in_inventory: true,
    known: true,
  },
  accepts_preposition: true,
  requires_preposition: true,
  accepts_these_prepositions: ["with"],
},
phrase2:
{
  accepts_noun: true,
  noun_must_be:
  {
    in_inventory: true,
    known: true,
  },
  accepts_preposition: true,
  requires_preposition: true,
  accepts_these_prepositions: ["with"],
},

The Adventurejs parser uses multiple filtering methods to try to interpret player input. Phrases are defined for each verb in order to narrow down the words that a verb can accept. This applies to preposition/noun pairs: from zero in the case of intransitive verbs, up to three in the case of verbs that can handle input such as "pour water from jug into basin". The nested noun_must_be object sets conditional qualifiers for nouns, that helps narrow down game objects that the verb might act upon. Input that isn't accepted will return a warning to the player.

  • It is possible for authors to modify a verb's phrases through the use of patchVerb.
  • To see a list of properties that can be set for phrases, see the Phrase class.
  • To see a list of properties that can be set for phrase.noun_must_be, see the NounMustBe class.
  • To learn more about modifying verbs, see Modify Verbs.

close params

Some verbs have custom params which are mirrored in the properties of any asset subscribed to the verb.

with_params: {},

For example, consider this setting of the verb plugIn:

MyGame.dictionary.verbs.plugIn.with_params.max_connections = 1

By default, assets that can be plugged in will take this setting and can only be plugged in to one other asset. Now imagine that an author wants to create a power cord that needs to be plugged in to both a computer and an outlet.

MyGame.createAsset({
  class: "Cable",
  name: "power cord",
  dov: { plugIn: { with_assets: ['computer','outlet'], with_params: { max_connections: 2 }, }, },
})
MyGame.createAsset({
  class: "Computer",
  name: "PC",
  iov: { plugIn: { with_assets: ['power cord'], }, },
})
MyGame.createAsset({
  class: "ElectricalOutlet",
  name: "outlet",
  iov: { plugIn: { with_assets: ['power cord'], }, },
})

The power cord's max_connections setting overrides the verb's max_attachment setting, allowing the player to plug the power cord into two assets, while the computer and the outlet can still have only one asset plugged into them.

  • It is possible for authors to modify a verb's params through the use of patchVerb.
  • To learn more about modifying verbs, see Modify Verbs.

close verb phases

Verb Phases allow an author to override how a verb is applied to any given asset. This is a broad method for exercising control over verb/noun interactions that allows for custom per-asset verb logic. For example, an author might supply completely different logic for "throw feather" vs "throw baseball" vs "throw anvil". This works by overriding portions of asset verb subscriptions. When a verb is applied to an asset, its do() method is called. For most (but not all) verbs, do() acts as a sequencer that moves the verb through six distinct phases.

  • doTry handles all the conditional logic to determine whether a verb can be applied to an asset.
  • doSuccess handles output and state changes.
  • doBeforeTry, doAfterTry, doBeforeSuccess and doAfterSuccess don't do anything by themselves, but provide opportunities for authors to inject custom code at various stages of a verb action.

do

    doBeforeTry
    MyGame.createAsset({
      class: "Thing",
      name: "This Asset",
      dov: {
        close: {
          doBeforeTry: function( params )
          {
            let msg = `You're about to try to close ${this.Name}. `;
            this.game.print(msg);
            return;
          },
        },
      },
    });

    doTry

    doAfterTry
    MyGame.createAsset({
      class: "Thing",
      name: "This Asset",
      dov: {
        close: {
          doAfterTry: function( params )
          {
            let msg = `You just tried to close ${this.Name}! `;
            this.game.print(msg);
            return;
          },
        },
      },
    });
    doBeforeSuccess
    MyGame.createAsset({
      class: "Thing",
      name: "This Asset",
      dov: {
        close: {
          doBeforeSuccess: function( params )
          {
            let msg = `You're about to try to succeed in performing close on ${this.Name}. `;
            this.game.print(msg);
            return;
          },
        },
      },
    });

    doSuccess

    doAfterSuccess
    MyGame.createAsset({
      class: "Thing",
      name: "This Asset",
      dov: {
        close: {
          doAfterSuccess: function( params )
          {
            let msg = `You're moving on from your success performing close on ${this.Name}. `;
            this.game.print(msg);
            return;
          },
        },
      },
    });

For example, consider the verb "take" as applied to this singing sword. Imagine that an author wants the game to print a custom message when the player tries to take the sword, and a different message when the player succeeds in taking it.

MyGame.createAsset({
  class: "Sword",
  name: "singing sword",
  dov: {
    take: 
    {
      doAfterTry: function( params )
      {
        let msg = "The sword begins to vibrate as your hand curls around its haft. ";
        MyGame.print( msg );
      },
      doAfterSuccess: function( params )
      {
        let msg = "The sword bursts into song in your hand. ";
        MyGame.print( msg );
      },
    },
  },
});

Please note that verb subscriptions are set distinctly for direct objects and indirect objects. All of the prior examples show verb phases applied to direct object verb subscriptions. Verb phases can also be applied to indirect object subscriptions. For example, perhaps our swinging sword had to be removed from a stone. We might want to hook into the stone's indirect object verb subscription for "remove".

MyGame.createAsset({
  class: "Thing",
  name: "stone",
  iov: {
    remove: 
    {
      doBeforeTry: function( params )
      {
        let msg = "Will the stone judge you worthy enough to remove the sword? "
        MyGame.print( msg );
      },
      doAfterSuccess: function( params )
      {
        let msg = "With the sword removed, the stone bursts into rubble! ";
        MyGame.print( msg );
        this.destroy();
      },      
    },
  },
});
  • To learn more, see Verb Phases.
  • Verb Phases are related to but distinct from Verb Actions, which offers a more surgical method to hook into the doTry and doSuccess phases, on a per object basis.

close verb actions

Verb actions provide hooks for injecting custom code into very specific verb actions (or reactions). It works by looking for custom functions attached to the assets that the verb is being applied to, and calling any function that it finds. It's a fine-grained way to tailor specific verb/noun interactions. Each verb has a unique set of actions. For instance, the verb lock has onTryLock and onTryLockThisWithThat and several other lock-specific hooks, whereas the verb climb has onTryClimb and onTryClimbFromThisToThat, etc.

Expand any item to see a code example.

tryCloseThis

If a verb is called with a direct object, the verb.handleActions method looks at the direct object for a verb action.

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  tryCloseThis: function (params) {
    let msg = 'Called verb action this_asset.tryCloseThis()';
    this.game.print(msg);
    return;
  },
});

Verb actions can have nested functions. If tryCloseThis is found to be an object rather than a function, the verb.handleActions method checks the object for a nested verb action that treats the player as an indirect object. This can be used in this way:

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  tryCloseThis: { 
    "My Hero": function (params) {
      let msg = 'Called verb action this_asset.tryCloseThis["My Hero"]()';
      this.game.print(msg);
      return;
    }
  },
});
doCloseThis

If a verb is called with a direct object, the verb.handleActions method looks at the direct object for a verb action. (Although, during the doTry phase, it's common for sentence structures to mutate so that they have changed by the time they reach the doSuccess phase.)

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  doCloseThis: function (params) {
    let msg = 'Called verb action this_asset.doCloseThis()';
    this.game.print(msg);
    return;
  },
});

Verb actions can have nested functions. If doCloseThis is found to be an object rather than a function, the verb.handleActions method checks the object for a nested verb action that treats the player as an indirect object. This can be used in this way:

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  doCloseThis: { 
    "My Hero": function (params) {
      let msg = 'Called verb action this_asset.doCloseThis["My Hero"]()';
      this.game.print(msg);
      return;
    }
  },
});
tryCloseThis[Preposition]That

If a verb is called with a direct object + preposition + indirect object, the verb.handleActions method looks at the direct object + preposition for a verb action.

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  tryCloseThisThroughThat: function (params) {
    let msg = 'Called verb action this_asset.tryCloseThisThroughThat()';
    this.game.print(msg);
    return;
  },
});

Verb actions can have nested functions. If tryCloseThisThroughThat is found to be an object rather than a function, the verb.handleActions method checks the object for a nested verb action for the indirect object. This can be used in this way:

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  tryCloseThisThroughThat: { 
    "That Asset": function (params) {
      let msg = 'Called verb action this_asset.tryCloseThisThroughThat["That Asset"]()';
      this.game.print(msg);
      return;
    }
  },
});
doCloseThis[Preposition]That

If a verb is called with a direct object + preposition, the verb.handleActions method looks at the direct object + preposition for a verb action. This example uses "through" as the preposition, but any preposition can be used. You can even set up unique function calls per preposition.

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  doCloseThisThroughThat: function (params) {
    let msg = 'Called verb action this_asset.doCloseThroughThis()';
    this.game.print(msg);
    return;
  },
});

Verb actions can have nested functions. If tryCloseThisThroughThat is found to be an object rather than a function, the verb.handleActions method checks the object for a nested verb action for the indirect object. This can be used in this way:

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  doCloseThisThroughThat: { 
    "That Asset": function (params) {
      let msg = 'Called verb action this_asset.doCloseThisThroughThat["That Asset"]()';
      this.game.print(msg);
      return;
    }
  },
});
tryCloseThis

If a verb is called with a direct object, the verb.handleActions method looks at the direct object for a verb action.

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  tryCloseThis: function (params) {
    let msg = 'Called verb action this_asset.tryCloseThis()';
    this.game.print(msg);
    return;
  },
});

Verb actions can have nested functions. If tryCloseThis is found to be an object rather than a function, the verb.handleActions method checks the object for a nested verb action that treats the player as an indirect object. This can be used in this way:

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  tryCloseThis: { 
    "My Hero": function (params) {
      let msg = 'Called verb action this_asset.tryCloseThis["My Hero"]()';
      this.game.print(msg);
      return;
    }
  },
});
doCloseThis

If a verb is called with a direct object, the verb.handleActions method looks at the direct object for a verb action. (Although, during the doTry phase, it's common for sentence structures to mutate so that they have changed by the time they reach the doSuccess phase.)

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  doCloseThis: function (params) {
    let msg = 'Called verb action this_asset.doCloseThis()';
    this.game.print(msg);
    return;
  },
});

Verb actions can have nested functions. If doCloseThis is found to be an object rather than a function, the verb.handleActions method checks the object for a nested verb action that treats the player as an indirect object. This can be used in this way:

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  doCloseThis: { 
    "My Hero": function (params) {
      let msg = 'Called verb action this_asset.doCloseThis["My Hero"]()';
      this.game.print(msg);
      return;
    }
  },
});
tryCloseThis[Preposition]That

If a verb is called with a direct object + preposition + indirect object, the verb.handleActions method looks at the direct object + preposition for a verb action.

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  tryCloseThisThroughThat: function (params) {
    let msg = 'Called verb action this_asset.tryCloseThisThroughThat()';
    this.game.print(msg);
    return;
  },
});

Verb actions can have nested functions. If tryCloseThisThroughThat is found to be an object rather than a function, the verb.handleActions method checks the object for a nested verb action for the indirect object. This can be used in this way:

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  tryCloseThisThroughThat: { 
    "That Asset": function (params) {
      let msg = 'Called verb action this_asset.tryCloseThisThroughThat["That Asset"]()';
      this.game.print(msg);
      return;
    }
  },
});
doCloseThis[Preposition]That

If a verb is called with a direct object + preposition, the verb.handleActions method looks at the direct object + preposition for a verb action. This example uses "through" as the preposition, but any preposition can be used. You can even set up unique function calls per preposition.

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  doCloseThisThroughThat: function (params) {
    let msg = 'Called verb action this_asset.doCloseThroughThis()';
    this.game.print(msg);
    return;
  },
});

Verb actions can have nested functions. If tryCloseThisThroughThat is found to be an object rather than a function, the verb.handleActions method checks the object for a nested verb action for the indirect object. This can be used in this way:

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  doCloseThisThroughThat: { 
    "That Asset": function (params) {
      let msg = 'Called verb action this_asset.doCloseThisThroughThat["That Asset"]()';
      this.game.print(msg);
      return;
    }
  },
});
tryCloseThis

If a verb is called with a direct object, the verb.handleActions method looks at the direct object for a verb action.

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  tryCloseThis: function (params) {
    let msg = 'Called verb action this_asset.tryCloseThis()';
    this.game.print(msg);
    return;
  },
});

Verb actions can have nested functions. If tryCloseThis is found to be an object rather than a function, the verb.handleActions method checks the object for a nested verb action that treats the player as an indirect object. This can be used in this way:

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  tryCloseThis: { 
    "My Hero": function (params) {
      let msg = 'Called verb action this_asset.tryCloseThis["My Hero"]()';
      this.game.print(msg);
      return;
    }
  },
});
doCloseThis

If a verb is called with a direct object, the verb.handleActions method looks at the direct object for a verb action. (Although, during the doTry phase, it's common for sentence structures to mutate so that they have changed by the time they reach the doSuccess phase.)

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  doCloseThis: function (params) {
    let msg = 'Called verb action this_asset.doCloseThis()';
    this.game.print(msg);
    return;
  },
});

Verb actions can have nested functions. If doCloseThis is found to be an object rather than a function, the verb.handleActions method checks the object for a nested verb action that treats the player as an indirect object. This can be used in this way:

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  doCloseThis: { 
    "My Hero": function (params) {
      let msg = 'Called verb action this_asset.doCloseThis["My Hero"]()';
      this.game.print(msg);
      return;
    }
  },
});
tryCloseThis[Preposition]That

If a verb is called with a direct object + preposition + indirect object, the verb.handleActions method looks at the direct object + preposition for a verb action.

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  tryCloseThisThroughThat: function (params) {
    let msg = 'Called verb action this_asset.tryCloseThisThroughThat()';
    this.game.print(msg);
    return;
  },
});

Verb actions can have nested functions. If tryCloseThisThroughThat is found to be an object rather than a function, the verb.handleActions method checks the object for a nested verb action for the indirect object. This can be used in this way:

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  tryCloseThisThroughThat: { 
    "That Asset": function (params) {
      let msg = 'Called verb action this_asset.tryCloseThisThroughThat["That Asset"]()';
      this.game.print(msg);
      return;
    }
  },
});
doCloseThis[Preposition]That

If a verb is called with a direct object + preposition, the verb.handleActions method looks at the direct object + preposition for a verb action. This example uses "through" as the preposition, but any preposition can be used. You can even set up unique function calls per preposition.

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  doCloseThisThroughThat: function (params) {
    let msg = 'Called verb action this_asset.doCloseThroughThis()';
    this.game.print(msg);
    return;
  },
});

Verb actions can have nested functions. If tryCloseThisThroughThat is found to be an object rather than a function, the verb.handleActions method checks the object for a nested verb action for the indirect object. This can be used in this way:

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  doCloseThisThroughThat: { 
    "That Asset": function (params) {
      let msg = 'Called verb action this_asset.doCloseThisThroughThat["That Asset"]()';
      this.game.print(msg);
      return;
    }
  },
});
tryCloseThis

If a verb is called with a direct object, the verb.handleActions method looks at the direct object for a verb action.

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  tryCloseThis: function (params) {
    let msg = 'Called verb action this_asset.tryCloseThis()';
    this.game.print(msg);
    return;
  },
});

Verb actions can have nested functions. If tryCloseThis is found to be an object rather than a function, the verb.handleActions method checks the object for a nested verb action that treats the player as an indirect object. This can be used in this way:

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  tryCloseThis: { 
    "My Hero": function (params) {
      let msg = 'Called verb action this_asset.tryCloseThis["My Hero"]()';
      this.game.print(msg);
      return;
    }
  },
});
doCloseThis

If a verb is called with a direct object, the verb.handleActions method looks at the direct object for a verb action. (Although, during the doTry phase, it's common for sentence structures to mutate so that they have changed by the time they reach the doSuccess phase.)

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  doCloseThis: function (params) {
    let msg = 'Called verb action this_asset.doCloseThis()';
    this.game.print(msg);
    return;
  },
});

Verb actions can have nested functions. If doCloseThis is found to be an object rather than a function, the verb.handleActions method checks the object for a nested verb action that treats the player as an indirect object. This can be used in this way:

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  doCloseThis: { 
    "My Hero": function (params) {
      let msg = 'Called verb action this_asset.doCloseThis["My Hero"]()';
      this.game.print(msg);
      return;
    }
  },
});
tryCloseThis[Preposition]That

If a verb is called with a direct object + preposition + indirect object, the verb.handleActions method looks at the direct object + preposition for a verb action.

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  tryCloseThisThroughThat: function (params) {
    let msg = 'Called verb action this_asset.tryCloseThisThroughThat()';
    this.game.print(msg);
    return;
  },
});

Verb actions can have nested functions. If tryCloseThisThroughThat is found to be an object rather than a function, the verb.handleActions method checks the object for a nested verb action for the indirect object. This can be used in this way:

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  tryCloseThisThroughThat: { 
    "That Asset": function (params) {
      let msg = 'Called verb action this_asset.tryCloseThisThroughThat["That Asset"]()';
      this.game.print(msg);
      return;
    }
  },
});
doCloseThis[Preposition]That

If a verb is called with a direct object + preposition, the verb.handleActions method looks at the direct object + preposition for a verb action. This example uses "through" as the preposition, but any preposition can be used. You can even set up unique function calls per preposition.

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  doCloseThisThroughThat: function (params) {
    let msg = 'Called verb action this_asset.doCloseThroughThis()';
    this.game.print(msg);
    return;
  },
});

Verb actions can have nested functions. If tryCloseThisThroughThat is found to be an object rather than a function, the verb.handleActions method checks the object for a nested verb action for the indirect object. This can be used in this way:

MyGame.createAsset({
  class: "Thing",
  name: "This Asset",
  doCloseThisThroughThat: { 
    "That Asset": function (params) {
      let msg = 'Called verb action this_asset.doCloseThisThroughThat["That Asset"]()';
      this.game.print(msg);
      return;
    }
  },
});

Each of the items above can be expanded to show a specific example, but here is a generic example.

MyGame.createAsset({
  class: "Player",
  name: "Elvis",  
});
MyGame.createAsset({
  class: "Weapon",
  name: "pistol",
});
MyGame.createAsset({
  class: "Electronics",
  name: "television",
  doShootThisWithThat:{
    "pistol": function {
      let msg = "You fire the pistol at the television, which explodes with a screech of static and sparks. ";
      this.game.print(msg);
    },
  },
});
  • To learn more, see Verb Actions.
  • Some hooks are not tied to any specific verbs and though these are technically identical, we refer to them as verb reactions. See Verb Reactions for a list of them.
  • Verb actions are related to but distinct from verb phases, which allow authors to broadly override entire phases of a verb.

close verb reactions

None available for close

Verb reactions provide a hook for authors to inject custom code into specific interactions between assets. They are identical to verb actions but for one thing: while verb actions are called during a verb's doTry or doSuccess phases, verb reactions are called as a secondary effect, or result, of doSuccess. For example, take lantern results in moving the lantern to the player from its original parent. Drop lantern results in moving the lantern from the player to the room. In both cases, the lantern leaves one place and enters another, so both verbs result in calling these four verb reactions:

lantern.doRemoveThisFromThat(player),
player.doRemoveThatFromThis(lantern),
lantern.doMoveThisToThat(room), and
room.doMoveThatToThis(lantern).

OMG you may exclaim. Why four reactions? Technically, two reactions are occurring – the lantern leaves the player and enters the room – but because we want to give authors maximum flexibility to organize code however makes sense to them, we check both assets for code relative to the other.

In this example, imagine that an author would like the game to print a custom message whenever a certain asset enters or leaves another asset, by any method.

MyGame.createAsset({
  class: "NPC",
  name: "Elvis",
}),
MyGame.createAsset({
  class: "Room",
  name: "The Building",
  doMoveThatToThis: 
  {
    "Elvis": function() 
    {
      MyGame.print("Elvis has entered The Building! ");
    }
  },
  doRemoveThatFromThis: 
  {
    "Elvis": function() 
    {
      MyGame.print("Elvis has left The Building! ");
    }
  },
}),
  • To learn more, see Verb Reactions.
  • Hooks that are tied directly to verbs are called verb actions. See Verb Actions for more information.
  • Verb reactions are related to but distinct from verb phases, which allow authors to broadly override entire phases of a verb.

close verb logic

Verb logic falls into a few recognizable patterns. Direction verbs tend to be simple. Manipulation verbs do a lot of testing to see whether one asset is allowed to interact with another asset. Many verbs are similar, but no two verbs are identical. Each verb has its quirks. If you would like to learn more about verb logic, we recommend you see the Verb Anatomy and Verb Process pages. If you find that you want more than you can get from verb phases and verb actions / reactions / you may want to investigate the patchVerb method, which lets you replace entire blocks of verb code. You can also write verbs from scratch if you're so inclined. See Modify Verbs for a complete list of verb modification methods.

Private Constructor:

MyGame.createVerb({ "name": "close", [...] });

close is a predefined instance of Verb that gets constructed automatically at runtime. It is defined in the library as a generic object, and then passed to Dictionary#createVerb for construction, validation, and initialization. Because this is predefined, authors should not need to create new instances. For information on modifying predefined Verbs, see Modify Verbs.

Inherited Overrides

Index

Methods:

Properties:

Methods Collapse all  |  Expand all

canBeIntransitive()

Defined in: adventure/dictionary/Verb.js, line 1905

Inherited from: adventurejs.Verb#canBeIntransitive

Verb can be intransitive if it doesn't require a noun.
do()

Defined in: adventure/dictionary/Verb.js, line 968

Inherited from: adventurejs.Verb#do

Verb.do is a coordinating method that sequences six other submethods in a series. In the case of Verb instances that can act on a collection of Assets in a single turn, Verb.do only fires once, but it loops through the Asset collection and calls each submethod for every Asset in the collection. The sequence is:

do -> The two key submethods are Verb.doTry and Verb.doSuccess. For most Verb instances, these two methods contain the bulk of the logic particular to this Verb. Verb.doTry determines whether a Verb can act on an Asset, and if it can't, prints an error message to Display. Verb.doSuccess applies the Verb to the Asset: updates the game state, assembles dynamic output, and prints the results to Display.

A Verb instance isn't required to use all of these methods. Some Verbs may bypass Verb.doTry because no special conditions are required to apply the Verb. Some specialized Verbs such as oops and undo override Verb.do entirely and don't use any submethods.

The other four submethods – Verb.doBeforeTry, Verb.doAfterTry, Verb.doBeforeSuccess, and Verb.doAfterSuccess – exist to provide optional hooks for authors to add custom interactions with individual Assets. For more information about Verb Actions and Verb Phases, see Verb Actions and Verb Phases.

And so, the first thing Verb.do does is to verify that each method exists on the Verb instance. If the submethod exists, it is called. Each submethod sends a return to Verb.do.

If the Verb is acting on a collection, a false return means that the Asset currently being acted on has responded in a way that blocks further parsing, and brings this turn to a halt. A null return means that the Asset currently being acted on has concluded its own parsing, but not in such a way as to block further parsing, and Verb.do moves on to the next Asset.
doSuccess()

Defined in: adventure/dictionary/Verb.js, line 1233

Inherited from: adventurejs.Verb#doSuccess

doSuccess typically contains all the code needed to apply this Verb to the specified Asset once it has successfully passed through all of our conditional logic. doBeforeSuccess and doAfterSuccess are provided so that authors can apply custom success code on an item-by-item basis, but it is also possible to globally modify doSuccess. For information about modifying verbs, see Modify Verbs.
doTry()

Defined in: adventure/dictionary/Verb.js, line 1138

Inherited from: adventurejs.Verb#doTry

doTry typically contains all the specific logic needed to determine if this Verb can act on the specified Asset. (We already applied some general logic supplied by NounMustBe before arriving here.) For information about modifying verbs, see Modify Verbs.
enqueueCollection()

Defined in: adventure/dictionary/Verb.js, line 1582

Inherited from: adventurejs.Verb#enqueueCollection

enqueueCollection takes a collection of Assets and enqueues them to game.parser for sequential handling.
getState()

Defined in: adventure/dictionary/Verb.js, line 1923

Inherited from: adventurejs.Verb#getState

Get this verb's state or unstate.
handleActions()

Defined in: adventure/dictionary/Verb.js, line 1153

Inherited from: adventurejs.Verb#handleActions

handleActions attempts to call any verb actions that match the current assets and sentence structure.
handleFailure()

Defined in: adventure/dictionary/Verb.js, line 1620

Inherited from: adventurejs.Verb#handleFailure

handleFailure prints either a given fail message or a generic fail msg if one is specified.
handleSuccess()

Defined in: adventure/dictionary/Verb.js, line 1718

Inherited from: adventurejs.Verb#handleSuccess

handleSuccess prints the provided success message or a generic one that has been defined by author. It also checks direct and indirect objects for custom verb subscription on_success results and tryDestroy results.
hasState()

Defined in: adventure/dictionary/Verb.js, line 1914

Inherited from: adventurejs.Verb#hasState

Does this verb have state or unstate?
hasVerbSubscriptionConnection()

Defined in: adventure/dictionary/Verb.js, line 2064

Inherited from: adventurejs.Verb#hasVerbSubscriptionConnection

Test whether two assets are connected by this verb, for example a rope tied to a tree, or a computer plugged into a socket.
initialize()

Defined in: adventure/dictionary/Verb.js, line 1547

Inherited from: adventurejs.Verb#initialize

Todos: How does patchVerb handle initialization?

If Verb is a direction, initialize adds it to game.dictionary.directionLookup.
set(props) → {adventurejs.Verb}

Defined in: adventure/dictionary/Verb.js, line 1608

Inherited from: adventurejs.Verb#set

Parameters:

  • props Object
    A generic object containing properties to copy to the DisplayObject instance.
Provides a chainable shortcut method for setting a number of properties on the instance.

Returns:

adventurejs.Verb Returns the instance the method is called on (useful for chaining calls.)
setState()

Defined in: adventure/dictionary/Verb.js, line 1932

Inherited from: adventurejs.Verb#setState

Apply this verb's state or unstate to an asset.
setVerbSubscriptionConnection()

Defined in: adventure/dictionary/Verb.js, line 1941

Inherited from: adventurejs.Verb#setVerbSubscriptionConnection

Connect two assets that share a connection when acted upon by this verb. For example, in the case of 'plug computer into socket', each asset has the other asset's ID saved to its verb subscription like this:

computer.dov.plugIn.with_params.connections = ['socket']
socket.iov.plugIn.with_params.connections = ['computer']

This is one of two verb subscription properties that are related and very similar, and it's important to understand the distinction between them. ...with_assets defines which assets CAN BE connected. ...with_params.connections stores which assets ARE connected.

with_assets: computer.dov.plugIn.with_assets = ['socket']
connections: computer.dov.plugIn.with_params.connections = ['socket']
tryDestroyAfterUsing(object_of, asset) → {Object}

Defined in: adventure/asset/tryDestroyAfterUsing.js, line 7

Inherited from: adventurejs.Verb#tryDestroyAfterUsing

Parameters:

  • object_of String
  • asset Object
tryDestroyAfterUsing is the underlying function for tryDestroyDirectObjectAfterUsing and tryDestroyIndirectObjectAfterUsing.

Returns:

Object
tryDestroyDirectObjectAfterUsing(asset) → {Boolean|string}

Defined in: adventure/asset/tryDestroyDirectObjectAfterUsing.js, line 7

Inherited from: adventurejs.Verb#tryDestroyDirectObjectAfterUsing

Parameters:

  • asset Object
tryDestroyDirectObjectAfterUsing checks to see if the specified asset can only be used directly once with this verb by checking for asset.dov[this.name].then_destroy. This is intended to provide a hook for authors to easily destroy an object after a single use, such as a key that only works once and then breaks or disappears.

Returns:

Boolean | string
tryDestroyIndirectObjectAfterUsing(asset) → {Boolean|string}

Defined in: adventure/asset/tryDestroyIndirectObjectAfterUsing.js, line 7

Inherited from: adventurejs.Verb#tryDestroyIndirectObjectAfterUsing

Parameters:

  • asset Object
tryDestroyIndirectObjectAfterUsing checks to see if the specified asset can only be used indirectly once with this verb by checking for asset.iov[this.name].then_destroy. This is intended to provide a hook for authors to easily destroy an object after a single use, such as a key that only works once and then breaks or disappears.

Returns:

Boolean | string
tryToInferIndirectObject(direct_object, handle_input) → {Object}

Defined in: adventure/dictionary/Verb.js, line 1292

Inherited from: adventurejs.Verb#tryToInferIndirectObject

Parameters:

  • direct_object Object
  • handle_input Boolean
    If true, updates the global input object per standard specs used by most (but not all) of the verb instances that call this method.
tryToInferIndirectObject is called by some verbs when they receive a direct object with no indirect object, to test whether an indirect object can be inferred. In order to be inferred, indirect object must be in player inventory. If player hasn't already interacted with direct object and game.settings.infer_indirect_objects_only_after_interaction is true, tryToInferIndirectObject will fail regardless of other circumstances.

Returns:

Object
tryToPutThisInThatAspect(direct_object, preposition, indirect_object) → {Object}

Defined in: adventure/dictionary/Verb.js, line 1369

Inherited from: adventurejs.Verb#tryToPutThisInThatAspect

Parameters:

  • direct_object Object
  • preposition String
  • indirect_object Object
tryToPutThisInThatAspect checks to see if a asset can be placed within the specified aspect of another specified asset. For example, "put sword in stone" and "push stone into depression" would both be tested with this function.

Returns:

Object
unsetVerbSubscriptionConnection()

Defined in: adventure/dictionary/Verb.js, line 2009

Inherited from: adventurejs.Verb#unsetVerbSubscriptionConnection

Disconnect two assets that share a connection when acted upon by this verb. For example, in the case of 'plug computer into socket', each asset has the other asset's ID saved to its verb subscription like this:

computer.dov.plugIn.with_params.connections = ['socket']
socket.iov.plugIn.with_params.connections = ['computer']
validate()

Properties  | 

accepts_direction :String

Defined in: adventure/dictionary/Phrase.js, line 27

Inherited from: adventurejs.Verb#accepts_direction

Currently unused.
accepts_number :String

Defined in: adventure/dictionary/Phrase.js, line 41

Inherited from: adventurejs.Verb#accepts_number

Currently unused.
accepts_string :String

Defined in: adventure/dictionary/Phrase.js, line 20

Inherited from: adventurejs.Verb#accepts_string

Currently unused.
adjectives :String

Defined in: adventure/dictionary/Verb.js, line 251

Inherited from: adventurejs.Verb#adjectives

Verb.adjectives are for direction verbs so that, for example, 'south' can be associated with 'southern' and 'southernly'.
article :Boolean

Defined in: adventure/dictionary/Verb.js, line 328

Inherited from: adventurejs.Verb#article

Default value: false

Set whether a direction can be referred to with an article, as in "there is a door to the north" vs "there is a door to starboard". This is a bit of mixed purpose because this property doesn't apply to the verb, but is stored in directionLookup for reference with directions.
dictionary :Object

Defined in: adventure/dictionary/Verb.js, line 144

Inherited from: adventurejs.Verb#dictionary

Default value: {}

A shortcut to the main Game Dictionary.
direction_preposition :Boolean

Defined in: adventure/dictionary/Verb.js, line 340

Inherited from: adventurejs.Verb#direction_preposition

Default value: ""

When player travels, this string may be prepended before the verb name, such as "you walk to the north"
doVerb :Getter

Defined in: adventure/dictionary/Verb.js, line 487

Inherited from: adventurejs.Verb#doVerb

Returns "do[Verb]This" for consistency with callAction()
doVerbFromThis :Getter

Defined in: adventure/dictionary/Verb.js, line 503

Inherited from: adventurejs.Verb#doVerbFromThis

Returns "do[Verb]FromThis" for consistency with callAction()
doVerbThatFromThis :Getter

Defined in: adventure/dictionary/Verb.js, line 543

Inherited from: adventurejs.Verb#doVerbThatFromThis

Returns "do[Verb]ThatFromThis" for consistency with callAction()
doVerbThatWithThis :Getter

Defined in: adventure/dictionary/Verb.js, line 527

Inherited from: adventurejs.Verb#doVerbThatWithThis

Returns "do[Verb]ThatWithThis" for consistency with callAction()
doVerbThis :Getter

Defined in: adventure/dictionary/Verb.js, line 495

Inherited from: adventurejs.Verb#doVerbThis

Returns "do[Verb]This" for consistency with callAction()
doVerbThisFromThat :Getter

Defined in: adventure/dictionary/Verb.js, line 535

Inherited from: adventurejs.Verb#doVerbThisFromThat

Returns "do[Verb]ThisFromThat" for consistency with callAction()
doVerbThisWithThat :Getter

Defined in: adventure/dictionary/Verb.js, line 519

Inherited from: adventurejs.Verb#doVerbThisWithThat

Returns "do[Verb]ThisWithThat" for consistency with callAction()
doVerbWithThis :Getter

Defined in: adventure/dictionary/Verb.js, line 511

Inherited from: adventurejs.Verb#doVerbWithThis

Returns "do[Verb]WithThis" for consistency with callAction()
enqueue_collections :Array

Defined in: adventure/dictionary/Verb.js, line 406

Inherited from: adventurejs.Verb#enqueue_collections

Default value: false

enqueue_collections if true allows a verb to unbundle the members of a collection in order to queue up separate actions for each. For example, "gems" is a collection that refers to three unique assets; "diamond", "emerald" and "ruby". If take.enqueue_collections is true, "take gems" will act individually on the diamond, the emerald and the ruby. Only applies to direct object.
extends :String

Defined in: adventure/dictionary/Verb.js, line 165

Inherited from: adventurejs.Verb#extends

Default value: ""

Extension verbs may perform some contextual logic before forwarding to another verb for the bulk of logic, such as "crawl" -> "go".
game :Object

Defined in: adventure/dictionary/Verb.js, line 137

Inherited from: adventurejs.Verb#game

Default value: {}

A reference back to the main Game object.
in_can_mean_on :Boolean

Defined in: adventure/dictionary/Verb.js, line 295

Inherited from: adventurejs.Verb#in_can_mean_on

Default value: false

Some types of objects can accept 'in' for 'on' interchangeably, such as 'sit in chair' / 'sit on chair', or 'lie in bed' / 'lie on bed'.
input_substitutions :Object

Defined in: adventure/dictionary/Verb.js, line 357

Inherited from: adventurejs.Verb#input_substitutions

Default value: {}

To simplify identifying verbs in input, specifically with regards to adverbs & prepositions, we can provide a list of synonyms for the verb. The parser will look for these synonyms in the input and replace them with the verb name. Then, the verb can handle the adverb/preposition as it sees fit.
is_compass_direction :Boolean

Defined in: adventure/dictionary/Verb.js, line 311

Inherited from: adventurejs.Verb#is_compass_direction

Default value: false

Set whether direction verb is a compass direction, meaning, it can be found on a compass rose.
is_direction :Boolean

Defined in: adventure/dictionary/Verb.js, line 304

Inherited from: adventurejs.Verb#is_direction

Default value: false

Set whether verb is a direction verb.
is_spatial_direction :Boolean

Defined in: adventure/dictionary/Verb.js, line 319

Inherited from: adventurejs.Verb#is_spatial_direction

Default value: false

Set whether direction verb is a relative direction such as those used on ships: port, starboard, etc. Also applies to left, right, forward, back, etc.
let_verb_handle_disambiguation :Boolean

Defined in: adventure/dictionary/Verb.js, line 275

Inherited from: adventurejs.Verb#let_verb_handle_disambiguation

Default value: false

Setting this to true allows you to write your own disambiguation script. Warning: going off road! Recommended for experienced Javascript users.
let_verb_handle_remaining_input :Boolean

Defined in: adventure/dictionary/Verb.js, line 284

Inherited from: adventurejs.Verb#let_verb_handle_remaining_input

Default value: false

When input is parsed, parse the verb and then pass the remainder of the input to the verb as a string, for the verb to act on. Chief example is: "oops xxx" where we don't want to parse xxx, we just want to let oops use it as a substitute for last turn's unknown input.
name :String

Defined in: adventure/dictionary/Verb.js, line 174

Inherited from: adventurejs.Verb#name

Default value: ""

String provided in Verb definition file (aka preverb).
Name :Getter

Defined in: adventure/dictionary/Verb.js, line 422

Inherited from: adventurejs.Verb#Name

Default value: []

Return uppercase name of the verb.
override_verb_failure_msg :String

Defined in: adventure/dictionary/Verb.js, line 369

Inherited from: adventurejs.Verb#override_verb_failure_msg

Default value: undefined

Provides a simple method for an author to override all failure messages for a verb with one generic string.
override_verb_success_msg :String

Defined in: adventure/dictionary/Verb.js, line 378

Inherited from: adventurejs.Verb#override_verb_success_msg

Default value: undefined

Provides a simple method for an author to override success messages for a verb with one generic string.
past_tense :String

Defined in: adventure/dictionary/Verb.js, line 191

Inherited from: adventurejs.Verb#past_tense

The past tense of the verb. May be used in output strings.
player_must_be :Object

Defined in: adventure/dictionary/Verb.js, line 259

Inherited from: adventurejs.Verb#player_must_be

Default value: {}

player_must_be sets conditions that the Player Character must meet in order for the Verb to act.
prettyname :String

Defined in: adventure/dictionary/Verb.js, line 182

Inherited from: adventurejs.Verb#prettyname

String provided in verb definition file. The prettyname is used for printing, and can include spaces, ie ask prints as "ask about".
requires_number :String

Defined in: adventure/dictionary/Phrase.js, line 48

Inherited from: adventurejs.Verb#requires_number

Currently unused.
requires_string :String

Defined in: adventure/dictionary/Phrase.js, line 34

Inherited from: adventurejs.Verb#requires_string

Currently unused.
state :String

Defined in: adventure/dictionary/Verb.js, line 198

Inherited from: adventurejs.Verb#state

state is an optional property for verbs that apply state to assets, such as close and lock. For example, "close door" will set door.is.closed to true. When used, state will contain the state to be set true on an asset. In the case of close, its state would be "closed".
state_strings :String

Defined in: adventure/dictionary/Verb.js, line 218

Inherited from: adventurejs.Verb#state_strings

state_strings is an optional property for verbs that is used to provide string substitutions for authors using the string substitution form of $(sink drain is| plugged or| unplugged). Because "unplugged" isn't a proper verb state, we'll use this as a reverse lookup to test whether the asset, sink_drain in this case, is subscribed to the relevant verb and has the specified state. state_strings only apply to direct objects.
synonyms :Getter/Setter

Defined in: adventure/dictionary/Verb.js, line 551

Inherited from: adventurejs.Verb#synonyms

Default value: []

synonyms provide alternate words for verbs, such as "get" for "take".
tryVerbFromThis :Getter

Defined in: adventure/dictionary/Verb.js, line 447

Inherited from: adventurejs.Verb#tryVerbFromThis

Returns "try[Verb]FromThis" for consistency with callAction()
tryVerbThatFromThis :Getter

Defined in: adventure/dictionary/Verb.js, line 479

Inherited from: adventurejs.Verb#tryVerbThatFromThis

Returns "try[Verb]ThatFromThis" for consistency with callAction()
tryVerbThatWithThis :Getter

Defined in: adventure/dictionary/Verb.js, line 463

Inherited from: adventurejs.Verb#tryVerbThatWithThis

Returns "try[Verb]ThatWithThis" for consistency with callAction()
tryVerbThis :Getter

Defined in: adventure/dictionary/Verb.js, line 431

Inherited from: adventurejs.Verb#tryVerbThis

Returns "try[Verb]This" for consistency with callAction()
tryVerbThisFromThat :Getter

Defined in: adventure/dictionary/Verb.js, line 471

Inherited from: adventurejs.Verb#tryVerbThisFromThat

Returns "try[Verb]ThisFromThat" for consistency with callAction()
tryVerbThisWithThat :Getter

Defined in: adventure/dictionary/Verb.js, line 455

Inherited from: adventurejs.Verb#tryVerbThisWithThat

Returns "try[Verb]ThisWithThat" for consistency with callAction()
tryVerbWithThis :Getter

Defined in: adventure/dictionary/Verb.js, line 439

Inherited from: adventurejs.Verb#tryVerbWithThis

Returns "try[Verb]WithThis" for consistency with callAction()
type :String

Defined in: adventure/dictionary/Verb.js, line 152

Inherited from: adventurejs.Verb#type

Default value: ""

May be used to help narrow verb selections in ambiguous situations.
unstate :String

Defined in: adventure/dictionary/Verb.js, line 208

Inherited from: adventurejs.Verb#unstate

unstate is an optional property for verbs that unset state from assets, such as open and unlock. For example, "open door" will set door.is.closed to false. When used, unstate will contain the state to be set false on an asset. In the case of open, its unstate would be "closed".
verb_noun_prep :Array

Defined in: adventure/dictionary/Verb.js, line 617

Inherited from: adventurejs.Verb#verb_noun_prep

Default value: []

For verb/noun pairs with a trailing preposition, or more likely a direction, such as "push bed north". When player input is parsed, they'll be concatenated, eg to "pushnorth bed".
verb_noun_prep_noun :Array

Defined in: adventure/dictionary/Verb.js, line 781

Inherited from: adventurejs.Verb#verb_noun_prep_noun

Default value: []

For verb/preposition pairs separated by another word, usually a noun, such as "lock door with key" or "take sword from stone". When player input is parsed, they'll be concatenated, eg to "lockwith door key" or "takefrom sword stone".

Though verb_prep_noun and verb_noun_prep_noun look similar, the reason they are separate fields is because we have to use different regex patterns to find each type in user input.
verb_noun_prep_noun_prep_noun :Array

Defined in: adventure/dictionary/Verb.js, line 870

Inherited from: adventurejs.Verb#verb_noun_prep_noun_prep_noun

Default value: []

For a verb phrase with three nouns and two prepositions. For example, in the phrase "tie boat to pier with rope", we're looking for "tie" and "to" and "with", and we would parse the phrase as "tietowith boat pier rope"
verb_noun_prep_prep_noun :Array

Defined in: adventure/dictionary/Verb.js, line 828

Inherited from: adventurejs.Verb#verb_noun_prep_prep_noun

Default value: []

For a verb phrase with two nouns and two prepositions. For example, in the phrase "take skateboard from under bed", we're looking for "take" and "from" and "under", and we would parse the phrase as "takefromunder skateboard bed"
verb_prep_noun :Array

Defined in: adventure/dictionary/Verb.js, line 658

Inherited from: adventurejs.Verb#verb_prep_noun

Default value: []

For verb/preposition pairs separated by a space, such as "go to" or "look at". When player input is parsed, they'll be concatenated, eg "go to" to "goTo".
verb_prep_noun_prep_noun :Array

Defined in: adventure/dictionary/Verb.js, line 575

Inherited from: adventurejs.Verb#verb_prep_noun_prep_noun

Default value: []

For phrases like "jump from branch to vine" or "look at sun with glasses", where we have a verb + preposition followed by a noun and then another preposition
verb_prep_noun_prep_noun_prep_noun :Array

Defined in: adventure/dictionary/Verb.js, line 916

Inherited from: adventurejs.Verb#verb_prep_noun_prep_noun_prep_noun

Default value: []

For a verb phrase with three nouns and three prepositions. For example, in the phrase "swing from branch to tree on vine", we're looking for "swing from with on".
verb_prep_prep_noun :Array

Defined in: adventure/dictionary/Verb.js, line 699

Inherited from: adventurejs.Verb#verb_prep_prep_noun

Default value: []

For compound preps separated by spaces, verb/prep/prep, such as "get out of"
verb_prep_prep_prep_noun :Array

Defined in: adventure/dictionary/Verb.js, line 740

Inherited from: adventurejs.Verb#verb_prep_prep_prep_noun

Default value: []

For three part compound preps, verb/prep/prep/prep, such as "get out from behind"