Pre-release
Adventure.js Docs Downloads
Score: 0 Moves: 0
// setRoomImage.js

(function() {
  /*global adventurejs A*/ 
  "use strict";

	var p = adventurejs.Display.prototype;

	/**
	 * Set Room image if there is one.
	 * @method adventurejs.Display#setRoomImage
	 * @param {String} id The id of an image in game.image_lookup.
	 * @returns {adventurejs.Display} Returns the instance the method is called on (useful for chaining calls.)
	 * @chainable
	 */
	p.setRoomImage = function Display_setRoomImage(id) 
  {
		this.imagedocks.forEach(function(dock){
      if(dock.dataset.type && dock.dataset.type.toLowerCase()==="room")
      {
        if(this.game.image_lookup[id])
        {
          dock.innerHTML = `<img src="${this.game.image_lookup[id]}" class="room_image id_${id}"/>`;
        }
        else
        { 
          dock.innerHTML = "";
        }
      }
    },this);

		return this;
	}

}());