# Class: Lineup

## Lineup()

Model representing a starting lineup/bench configuration for a given team. These will have copies frozen for each week that progresses.

## Constructor

#### new Lineup()

Source:
  - app/models/Lineup.model.js, line 8

### Extends

- Model

### Methods

#### (async, static) get_and_update_for_team(team) → {Promise.<Lineup>}

Given a team, fetch the latest draft lineup for that team. This will also update the lineup record so that it includes all players currently on the team (benching any players not already in the lineup). If no lineup exists, one will be created.

##### Parameters:

Name | Type | Description
--- | --- | ---
`team` | Team |

Source:
  - app/models/Lineup.model.js, line 60

##### Returns:

Type
  Promise.<Lineup>

#### bench_player(player)

Removes the player from the starting lineup if they are there and adds them to the bench if they aren't already there.

##### Parameters:

Name | Type | Description
--- | --- | ---
`player` | Player |

Source:
  - app/models/Lineup.model.js, line 149

#### (async) calculate_fantasy_points() → {Promise.<number>}

Calculate the fantasy points scored by the starting players on this lineup.

Source:
  - app/models/Lineup.model.js, line 39

##### Returns:

Type
  Promise.<number>

#### clear_lineup()

Remove all players from the bench and the starting lineup.

Source:
  - app/models/Lineup.model.js, line 169

#### has_bench_player(player) → {boolean}

Returns true if the given player is on the bench in this lineup.

##### Parameters:

Name | Type | Description
--- | --- | ---
`player` | Player |

Source:
  - app/models/Lineup.model.js, line 122

##### Returns:

Type
  boolean

#### has_player(player) → {boolean}

Returns true if the given player is in this lineup anywhere.

##### Parameters:

Name | Type | Description
--- | --- | ---
`player` | Player |

Source:
  - app/models/Lineup.model.js, line 140

##### Returns:

Type
  boolean

#### has_starting_player(player) → {boolean}

Returns true if the given player is on the starting lineup in this lineup.

##### Parameters:

Name | Type | Description
--- | --- | ---
`player` | Player |

Source:
  - app/models/Lineup.model.js, line 131

##### Returns:

Type
  boolean

#### (async) players_in_starting() → {Promise.<Array.<Model>>}

Returns an array of Players that are on the starting lineup.

Source:
  - app/models/Lineup.model.js, line 108

##### Returns:

Type
  Promise.<Array.<Model>>

#### (async) players_on_bench() → {Promise.<Array.<Model>>}

Returns an array of Players that are on the bench for this lineup.

Source:
  - app/models/Lineup.model.js, line 95

##### Returns:

Type
  Promise.<Array.<Model>>

#### start_player(player_position_record)

Given the player_id/position record, add it to the starting lineup.

##### Parameters:

Name | Type | Description
--- | --- | ---
`player_position_record` | object |

Source:
  - app/models/Lineup.model.js, line 160

#### (async) to_api() → {Promise.<object>}

Cast the lineup to an object which can be returned via the API.

Source:
  - app/models/Lineup.model.js, line 178

##### Returns:

Type
  Promise.<object>