Class: module:common/game-map/GameMap

module:common/game-map/GameMap()

A map for a game

Constructor

new module:common/game-map/GameMap()

Constructor is private. See GameMap.parse or GameMap.generate for instances of GameMap
Properties:
Name Type Description
id string Unique id for this map
theme string The theme for this map
rooms Array.<Room> The rooms in the map
items Array.<Item> The items in this map
players Array.<Player> The players in this map
Source:

Methods

(static) generate(map, params) → {GameMap}

Geneate a game map
Parameters:
Name Type Description
map GameMap The game map to store everything in
params object The game map generation parameters for the game map
Source:
Returns:
Type
GameMap

(static) parse(json, map) → {GameMap}

Parse a previously serialized map
Parameters:
Name Type Description
json string | object The serialized map
map GameMap The game map to use
Source:
Returns:
Type
GameMap

(static) register(renderer)

Regester a renderer for rooms and corridors
Parameters:
Name Type Description
renderer Renderer The renderer to use
Source:

getRect(x, y) → {Room|Corridor}

Get the room of corridor that contains the x, y corrdinate otherwise return undefined
Parameters:
Name Type Description
x number
y number
Source:
Returns:
Type
Room | Corridor

getSpawnPoint() → {object}

Get the spawn point for a player
Source:
Returns:
{x,y}
Type
object

isOnMap(x, y, isMonster) → {boolean}

Check if a point is on the map/floor
Parameters:
Name Type Description
x number
y number
isMonster boolean
Source:
Returns:
Type
boolean

serialize() → {string}

Serialize the game map
Source:
Returns:
The serialized map
Type
string

Type Definitions

Renderer

A room and corridor renderer
Properties:
Name Type Description
name string The name of the renderer
canRender function Can this render the room or corridor that is passed in
render function Render the actual room or corridor
Source: