///
///
///
var MapsHandlr;
(function (MapsHandlr_1) {
"use strict";
/**
* Map manipulator and spawner for GameStartr maps that is the front-end
* counterpart to MapsCreatr. PreThing listings are loaded from Maps stored in a
* MapsCreatr and added or removed from user input. Area properties are given to
* a MapScreenr when a new Area is loaded.
*/
var MapsHandlr = (function () {
/**
* @param {IMapsHandlrSettings} settings
*/
function MapsHandlr(settings) {
if (!settings) {
throw new Error("No settings given to MapsHandlr.");
}
// Maps themselves should have been created in the MapsCreator object
if (!settings.MapsCreator) {
throw new Error("No MapsCreator provided to MapsHandlr.");
}
this.MapsCreator = settings.MapsCreator;
// Map/Area attributes will need to be stored in a MapScreenr object
if (!settings.MapScreener) {
throw new Error("No MapScreener provided to MapsHandlr.");
}
this.MapScreener = settings.MapScreener;
this.onSpawn = settings.onSpawn;
this.onUnspawn = settings.onUnspawn;
this.screenAttributes = settings.screenAttributes || [];
this.stretchAdd = settings.stretchAdd;
this.afterAdd = settings.afterAdd;
this.commandScope = settings.commandScope;
}
/* Simple gets
*/
/**
* @return {MapsCreatr} The internal MapsCreator.
*/
MapsHandlr.prototype.getMapsCreator = function () {
return this.MapsCreator;
};
/**
* @return {MapScreenr} The internal MapScreener.
*/
MapsHandlr.prototype.getMapScreener = function () {
return this.MapScreener;
};
/**
* @return {String[]} The attribute names to be copied to MapScreener.
*/
MapsHandlr.prototype.getScreenAttributes = function () {
return this.screenAttributes;
};
/**
* @return {String} The key by which the current Map is indexed.
*/
MapsHandlr.prototype.getMapName = function () {
return this.mapName;
};
/**
* Gets the map listed under the given name. If no name is provided, the
* mapCurrent is returned instead.
*
* @param {String} [name] An optional key to find the map under.
* @return {Map}
*/
MapsHandlr.prototype.getMap = function (name) {
if (name === void 0) { name = undefined; }
if (typeof name !== "undefined") {
return this.MapsCreator.getMap(name);
}
else {
return this.mapCurrent;
}
};
/**
* Simple getter pipe to the internal MapsCreator.getMaps() function.
*
* @return {Object