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

Touchline decisions of the live match, independent of the widgets: planned substitutions made together at a stoppage, the assistant's suggestions, tactical presets, formation changes and the shouts on offer. More...

Classes

struct  PlannedSubstitution
 One planned substitution. More...
 
struct  ShoutInfo
 One touchline shout: its labels and keyboard slot. More...
 
struct  SliderInfo
 One strategy slider: label, help and the member it edits. More...
 
struct  SubstitutionOutcome
 Result of one planned change once it was attempted. More...
 
class  SubstitutionPlan
 Substitutions queued by the manager and made together, so they share one stoppage and one window. More...
 
struct  Suggestion
 The assistant's proposal: replace out with in. More...
 
struct  TacticPreset
 A named set of the five strategy sliders. More...
 

Enumerations

enum class  Refusal : std::uint8_t {
  NONE , MATCH_OVER , LIMIT , WINDOWS ,
  NOT_NOW , NOT_ON_PITCH , NOT_ON_BENCH , ALREADY_PLAYED ,
  ALREADY_PLANNED
}
 Why a change cannot be made (NONE when it can). More...
 
enum  SuggestionReason : std::uint8_t { SUGGEST_INJURED = 1U << 0U , SUGGEST_TIRED = 1U << 1U , SUGGEST_BOOKED = 1U << 2U }
 Reasons behind a suggested substitution (bit flags). More...
 

Functions

const char * refusalKey (Refusal refusal)
 Language key explaining a refusal (LIMIT and WINDOWS take d).
 
Refusal rulesRefusal (const MatchEngine &engine, bool home, int planned)
 Refusal from the match rules alone (limit, windows, full time) for one more change when planned changes are already waiting.
 
int maxSubstitutions (const MatchEngine &engine)
 Substitutions a side may make in this match (one more in ET).
 
int maxWindows (const MatchEngine &engine)
 Substitution windows of a side in this match (one more in ET).
 
bool atStoppage (const MatchEngine &engine)
 Play is stopped: planned changes can be made without waiting.
 
float positionFit (PlayerRole substitute, PlayerRole position)
 Suitability of a substitute for the outgoing player's position in [0, 1] (the natural role fit, see Formation::roleFit).
 
std::vector< Suggestion > suggestSubstitutions (const MatchEngine &engine, bool home, std::span< const Player *const > bench, const SubstitutionPlan &plan, const StatsConfig &config, std::size_t maximum)
 Up to maximum substitutions the assistant would make now: injured players first, then tired ones and booked defenders or midfielders late in the game, each with the best free substitute for the position (goalkeepers only for goalkeepers). Players already in the plan are left out; nothing is suggested when no change is allowed.
 
bool sameSliders (const StrategySliders &left, const StrategySliders &right)
 Every slider within a small tolerance.
 
int detectTacticPreset (const StrategySliders &sliders)
 Index of the preset with these sliders, or -1 (custom).
 
int detectFormation (std::span< const Vector2F > shape)
 Index of the formation preset with this shape, or -1 (custom).
 
std::vector< Vector2F > formationFor (const MatchEngine &engine, bool home, const Formation::Preset &preset)
 The side's current shape rearranged as preset: each occupied slot gets the preset position that best suits its player (natural role first, then the nearest spot), empty slots take what is left. Returns the current shape unchanged when it does not have ten slots.
 
