Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0
// UID.js
(function () {
  /*global adventurejs A*/

  /**
   *
   * @class adventurejs.UID
   * @ajsnavheading FrameworkReference
   * @ajsinternal
   * @summary Generates sequential unique ID numbers.
   * @classdesc
   * <p>
   * Global utility for generating sequential unique ID numbers.
   * The UID class uses a static interface (ex.
   * <code class="property">UID.get()</code>)
   * and should not be instantiated.
   * </p>
   * <p>
   * Shamelessly cribbed from
   * <a href="https://www.createjs.com/">create.js</a> by
   * <a href="https://gskinner.com/">gskinner</a>
   * </p>
   */
  function UID() {
    throw "UID cannot be instantiated";
  }

  // private static properties:
  /**
   * @method adventurejs.UID#_nextID
   * @memberOf adventurejs.UID
   * @type Number
   * @protected
   **/
  UID._nextID = 0;

  // public static methods:
  /**
   * Returns the next unique id.
   * @method adventurejs.UID#get
   * @memberOf adventurejs.UID
   **/
  UID.get = function UID_get() {
    return "_" + UID._nextID++;
  };

  adventurejs.UID = UID;
})();