Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0
// incrementDoVerbCount.js
(function () {
  /*global adventurejs A*/
  var p = adventurejs.Asset.prototype;
  /**
   * <strong>incrementDoVerbCount</strong> takes a verb and an object and
   * updates this asset's count of the number of times the verb has
   * acted upon it.
   * @method adventurejs.Asset#incrementDoVerbCount
   * @memberOf adventurejs.Asset
   * @param {String} verb
   * @param {String} ov "dov" or "iov" representing a direct or indirect object.
   *
   */
  p.incrementDoVerbCount = function Asset_incrementDoVerbCount(verb, ov) {
    var linked_asset;
    if (this.linked_asset) {
      /** @TODO replace linked_asset with a method to get any linked assets */
      linked_asset = this.game.getAsset(this.linked_asset);
    }

    if (ov !== "dov" && ov !== "iov") ov = "dov";
    ov = ov === "dov" ? "directly" : "indirectly";

    if (!this.did[verb]) {
      this.did[verb] = {};
    }
    if (!this.did[verb][ov]) {
      this.did[verb][ov] = 0;
    }
    this.did[verb][ov]++;

    if (linked_asset) {
      if (!linked_asset.did[verb]) {
        linked_asset.did[verb] = {};
      }
      if (!linked_asset.did[verb][ov]) {
        linked_asset.did[verb][ov] = 0;
      }
      linked_asset.did[verb][ov]++;
    }
  };
})();