float reshapeCost (std::span< const Vector2F > from, std::span< const Vector2F > to)
 Tactical familiarity the side gives up for a while when its shape changes from from to to, in [0, 1] (the engine's reshape rule).
 

Variables

constexpr std::array< TacticPreset, 4 > TACTIC_PRESETS
 Balanced, front foot, counter and control.
 
constexpr std::array< SliderInfo, 5 > TACTIC_SLIDERS
 
constexpr std::array< ShoutInfo, 11 > SHOUTS
 Every shout, in bar order (Shift+1 .. Shift+0, Shift+-).
 

Detailed Description

Touchline decisions of the live match, independent of the widgets: planned substitutions made together at a stoppage, the assistant's suggestions, tactical presets, formation changes and the shouts on offer.

Every change goes through the engine, which owns the rules; the plan only explains in advance why a change would be refused.

Enumeration Type Documentation

◆ Refusal

enum class MatchChanges::Refusal : std::uint8_t
strong

Why a change cannot be made (NONE when it can).

Enumerator
NONE 
MATCH_OVER 
LIMIT 

Every substitution is used (counting the planned ones).

WINDOWS 

Every substitution window is used (half-time changes are free).

NOT_NOW 

The engine does not allow a change at this moment (shootout).

NOT_ON_PITCH 

The outgoing player is no longer on the pitch.

NOT_ON_BENCH 

The incoming player is not among the substitutes.

ALREADY_PLAYED 

The substitute has already played (no re-entry).

ALREADY_PLANNED 

One of the two players is already part of a planned change.

◆ SuggestionReason

enum MatchChanges::SuggestionReason : std::uint8_t

Reasons behind a suggested substitution (bit flags).

Enumerator
SUGGEST_INJURED 
SUGGEST_TIRED 
SUGGEST_BOOKED 

Function Documentation

◆ atStoppage()

bool MatchChanges::atStoppage ( const MatchEngine &  engine)

Play is stopped: planned changes can be made without waiting.

◆ detectFormation()

int MatchChanges::detectFormation ( std::span< const Vector2F >  shape)

Index of the formation preset with this shape, or -1 (custom).

◆ detectTacticPreset()

int MatchChanges::detectTacticPreset ( const StrategySliders &  sliders)

Index of the preset with these sliders, or -1 (custom).

◆ formationFor()

std::vector< Vector2F > MatchChanges::formationFor ( const MatchEngine &  engine,
bool  home,
const Formation::Preset &  preset 
)

The side's current shape rearranged as preset: each occupied slot gets the preset position that best suits its player (natural role first, then the nearest spot), empty slots take what is left. Returns the current shape unchanged when it does not have ten slots.

◆ maxSubstitutions()

int MatchChanges::maxSubstitutions ( const MatchEngine &  engine)

Substitutions a side may make in this match (one more in ET).

◆ maxWindows()

int MatchChanges::maxWindows ( const MatchEngine &  engine)

Substitution windows of a side in this match (one more in ET).

◆ positionFit()

float MatchChanges::positionFit ( PlayerRole  substitute,
PlayerRole  position 
)

Suitability of a substitute for the outgoing player's position in [0, 1] (the natural role fit, see Formation::roleFit).

◆ refusalKey()

const char * MatchChanges::refusalKey ( Refusal  refusal)

Language key explaining a refusal (LIMIT and WINDOWS take d).

◆ reshapeCost()

float MatchChanges::reshapeCost ( std::span< const Vector2F >  from,
std::span< const Vector2F >  to 
)

Tactical familiarity the side gives up for a while when its shape changes from from to to, in [0, 1] (the engine's reshape rule).

◆ rulesRefusal()

Refusal MatchChanges::rulesRefusal ( const MatchEngine &  engine,
bool  home,
int  planned 
)

Refusal from the match rules alone (limit, windows, full time) for one more change when planned changes are already waiting.

◆ sameSliders()

bool MatchChanges::sameSliders ( const StrategySliders &  left,
const StrategySliders &  right 
)

Every slider within a small tolerance.

◆ suggestSubstitutions()

std::vector< Suggestion > MatchChanges::suggestSubstitutions ( const MatchEngine &  engine,
bool  home,
std::span< const Player *const >  bench,
const SubstitutionPlan &  plan,
const StatsConfig &  config,
std::size_t  maximum 
)

Up to maximum substitutions the assistant would make now: injured players first, then tired ones and booked defenders or midfielders late in the game, each with the best free substitute for the position (goalkeepers only for goalkeepers). Players already in the plan are left out; nothing is suggested when no change is allowed.

Variable Documentation

◆ SHOUTS

constexpr std::array<ShoutInfo, 11> MatchChanges::SHOUTS
inlineconstexpr
Initial value:
{{
{MatchShout::ENCOURAGE, "SHOUT_ENCOURAGE", "SHOUT_ENCOURAGE_HINT"},
{MatchShout::DEMAND_MORE, "SHOUT_DEMAND_MORE", "SHOUT_DEMAND_MORE_HINT"},
{MatchShout::CALM_DOWN, "SHOUT_CALM_DOWN", "SHOUT_CALM_DOWN_HINT"},
{MatchShout::PUSH_HIGHER, "SHOUT_PUSH_HIGHER", "SHOUT_PUSH_HIGHER_HINT"},
{MatchShout::DROP_DEEPER, "SHOUT_DROP_DEEPER", "SHOUT_DROP_DEEPER_HINT"},
{MatchShout::PRESS_MORE, "SHOUT_PRESS_MORE", "SHOUT_PRESS_MORE_HINT"},
{MatchShout::STAND_OFF, "SHOUT_STAND_OFF", "SHOUT_STAND_OFF_HINT"},
{MatchShout::KEEP_POSSESSION, "SHOUT_KEEP_POSSESSION",
"SHOUT_KEEP_POSSESSION_HINT"},
{MatchShout::HIT_ON_COUNTER, "SHOUT_HIT_ON_COUNTER",
"SHOUT_HIT_ON_COUNTER_HINT"},
{MatchShout::WORK_BALL_INTO_BOX, "SHOUT_WORK_BALL_INTO_BOX",
"SHOUT_WORK_BALL_INTO_BOX_HINT"},
{MatchShout::SHOOT_ON_SIGHT, "SHOUT_SHOOT_ON_SIGHT",
"SHOUT_SHOOT_ON_SIGHT_HINT"},
}}
@ WORK_BALL_INTO_BOX

Every shout, in bar order (Shift+1 .. Shift+0, Shift+-).

◆ TACTIC_PRESETS

constexpr std::array<TacticPreset, 4> MatchChanges::TACTIC_PRESETS
inlineconstexpr
Initial value:
{{
{"TACTIC_BALANCED",
"TACTIC_BALANCED_HELP",
{0.50f, 0.50f, 0.50f, 0.50f, 0.50f}},
{"TACTIC_FRONT_FOOT",
"TACTIC_FRONT_FOOT_HELP",
{0.82f, 0.72f, 0.76f, 0.68f, 0.64f}},
{"TACTIC_COUNTER",
"TACTIC_COUNTER_HELP",
{0.38f, 0.68f, 0.62f, 0.58f, 0.42f}},
{"TACTIC_CONTROL",
"TACTIC_CONTROL_HELP",
{0.62f, 0.34f, 0.44f, 0.72f, 0.72f}},
}}

Balanced, front foot, counter and control.

◆ TACTIC_SLIDERS

constexpr std::array<SliderInfo, 5> MatchChanges::TACTIC_SLIDERS
inlineconstexpr
Initial value:
{{
{"STRATEGY_PRESSING", "pressing", &StrategySliders::pressing,
"TACTIC_PRESSING_HELP"},
{"STRATEGY_RISK_TAKING", "risk", &StrategySliders::riskTaking,
"TACTIC_RISK_HELP"},
{"STRATEGY_OFFENSIVE_BIAS", "offensive", &StrategySliders::offensiveBias,
"TACTIC_OFFENSIVE_HELP"},
{"STRATEGY_WIDTH_USAGE", "width", &StrategySliders::widthUsage,
"TACTIC_WIDTH_HELP"},
{"STRATEGY_COMPACTNESS", "compactness", &StrategySliders::compactness,
"TACTIC_COMPACTNESS_HELP"},
}}
float pressing
Definition strategy.h:28
float widthUsage
Definition strategy.h:33
float compactness
Definition strategy.h:34
float riskTaking
Definition strategy.h:29
float offensiveBias
Definition strategy.h:31