Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Building<ForkName, StairName>

This is the class that we use to define a building. See README.md for a tutorial on how to create a Building.

Note on TypeScript usage: It is recommended that you supply your own types for the generic type parameters ForkName and StairName. See README.md for an example.

Type parameters

  • ForkName: string

    The type of string that a node ID for a Room or Fork may use.

  • StairName: string

    The type of string that a node ID for Stairs may use.

Hierarchy

  • Building

Index

Important

constructor

  • new Building(hallways: Hallway<ForkName, StairName>[], __namedParameters?: { oneWayStaircases: {} }, allowedConnections?: (StairName | ForkName)[]): Building
  • category

    Important

    Parameters

    • hallways: Hallway<ForkName, StairName>[]

      All of the hallways in this building

    • Default value __namedParameters: { oneWayStaircases: {} } = {}
      • oneWayStaircases: {}

        An object representing all of the one way staircases in the building. For example, if stairA is one-way and only down, it would be { stairA: "down" }.

    • Default value allowedConnections: (StairName | ForkName)[] = hallways.flatMap(h =>h.nodes.map(n => n.nodeId).filter((nodeId): nodeId is ForkNode<ForkName> | StairNode<StairName> =>!(nodeId instanceof BasicRoomNode)).map(nodeId => nodeId.name))

    Returns Building

Readonly roomsList

roomsList: string[]

An array of all of the names and aliases for all of the rooms

getDirections

  • getDirections(from: string, to: string, __namedParameters?: { capitalize: boolean; periods: boolean }): string | null
  • This is the method that tells you how to get from one room to another in a building.

    Parameters

    • from: string

      The name of the starting room

    • to: string

      The name of the destination room

    • Default value __namedParameters: { capitalize: boolean; periods: boolean } = {capitalize: true,periods: false,}
      • capitalize: boolean

        Whether to capitalize the beginning of every line

      • periods: boolean

        Whether to add a period at the end of every instruction

    Returns string | null

    The directions to get from room from to room to

Other

Readonly allowedConnections

allowedConnections: (StairName | ForkName)[]

Readonly graph

graph: {}

The graph that is generated from the nodes in the hallways and the connections between them

Type declaration

  • [key: string]: {}
    • [key: string]: number

Readonly hallways

hallways: Hallway<ForkName, StairName>[]

All of the hallways in this building

Readonly oneWayStaircases

oneWayStaircases: Partial<Record<StairName, StairOneWay>>

getHallwayIndexAndIndex

  • getHallwayIndexAndIndex(name: string): [] | null
  • Parameters

    • name: string

      The name of the room

    Returns [] | null

    An array, where the first element is the index of the hallway where the room is located, and the second element is the index of the room in the hallway. If the room doesn't exist, returns null.

isValidRoomName

  • isValidRoomName(name: string): boolean
  • cateogry

    Important

    Parameters

    • name: string

      A possible name for a room in this building

    Returns boolean

    true if there is a room with the name or alias name, and false otherwise.

withAllowedConnectionTypes

  • withAllowedConnectionTypes(allowedConnections: (StairName | ForkName)[] | ((name: string) => boolean)): Building<ForkName, StairName>
  • Parameters

    • allowedConnections: (StairName | ForkName)[] | ((name: string) => boolean)

    Returns Building<ForkName, StairName>

Generated using TypeDoc