// Zone.js
(function () {
/*global adventurejs A*/
"use strict";
/**
* @ajspath adventurejs.Atom.Asset.Zone
* @augments adventurejs.Asset
* @class adventurejs.Zone
* @ajsconstruct MyGame.createAsset({ "class":"Zone", "name":"foo", [...] })
* @ajsconstructedby adventurejs.Game#createAsset
* @ajsnavheading BaseClasses
* @param {String} game_name Name of top level game instance that is scoped to window.
* @param {String} name Instance name.
* @summary Set UniversalScenery descriptions for groups of Rooms.
* @tutorial NextSteps_GlobalScenery
* @tutorial CreateSceneEvents
* @classdesc
* <p>
* <strong>Zone</strong> is a low-level subclass of
* {@link adventurejs.Asset|Asset} with just a couple
* of properties: zone_events and zone_scenery. Use
* Zone to define customized sets of global Assets that
* can be shared by any number of
* {@link adventurejs.Room|Rooms}. For instance, you might
* create a desert Zone which describes a starry night sky,
* a blood moon, and exits that are blocked by
* sand dunes in every direction that hasn't got a defined
* Exit, with random gusts of blown sand and shimmering heat haze.
* </p>
* <p>
* There are three types of predefined global Assets:
* {@link adventurejs.Scenery|Scenery},
* {@link adventurejs.Wall|Walls}, and
* {@link adventurejs.Exit|Exits} (aka NoExits).
* Game comes with a number of predefined global Assets:
* {@link global_air|air},
* {@link global_moon|moon},
* {@link global_sky|sky},
* {@link global_sun|sun},
* {@link global_stars|stars},
* {@link global_ceiling|ceiling},
* {@link global_sound|sound},
* {@link global_rain|rain},
* {@link global_trees|trees}, and
* {@link global_wind|wind}; Walls for each of 12 directions; and
* NoExits for each of 18 directions. (NoExits are only called
* if the Room hasn't got an actual Exit in the given direction.)
* Scenery and Walls are disabled by default and must be
* enabled to use. NoExits are enabled by default,
* and can be disabled or customized.
* </p>
* <p>
* In addition to scenery, authors can create sets of
* random (or sequential) events that will print at any
* specified frequency. (<i>Events</i> here means in-game events,
* such as a periodic car alarm or a twinkling light, as opposed
* to JavaScript events.) A few random Room events can help to
* spice up frequently visited locations. Look to the bottom
* of the following example to see how events are set up.
* </p>
* <h3 class="examples">Example:</h3>
* <p>
* In this example, we've defined a room with its
* <code class="property">zone</code> property set
* to "Desert Zone", where we've set custom
* descriptions for a couple of Game's predefined global
* Assets, and given it some random events.
* </p>
* <pre class="display"><code class="language-javascript">MyGame.createAsset({
* class: "Room",
* name: "Eastern Sands",
* zone: "Desert Zone",
* description: "It's swelteringly hot here. ",
* exits: {
* west: "Western Sands",
* north: "Nothing but sand dunes that way. ",
* },
* });
*
* MyGame.createAsset({
* class: "Zone",
* name: "Desert Zone",
* zone_scenery:
* {
* global_sky: {
* enabled: true,
* description: "Even the sky is burnt to a pale sandy color. ",
* },
* global_sun: {
* enabled: true,
* description: "The sun burns is punishingly bright. ",
* },
* },
*
* zone_events: [
* {
* frequency: .1,
* randomize: true,
* },
* "You hear the distant shriek of a desert hawk. ",
* "A flurry of sand trickles down a nearby dune. ",
* "A shimmer of heat haze rises up from the sands. "
* ],
* });
* </code></pre>
* <p>
* To learn more about customizing global Assets, see
* <a href="/doc/NextSteps_GlobalScenery.html">Global Scenery</a>.
* </p>
* <p>
* This longer version below shows all of the available global Assets.
* It's a pretty long list and it might look intimidating, but don't panic!
* It's all optional.
* In this example, we've expanded the
* "Desert Zone" with all of the Game's predefined
* global Assets. Note where the Room has
* <code class="property">exits.west</code> set to
* an actual Exit, which overrides the west NoExit
* set in Desert Zone. Similarly, the Room has a
* custom error message set for
* <code class="property">exits.north</code>, and
* this also overrides the north NoExit set in Desert Zone.
* </p>
* <pre class="display"><code class="language-javascript">MyGame.createAsset({
* class: "Room",
* name: "Eastern Sands",
* zone: "Desert Zone",
* description: "It's swelteringly hot here. ",
* exits: {
* west: "Western Sands",
* north: "Nothing but sand dunes that way. ",
* },
* });
*
* MyGame.createAsset({
* class: "Zone",
* name: "Desert Zone",
* zone_scenery:
* {
* global_air: {
* enabled: true,
* description: "The air is hot and dry. ",
* },
* global_moon: { enabled: false,
* description: "The sun makes it impossible to see it. ",
* },
* global_sky: {
* enabled: true,
* description: "Even the sky is burnt to a pale sandy color. ",
* },
* global_sun: {
* enabled: true,
* description: "The sun burns is punishingly bright. ",
* },
* global_stars: {
* enabled: false,
* description: "Invisible under this brilliant sun. ",
* },
* global_floor: {
* enabled: true,
* description: "Endless sand. ",
* },
* global_ceiling: { enabled: false, description: "", },
* global_sound: {
* enabled: true,
* description: "You can hear a constant dry breeze. ",
* },
* global_east_wall: { enabled: false, description: "", },
* global_west_wall: { enabled: false, description: "", },
* global_north_wall: { enabled: false, description: "", },
* global_northeast_wall: { enabled: false, description: "", },
* global_northwest_wall: { enabled: false, description: "", },
* global_south_wall: {
* enabled: true,
* description: "A crumbling sandstone wall divides the entire region,
* blocking any passage to the south. ",
* },
* global_southeast_wall: {
* enabled: true,
* description: "The crumbling sandstone wall stretches away
* to the east, blocking any southeast passage. ",
* },
* global_southwest_wall: {
* enabled: true,
* descriptions: "The crumbling sandstone wall stretches away
* to the west, blocking any southwest passage. ",
* },
* global_aft_wall: { enabled: false, description: "", },
* global_port_wall: { enabled: false, description: "", },
* global_starboard_wall: { enabled: false, description: "", },
* global_fore_wall: { enabled: false, description: "", },
* global_east: {
* enabled: true,
* description: "Nothing but endless sand lies to the east. ",
* },
* global_west: {
* enabled: true,
* description: "Only trackless wastes lie to the west. ",
* },
* global_north: {
* enabled: true,
* description: "Tall dunes block passage to the north. ",
* },
* global_northeast: {
* enabled: true,
* description: "Towering dunes block any passage to the northeast. ",
* },
* global_northwest: {
* enabled: true,
* description: "Sand dunes prevent passage to the northwest. ",
* },
* global_south: {
* enabled: true,
* description: "The crumbling southern wall blocks all passage. ",
* },
* global_southeast: {
* enabled: true,
* description: "The endless sandstone wall lies southeast. ",
* },
* global_southwest: {
* enabled: true,
* description: "The sandstone wall prevents passage to the southwest. ",
* },
* global_aft: { enabled: false, description: "", },
* global_port: { enabled: false, description: "", },
* global_starboard: { enabled: false, description: "", },
* global_fore: { enabled: false, description: "", },
* },
*
* zone_events: [
* {
* frequency: .1,
* randomize: true,
* },
* "You hear the distant shriek of a desert hawk. ",
* "A flurry of sand trickles down a nearby dune. ",
* "A shimmer of heat haze rises up from the sands. "
* ],
* });
* </code></pre>
**/
class Zone extends adventurejs.Asset {
constructor(name, game_name) {
super(name, game_name);
this.class = "Zone";
this.exclude_from_lookup = true;
this.zone_events = [];
this.zone_scenery = {
global_air: { enabled: false, description: "It smells like air. " },
global_moon: { enabled: false, description: "It's the moon. " },
global_sky: { enabled: false, description: "The sky. " },
global_sun: { enabled: false, description: "The sun. " },
global_stars: { enabled: false, description: "The stars. " },
global_floor: { enabled: false, description: "The floor. " },
global_ceiling: { enabled: false, description: "The ceiling. " },
global_sound: { enabled: false, description: "No particular sound. " },
global_rain: { enabled: false, description: "A light spring rain. " },
global_wind: { enabled: false, description: "A mighty wind. " },
global_trees: {
enabled: false,
description: "Can't see the forest for 'em. ",
},
global_clouds: { enabled: false, description: "Dark clouds. " },
global_lightning: {
enabled: false,
description: "Distant lightning. ",
},
global_mountains: {
enabled: false,
description: "Snow capped mountains. ",
},
global_mountain: { enabled: false, description: "Mount Doom. " },
global_east_wall: { enabled: false, description: "The east wall. " },
global_west_wall: { enabled: false, description: "The west wall. " },
global_north_wall: { enabled: false, description: "The north wall. " },
global_northeast_wall: {
enabled: false,
description: "The northeast wall. ",
},
global_northwest_wall: {
enabled: false,
description: "The northwest wall. ",
},
global_south_wall: { enabled: false, description: "The south wall. " },
global_southeast_wall: {
enabled: false,
description: "The southeast wall. ",
},
global_southwest_wall: {
enabled: false,
description: "The southwest wall. ",
},
global_aft_wall: { enabled: false, description: "The aft wall. " },
global_port_wall: { enabled: false, description: "The port wall. " },
global_starboard_wall: {
enabled: false,
description: "The starboard wall. ",
},
global_fore_wall: { enabled: false, description: "The fore wall. " },
global_east: {
enabled: true,
description: "There's no exit to the east. ",
},
global_west: {
enabled: true,
description: "There's no exit to the west. ",
},
global_north: {
enabled: true,
description: "There's no exit to the north. ",
},
global_northeast: {
enabled: true,
description: "There's no exit to the northeast. ",
},
global_northwest: {
enabled: true,
description: "There's no exit to the northwest. ",
},
global_south: {
enabled: true,
description: "There's no exit to the south. ",
},
global_southeast: {
enabled: true,
description: "There's no exit to the southeast. ",
},
global_southwest: {
enabled: true,
description: "There's no exit to the southwest. ",
},
global_aft: {
enabled: true,
description: "There's no exit to the aft. ",
},
global_port: {
enabled: true,
description: "There's no exit to the port. ",
},
global_starboard: {
enabled: true,
description: "There's no exit to the starboard. ",
},
global_fore: {
enabled: true,
description: "There's no exit to the fore. ",
},
};
}
}
adventurejs.Zone = Zone;
})();