Player12
An open source football management simulator
Loading...
Searching...
No Matches
formation.h File Reference
#include <array>
#include <span>
#include <unordered_set>
#include <vector>
#include "global/stats_config.h"
#include "global/types.h"

Go to the source code of this file.

Classes

struct  Formation::Slot
 One outfield slot of a formation. More...
 
struct  Formation::Preset
 A named arrangement of ten outfield slots. More...
 

Namespaces

namespace  Formation
 Formation presets and XI selection built on the Lineup API.
 

Functions

float Formation::roleFit (PlayerRole actual, PlayerRole expected)
 How well a player's natural role suits a slot role, in [0, 1]. 1 means natural; adjacent roles score partially; goalkeepers and outfield players never swap.
 
void Formation::applyPreset (Lineup &lineup, const Preset &preset, const StatsConfig &config)
 Moves the current outfield players into the preset's slots, keeping the same eleven and matching players to the slots that suit them best.
 
void Formation::autoPick (Lineup &lineup, const Preset &preset, std::span< const Player *const > squad, const StatsConfig &config)
 Chooses the best goalkeeper and ten outfield players from the squad for the preset, places them, and puts everyone else on the bench.
 
void Formation::autoPickAvailable (Lineup &lineup, const Preset &preset, std::span< const Player *const > squad, const std::unordered_set< PlayerID > &unavailable, const StatsConfig &config)
 autoPick() that leaves unavailable players (injured, suspended) out of the matchday squad (the lineup screen lists them with the rest).
 
size_t Formation::unavailableStarters (const Lineup &lineup, const std::unordered_set< PlayerID > &unavailable)
 Selected starters (goalkeeper and outfield) found in the set.
 
int Formation::detectPreset (const Lineup &lineup)
 Index of the preset matching the current positions, or -1 when the shape has been customised.