Pre-release
AdventureJS Docs Downloads Bundler Devlog Score: 0 Moves: 0
// incrementDoVerbCount.js
(function () {
  /* global AdventureJS A */
  var p = AdventureJS.Assets.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.Assets.Asset#incrementDoVerbCount
   * @memberOf AdventureJS.Assets.Asset
   * @param {String} verb
   * @param {String} ov "dov" or "iov" representing a direct or indirect object.
   *
   */
  p.incrementDoVerbCount = function Asset_incrementDoVerbCount(verb, ov) {
    var other_side;
    if (this.other_side) {
      /** @TODO replace other_side with a method to get any linked assets */
      other_side = this.game.getAsset(this.other_side);
    }

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

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

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