Pre-release
Adventure.js Docs Downloads
Score: 0 Moves: 0
// IOVhasMaxConnections.js
(function() {
	/*global adventurejs A*/ 
  "use strict";
  var p = adventurejs.Asset.prototype;	
  /**
   * Get whether the IOV has maximum connections.
   * @memberOf adventurejs.Asset
	 * @method adventurejs.Asset#IOVhasMaxConnections
   * @param {String} verb The name of a verb.
   * @return {Boolean}
   */
  p.IOVhasMaxConnections = function Asset_IOVhasMaxConnections(verb) 
  {
    // no verb or not DOV, not max
    if( !verb || !this.game.dictionary.verbs[verb] ) return true;
    if( !this.iov[verb] ) return true;

    // no connections at all? is max
    if( !this.iov[verb].with_params.connections ) return true;

    // no max connections set? not max
    if( "undefined" === typeof this.iov[verb].with_params.max_connections ) return false;

    // max greater than actual? not max
    if( this.iov[verb].with_params.max_connections >= 
    this.iov[verb].with_params.connections.length )
    {
      return false;
    }

    // assume it's max
    return true;
  }
}());