Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Fork<ForkName>

A Fork represents a connection between 2 Hallways on the same floor. (Technically, Fork is a subclass of Room, and it does not add any additional functionality to Room.)

Type parameters

  • ForkName: string

Hierarchy

  • Room<ForkName>
    • Fork

Index

Constructors

constructor

  • new Fork(side: Direction, nodeId: ForkNode<ForkName> | ForkName, destinationName: string, edgeLengthFromPreviousNodeInHallway?: number | undefined): Fork
  • Parameters

    • side: Direction

      The side of the Hallway that this Fork is on

    • nodeId: ForkNode<ForkName> | ForkName

      The node ID of this fork. This can either be a string (e.g. "myConnection") to represent a forward connection or a ForkNode (e.g. reverseConnection("myConnection")).

    • destinationName: string

      This is used when giving directions to enter this Fork.

    • Default value edgeLengthFromPreviousNodeInHallway: number | undefined = 1

    Returns Fork

Properties

aliases

aliases: string[] = []

Other names for this room. These aliases will not be used in the generated directions between rooms, but if you use an alias in Building.getDirections, it will know which room you want to go to.

destinationName

destinationName: string

This is used when giving directions to enter this Fork.

edgeLengthFromPreviousNodeInHallway

edgeLengthFromPreviousNodeInHallway: number | null | undefined = null

The edge length in the graph from the previous node in this Hallway to this node. Use this if you want to alter the directions to make it less likely that the user will be given directions that take them along that edge in the hallway.

This property has no effect if this hallway element is not a node (has no node ID).

Optional name

name: (null | string) | undefined

The name of this hallway element

Readonly nodeId

nodeId: ForkNode<ForkName> | BasicRoomNode | undefined

The node ID of the node belonging to this Room. This can be either

  • a string, like "myConnection", to represent a forward connection, or
  • a ForkNode made with reverseConnection, like reverseConnection("myConnection").

prefix

prefix: string | undefined = "room"

The prefix that should be given whenever mentioning the name of this room. The default prefix is "room", which is useful when specifying a room with a number. But if you have a room with a name such as "Library", you should change the prefix to "the" so that the directions say "the Library" instead of "room Library". Use an empty string for no prefix.

side

side: Direction

The side of the Hallway that this element is on. You should decide which side the element is on based on how you've ordered the elementss in the Hallway - that is, which direction you've arbitrarily decided is "forward."

Accessors

fullName

  • get fullName(): string

Methods

onArrive

  • onArrive(forwardOrBackward: -1 | 1, isEndOfDirections: boolean): string
  • Parameters

    • forwardOrBackward: -1 | 1

      Whether we're going forward or backward through this hallway

    • isEndOfDirections: boolean

      Is this sentence the last sentence in the whole in the whole set of directions created in Building.getDirections?

    Returns string

    What we should say when we enter this room or hallway

onLeave

  • onLeave(forwardOrBackward: -1 | 1, isBeginningOfDirections: boolean, entranceWasStraight: boolean): string
  • Parameters

    • forwardOrBackward: -1 | 1

      Whether we're going forward or backward through this hallway

    • isBeginningOfDirections: boolean

      Is this sentence the first sentence in the whole set of directions created in Building.getDirections?

    • 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)

    Returns string

    What we should say when we go out of this room or hallway

onPass

  • Parameters

    • forwardOrBackward: -1 | 1

      Whether we're going forward or backward through this hallway

    • prevRoom: HallwayElement | Turn

      The previous room

    Returns string

    What we should say when you pass this room

Generated using TypeDoc