|
Player12
An open source football management simulator
|
Manages the starting XI and reserves of a team. More...
#include <lineup.h>
Classes | |
| struct | PositionedPlayer |
| struct | StandIn |
| A starter who was replaced because he could not play, and the player standing in for him until he can. More... | |
Public Member Functions | |
| Lineup () | |
| Constructs a Lineup object. | |
| void | setGoalkeeper (const Player *gk) |
| Sets the goalkeeper. | |
| const Player * | getGoalkeeper () const |
| Gets the goalkeeper. | |
| void | addOutfieldPlayer (const Player *player, Vector2F position) |
| Adds an outfield player to the pitch at the specified coordinate. | |
| bool | moveOutfieldPlayer (PlayerID playerID, Vector2F newPosition) |
| Updates the position of an existing outfield player. | |
| void | removeOutfieldPlayer (PlayerID playerID) |
| Removes an outfield player from the pitch. | |
| bool | removePlayer (PlayerID playerID) |
| Drops every reference to a player: goalkeeper, outfield slot, bench and set-piece designations. Call it before the Player object is destroyed, since the lineup holds raw pointers. | |
| bool | swapPlayers (PlayerID benchPlayerID, PlayerID pitchPlayerID) |
| Swaps a bench player with an outfield player. | |
| const std::vector< PositionedPlayer > & | getOutfieldPlayers () const |
| Gets all positioned outfield players. | |
| void | setReserves (const std::vector< const Player * > &subs) |
| Sets the substitutes. Starters and duplicates are skipped; more than MAX_SUBSTITUTES are cut down with chooseBench() (pass the candidates best first). | |
| bool | bringIn (const Player *player, PlayerID replaced) |
Puts player, who is not in the matchday squad, in place of the starter or substitute replaced, who leaves the squad. | |
| const std::vector< const Player * > & | getReserves () const |
| Gets the reserve players. | |
| void | setStrategy (const Strategy &strat) |
| Sets the strategy for this lineup. | |
| const Strategy & | getStrategy () const |
| Gets the strategy for this lineup. | |
| PlayerID | getDesignated (SetPieceDuty duty) const |
| Designated player of a duty (0 = automatic). | |
| void | setDesignated (SetPieceDuty duty, PlayerID playerID) |
| Designates a player (0 = automatic) for a duty. | |
| const SetPieceDesignations & | getDesignations () const |
| Every designation, indexed by SetPieceDuty. | |
| void | setDesignations (const SetPieceDesignations &designations) |
| Replaces every designation (persistence). | |
| const std::vector< StandIn > & | getStandIns () const |
| Stand-ins currently filling a regular's place in the XI. | |
| void | setStandIns (std::vector< StandIn > values) |
| Replaces the stand-ins (persistence, matchday fixes). | |
| std::vector< const Player * > | starters () const |
| Goalkeeper and outfield players of the XI (no null entries). | |
| bool | isStarter (PlayerID playerID) const |
| True when the player is in the starting XI. | |
| const Player * | effectiveTaker (SetPieceDuty duty) const |
| Who performs a dead-ball duty at kick-off: the designated player when he starts, otherwise the best starter for it (SetPieces::best). Leadership duties return the designated captain when he starts (the designated vice-captain stands in for an absent one), else nullptr: an automatic captain comes from the dressing-room hierarchy. | |
| std::string | toString () const |
| Converts the lineup to a string representation for debugging. | |
| void | generateStartingXI (const class GameData &gamedata, const std::vector< PlayerID > &allPlayerIDs, const StatsConfig &stats_config) |
| Generates a starting XI automatically. | |
| void | clear () |
| Clears the outfield players and goalkeeper. | |
Static Public Member Functions | |
| static std::vector< const Player * > | chooseBench (std::span< const Player *const > candidates) |
A matchday bench of at most MAX_SUBSTITUTES from candidates (best first): available players before injured ones, a reserve goalkeeper and one defender, midfielder and forward as cover, then the rest in order. | |
| static PlayerRole | roleAt (Vector2F position) |
The position a slot at position asks for: x from the own goal (defence, holding midfield, midfield, attacking midfield, attack), y from the left touchline (left flank, centre, right flank). | |
Static Public Attributes | |
| static constexpr size_t | MAX_SUBSTITUTES = 9 |
| Substitutes named for a match (the top-league norm). | |
Private Attributes | |
| const Player * | goalkeeper |
| std::vector< PositionedPlayer > | outfield_players |
| std::vector< const Player * > | reserves |
| Strategy | strategy |
| SetPieceDesignations | designations {} |
| std::vector< StandIn > | stand_ins |
Manages the starting XI and reserves of a team.
This class will manage the starting 11 of the team, the reserves, possibly changing depending on the type of competition of the next match, the strategy and tactics of the team.
| Lineup::Lineup | ( | ) |
Constructs a Lineup object.
Adds an outfield player to the pitch at the specified coordinate.
| player | Pointer to the Player object. |
| position | The position on the pitch (x, y in [0.0, 1.0]). |
Puts player, who is not in the matchday squad, in place of the starter or substitute replaced, who leaves the squad.
player is already selected or replaced is not.
|
static |
A matchday bench of at most MAX_SUBSTITUTES from candidates (best first): available players before injured ones, a reserve goalkeeper and one defender, midfielder and forward as cover, then the rest in order.
|
inline |
Clears the outfield players and goalkeeper.
| const Player * Lineup::effectiveTaker | ( | SetPieceDuty | duty | ) | const |
Who performs a dead-ball duty at kick-off: the designated player when he starts, otherwise the best starter for it (SetPieces::best). Leadership duties return the designated captain when he starts (the designated vice-captain stands in for an absent one), else nullptr: an automatic captain comes from the dressing-room hierarchy.
| void Lineup::generateStartingXI | ( | const class GameData & | gamedata, |
| const std::vector< PlayerID > & | allPlayerIDs, | ||
| const StatsConfig & | stats_config | ||
| ) |
Generates a starting XI automatically.
| gamedata | The game data containing player information. |
| allPlayerIDs | A vector of all available player IDs. |
| stats_config | The stats configuration for evaluating players. |
| PlayerID Lineup::getDesignated | ( | SetPieceDuty | duty | ) | const |
Designated player of a duty (0 = automatic).
| const SetPieceDesignations & Lineup::getDesignations | ( | ) | const |
Every designation, indexed by SetPieceDuty.
| const Player * Lineup::getGoalkeeper | ( | ) | const |
Gets the goalkeeper.
| const std::vector< Lineup::PositionedPlayer > & Lineup::getOutfieldPlayers | ( | ) | const |
Gets all positioned outfield players.
| const std::vector< const Player * > & Lineup::getReserves | ( | ) | const |
Gets the reserve players.
|
inline |
Stand-ins currently filling a regular's place in the XI.
| const Strategy & Lineup::getStrategy | ( | ) | const |
Gets the strategy for this lineup.
| bool Lineup::isStarter | ( | PlayerID | playerID | ) | const |
True when the player is in the starting XI.
Updates the position of an existing outfield player.
| playerID | The ID of the player to move. |
| newPosition | The new position on the pitch. |
| void Lineup::removeOutfieldPlayer | ( | PlayerID | playerID | ) |
Removes an outfield player from the pitch.
| playerID | The ID of the player to remove. |
| bool Lineup::removePlayer | ( | PlayerID | playerID | ) |
Drops every reference to a player: goalkeeper, outfield slot, bench and set-piece designations. Call it before the Player object is destroyed, since the lineup holds raw pointers.
|
static |
The position a slot at position asks for: x from the own goal (defence, holding midfield, midfield, attacking midfield, attack), y from the left touchline (left flank, centre, right flank).
| void Lineup::setDesignated | ( | SetPieceDuty | duty, |
| PlayerID | playerID | ||
| ) |
Designates a player (0 = automatic) for a duty.
| void Lineup::setDesignations | ( | const SetPieceDesignations & | designations | ) |
Replaces every designation (persistence).
| void Lineup::setGoalkeeper | ( | const Player * | gk | ) |
Sets the goalkeeper.
| gk | Pointer to the Player object. |
| void Lineup::setReserves | ( | const std::vector< const Player * > & | subs | ) |
Sets the substitutes. Starters and duplicates are skipped; more than MAX_SUBSTITUTES are cut down with chooseBench() (pass the candidates best first).
| subs | A vector of pointers to the reserve Player objects. |
|
inline |
Replaces the stand-ins (persistence, matchday fixes).
| void Lineup::setStrategy | ( | const Strategy & | strat | ) |
Sets the strategy for this lineup.
| strat | The strategy to set. |
| std::vector< const Player * > Lineup::starters | ( | ) | const |
Goalkeeper and outfield players of the XI (no null entries).
Swaps a bench player with an outfield player.
| benchPlayerID | The ID of the substitute. |
| pitchPlayerID | The ID of the current starting player. |
| std::string Lineup::toString | ( | ) | const |
Converts the lineup to a string representation for debugging.
|
private |
|
private |
|
staticconstexpr |
Substitutes named for a match (the top-league norm).
|
private |
|
private |
|
private |
|
private |