Class: Game


# Game

The Game class provides some helper functions that the player can use to his/her advantage while playing the game and building paths.

This class also provides a reference to the log class.

This class also contains the stats of the game (how much time has passed, how many passengers have been delivered).

Constructor

# new Game ()




# Members

# Game.log {}

Description

Use this property to get a reference to the console (at the bottom of the screen) and to write to it. View the below example for use cases.

Example

You have to specify a logging level to write, as exemplified below

game.log.error("This is a error message");
game.log.debug("This is a debug message");
game.log.success("This is a success message");



# Game.elapsedTimeSeconds {Integer}

Type: Integer
Description

Time the level has been running, in seconds.




# Game.elapsedTimeMS {Integer}

Type: Integer
Description

Time the level has been running, in ms.




# Game.passengersDelivered {Integer}

Type: Integer
Description

Quantity of passengers already delivered.




# Methods

# Game.GetRoadBetween (cityA, cityB)

Parameters:
Name Type Description
cityA City

The "from" city

cityB City

The "to" city

Description

Use this method to get the Road that runs from cityA to cityB.

Returns undefined if there's no Road between them.




# Game.GetTimeBetween (cityA, cityB)

Parameters:
Name Type Description
cityA City

The "from" city

cityB City

The "to" city

Description

This is a shortcut to get the time to travel between two cities.

Use this method to get the travel time from the Road that runs from cityA to cityB.

This method returns Infinity if there's no Road from cityA to cityB.




# Game.GetCity (id)

Parameters:
Name Type Description
id string

City's id.

Description

Use this method to get a City instance by its ID ("A" to "Z").

This method returns undefined if there's no City with the specified ID.