Class: City


# City

Every city on the map is an instance of the City class. Cities may contain Passengers and Vehicles.

Constructor

# new City ()

Example

Example of setting up an event handler that is triggered whenever a city gets a new Passenger.

function init (vehicles, cities, passengers, game) {

   let city = city[0];

   city.on('newPassenger', function(passenger) {
     // perhaps move a vehicle here??
   });
} 



# Members

# City.id {string}

constant

Type: string
Description

City's id (may be between "A" and "Z").




# City.passengers {Array.<Passenger>}

Type: Array.<Passenger>
Description

List of Passengers currently waiting to be delivered.




# City.roads {Array.<Road>}

constant

Type: Array.<Road>
Description

List of Roads that run from this city to other cities.




# City.connectedCities {Array.<City>}

constant

Type: Array.<City>
Description

List of cities that this city connects to by its Roads




# Events

# City.on:newPassenger

Parameters:
Name Type Description
name 'newPassenger'

Name of this event

onNewPassenger function

Function that is called when this this city gets a new Passenger, receives as argument the Passenger.

Description

Event that is triggered whenever this city gets a new Passenger. It's not triggered when a car delivers a passenger.

Example
function init (vehicles, cities, passengers, game) {
   let city = cities[0];
   city.on('newPassenger', function(passenger) {
     // do something?
   });
}