Player12
An open source football management simulator
Loading...
Searching...
No Matches
match_changes.h File Reference
#include <array>
#include <cstddef>
#include <cstdint>
#include <span>
#include <vector>
#include "global/stats_config.h"
#include "global/types.h"
#include "gui/view_models/formation.h"
#include "model/match_engine.h"
#include "model/strategy.h"

Go to the source code of this file.

Classes

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

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.
 

Enumerations

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

Functions

const char * MatchChanges::refusalKey (Refusal refusal)
 Language key explaining a refusal (LIMIT and WINDOWS take d).
 
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).
 
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.
 
bool MatchChanges::atStoppage (const MatchEngine &engine)
 Play is stopped: planned changes can be made without waiting.
 
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.
 
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).
 
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).
 

Variables

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