Player12
An open source football management simulator
Loading...
Searching...
No Matches
SquadNumbers Namespace Reference

Classes

struct  Entry
 

Enumerations

enum class  Change : std::uint8_t { Changed , Swapped , Invalid }
 

Functions

constexpr bool isValid (int number)
 
void assign (std::span< Entry > squad)
 

Variables

constexpr int MIN_NUMBER = 1
 
constexpr int MAX_NUMBER = 99
 
constexpr int YOUNG_AGE = 20
 

Detailed Description

Persistent squad numbers (1-99, unique within a club's senior squad).

A new squad is numbered the traditional way: the first goalkeeper wears 1, the regulars 2-11 by position (2 right back, 3 left back, 4 and 5 centre backs, 6 holding midfielder, 7 right wing, 8 centre midfielder, 9 striker, 10 playmaker, 11 left wing), back-up goalkeepers 12, 13, 25 or 31, the other seniors 14 and up and the youngsters 30 and up. A newcomer keeps the number he wore before when it is free at his new club, otherwise he takes a free number of his position.

Enumeration Type Documentation

◆ Change

enum class SquadNumbers::Change : std::uint8_t
strong

Outcome of changing a player's squad number.

Enumerator
Changed 

Free number taken.

Swapped 

The teammate wearing it took the player's old number.

Invalid 

Not 1-99, unknown player, free agent or academy player.

Function Documentation

◆ assign()

void SquadNumbers::assign ( std::span< Entry >  squad)

Gives every player of squad a valid number, unique within the squad. Valid numbers are kept (on a clash the better player keeps his); the others are handed out best player first. A squad without any number is numbered from scratch (1-11 for the regulars, see above); in a numbered squad newcomers take their preferred number if free, else a free traditional number of their position, else a free squad number. Deterministic: depends only on the entries, not on their order.

◆ isValid()

constexpr bool SquadNumbers::isValid ( int  number)
constexpr

True for a number a player can wear (1-99).

Variable Documentation

◆ MAX_NUMBER

constexpr int SquadNumbers::MAX_NUMBER = 99
inlineconstexpr

◆ MIN_NUMBER

constexpr int SquadNumbers::MIN_NUMBER = 1
inlineconstexpr

◆ YOUNG_AGE

constexpr int SquadNumbers::YOUNG_AGE = 20
inlineconstexpr

Players up to this age without a regular place get a number from 30.