Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0
// setIs.js
(function () {
  /*global adventurejs A*/
  var p = adventurejs.Tangible.prototype;

  /**
   * Set asset.is.state.
   * @memberOf adventurejs.Tangible
   * @method adventurejs.Tangible#setIs
   * @param {Boolean} bool
   */
  p.setIs = function Tangible_setIs(state, bool = true) {
    if ("string" !== typeof state) return;
    this.is[state] = bool;

    if (this.linked_asset) {
      let linked_asset = this.game.getAsset(this.linked_asset);
      linked_asset.is[state] = bool;
    }

    if (state === "known" && this.aspects) {
      if (this.setAllAspectsContentsKnown) {
        this.setAllAspectsContentsKnown(bool);
      }
      if (this.getVessel) {
        let vessel = this.getVessel();
        if (vessel?.know_with_parent) vessel.known = true;
      }
    }

    return this.is[state];
  };
})();