Player12
An open source football management simulator
Loading...
Searching...
No Matches
formation.cpp File Reference
#include "gui/view_models/formation.h"
#include <algorithm>
#include <cmath>
#include "model/lineup.h"
#include "model/player.h"

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.
 

Variables

const std::array< Preset, 5 > Formation::PRESETS
 4-4-2, 4-3-3, 4-2-3-1, 3-5-2 and 5-3-2.