Player12
An open source football management simulator
Loading...
Searching...
No Matches
match_changes.cpp File Reference
#include "match_changes.h"
#include <algorithm>
#include <cmath>
#include <cstddef>
#include <limits>
#include "model/match_tuning.h"
#include "model/player.h"

Namespaces

namespace  MatchChanges
 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.
 

Functions

const char * MatchChanges::refusalKey (Refusal refusal)
 Language key explaining a refusal (LIMIT and WINDOWS take d).
 
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.
 
int MatchChanges::maxSubstitutions (const MatchEngine &engine)
 Substitutions a side may make in this match (one more in ET).
 
int MatchChanges::maxWindows (const MatchEngine &engine)
 Substitution windows of a side in this match (one more in ET).
 
bool MatchChanges::atStoppage (const MatchEngine &engine)
 Play is stopped: planned changes can be made without waiting.
 
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).
 
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.
 
bool MatchChanges::sameSliders (const StrategySliders &left, const StrategySliders &right)
 Every slider within a small tolerance.
 
int MatchChanges::detectTacticPreset (const StrategySliders &sliders)
 Index of the preset with these sliders, or -1 (custom).
 
int MatchChanges::detectFormation (std::span< const Vector2F > shape)
 Index of the formation preset with this shape, or -1 (custom).
 
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.
 
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).