Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Hallway<ForkName, StairName>

This class represents a single hallway. The hallway may have turns, but if you need a fork, you need to add another Hallway to the list and connect them with 2 Forks.

Type parameters

  • ForkName: string

  • StairName: string

Hierarchy

Index

Constructors

constructor

  • new Hallway(partList: (Turn | Room<ForkName> | Stairs<StairName>)[], __namedParameters?: { allowFrontConnectionsInMiddle: boolean; oneWay: false | "forward" | "backward" }): Hallway
  • Parameters

    • partList: (Turn | Room<ForkName> | Stairs<StairName>)[]

      An array of every Room, Stairs, or Turn in the hallway. You can choose arbitrarily which end of the hallway to start at, but make sure to keep the sides and directions of the Rooms, Stairs, and Turns consistent with the direction you choose as forward.

    • Default value __namedParameters: { allowFrontConnectionsInMiddle: boolean; oneWay: false | "forward" | "backward" } = {}
      • allowFrontConnectionsInMiddle: boolean

        If true, this hallway may have [[Rooms]] and Stairs that are not at the ends of the hallway, but are marked as FRONT. This is used by isValidBuilding.

      • oneWay: false | "forward" | "backward"

        false if you can travel both ways in this hallway. "forward" if you can only travel from the first to the last element of this hallway. "backward" if you can only travel from the last element to the first.

    Returns Hallway

Properties

Readonly allowFrontConnectionsInMiddle

allowFrontConnectionsInMiddle: boolean

Readonly oneWay

oneWay: OneWay

partList

partList: (Turn | Room<ForkName> | Stairs<StairName>)[]

An array of every Room, Stairs, or Turn in the hallway. You can choose arbitrarily which end of the hallway to start at, but make sure to keep the sides and directions of the Rooms, Stairs, and Turns consistent with the direction you choose as forward.

Accessors

nodes

  • get nodes(): { edgeLengthFromPreviousNodeInHallway: number; nodeId: Node<ForkName, StairName> }[]
  • An array of all of the node IDs in this hallway.

    Returns { edgeLengthFromPreviousNodeInHallway: number; nodeId: Node<ForkName, StairName> }[]

Methods

getDirectionsFromIndices

  • getDirectionsFromIndices(from: number, to: number, __namedParameters: { entranceWasStraight: boolean; isBeginningOfDirections: boolean; isEndOfDirections: boolean }): string
  • Gives the directions to get from one room to another in a single hallway given the indices of the rooms in the hallway.

    Parameters

    • from: number

      The index of the starting room

    • to: number

      The index of the room to go to

    • __namedParameters: { entranceWasStraight: boolean; isBeginningOfDirections: boolean; isEndOfDirections: boolean }
      • entranceWasStraight: boolean

        When we entered this hallway, were we going straight (as opposed to turning left or right into this hallway)? (not applicable if isBeginningOfDirections is true; in this case, the argument is ignored)

      • isBeginningOfDirections: boolean

        Are these directions the first set of directions in the whole set of directions created in Building.getDirections?

      • isEndOfDirections: boolean

        Are these directions the last set of directions in the whole set of directions created in Building.getDirections?

    Returns string

    The directions. Steps are separated with newlines.

getRoomInd

  • getRoomInd(name: string): number
  • Parameters

    • name: string

    Returns number

    The index of the room, or -1 if there's no room with that name

idOfClosestNodeToIndex

  • idOfClosestNodeToIndex(roomInd: number, allowedConnections: (ForkName | StairName)[]): Node<ForkName, StairName>
  • Parameters

    • roomInd: number

      The index of the room in this hallway

    • allowedConnections: (ForkName | StairName)[]

    Returns Node<ForkName, StairName>

    The id of the "closest" node to the given room within this hallway

Generated using TypeDoc