Player12
An open source football management simulator
Loading...
Searching...
No Matches
squad_planner.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2// Football Management Project
3// Copyright (c) 2025 - 2026 Flavio Milinanni. All Rights Reserved.
4//
5// This file is part of the Football Management Project.
6// See the LICENSE file in the project root.
7// -----------------------------------------------------------------------------
8
9#pragma once
10
11#include <array>
12#include <cstddef>
13#include <cstdint>
14#include <utility>
15#include <vector>
16
17#include "global/types.h"
18
24enum class PlannerGroup : std::uint8_t
25{
30 Midfield,
31 Wide,
32 Striker,
33 COUNT
34};
35
36inline constexpr std::size_t PLANNER_GROUP_COUNT =
37 static_cast<std::size_t>(std::to_underlying(PlannerGroup::COUNT));
38
40enum class DepthTier : std::uint8_t
41{
43 Backup,
45};
46
49{
50 PlayerID id = 0;
52 int age = 0;
53 float overall = 0.0f;
55 float potential = 0.0f;
58 bool in_xi = false;
59 bool injured = false;
60 bool listed = false;
61};
62
73
76{
78 int target = 0;
79 int starters = 0;
80 std::vector<DepthEntry> players;
81 int missing = 0;
82 int surplus = 0;
83 float first_choice_average = 0.0f;
84};
85
87enum class NeedKind : std::uint8_t
88{
89 Missing,
90 Upgrade,
92 Surplus
93};
94
102
104inline constexpr std::array<int, 4> AGE_BAND_LIMITS = {21, 25, 29, 32};
105inline constexpr std::size_t AGE_BAND_COUNT = AGE_BAND_LIMITS.size() + 1;
106
109{
110 int years_left = 0;
111 std::vector<PlayerID> players;
112};
113
120{
122 std::array<GroupDepth, PLANNER_GROUP_COUNT> groups{};
123 std::vector<PlannerNeed> needs;
124 std::array<int, AGE_BAND_COUNT> age_bands{};
125 float average_age = 0.0f;
126 std::vector<ContractExpiry> expiries;
128 std::vector<PlayerID> departures;
129 int squad_size = 0;
130};
131
133{
136
138const char* groupKey(PlannerGroup group);
139
141int targetDepth(PlannerGroup group);
142
145
152PlannerPlayer project(const PlannerPlayer& player, int seasons);
153
160SquadPlan build(const std::vector<PlannerPlayer>& squad, int season_offset,
161 const std::array<int, PLANNER_GROUP_COUNT>& starters = {});
162} // namespace SquadPlanner
Definition squad_planner.h:133
PlannerPlayer project(const PlannerPlayer &player, int seasons)
Definition squad_planner.cpp:131
int targetDepth(PlannerGroup group)
Definition squad_planner.cpp:121
PlannerGroup groupOf(PlayerRole role)
Definition squad_planner.cpp:68
SquadPlan build(const std::vector< PlannerPlayer > &squad, int season_offset, const std::array< int, PLANNER_GROUP_COUNT > &starters={})
Definition squad_planner.cpp:146
const char * groupKey(PlannerGroup group)
Definition squad_planner.cpp:97
int defaultStarters(PlannerGroup group)
Definition squad_planner.cpp:126
PlannerGroup
Position groups of the depth chart (the groups computer-managed clubs count when they look for missin...
Definition squad_planner.h:25
NeedKind
Why the planner suggests recruitment (or a sale) for a group.
Definition squad_planner.h:88
constexpr std::size_t PLANNER_GROUP_COUNT
Definition squad_planner.h:36
constexpr std::array< int, 4 > AGE_BAND_LIMITS
Age bands of the age profile.
Definition squad_planner.h:104
DepthTier
Place of a player in his group's depth chart.
Definition squad_planner.h:41
constexpr std::size_t AGE_BAND_COUNT
Definition squad_planner.h:105
Players whose contract ends in a given season.
Definition squad_planner.h:109
std::vector< PlayerID > players
Definition squad_planner.h:111
int years_left
Definition squad_planner.h:110
One player's line in the depth chart of the viewed season.
Definition squad_planner.h:65
bool ageing
Definition squad_planner.h:71
bool expiring
Definition squad_planner.h:69
PlannerPlayer player
Definition squad_planner.h:66
DepthTier tier
Definition squad_planner.h:67
Depth of one position group.
Definition squad_planner.h:76
int starters
Definition squad_planner.h:79
float first_choice_average
Definition squad_planner.h:83
int target
Definition squad_planner.h:78
int surplus
Definition squad_planner.h:82
int missing
Definition squad_planner.h:81
std::vector< DepthEntry > players
Definition squad_planner.h:80
PlannerGroup group
Definition squad_planner.h:77
Definition squad_planner.h:96
PlannerGroup group
Definition squad_planner.h:97
PlayerID player_id
Definition squad_planner.h:100
int count
Definition squad_planner.h:99
NeedKind kind
Definition squad_planner.h:98
What the planner knows about one player of the squad.
Definition squad_planner.h:49
float overall
Definition squad_planner.h:53
bool injured
Definition squad_planner.h:59
bool in_xi
Definition squad_planner.h:58
bool listed
Definition squad_planner.h:60
int contract_years
Definition squad_planner.h:57
PlayerRole role
Definition squad_planner.h:51
int age
Definition squad_planner.h:52
float potential
Definition squad_planner.h:55
Depth chart, needs, age profile and contract calendar of a squad for the current season (offset 0) or...
Definition squad_planner.h:120
int squad_size
Definition squad_planner.h:129
std::array< int, AGE_BAND_COUNT > age_bands
Definition squad_planner.h:124
std::vector< PlayerID > departures
Definition squad_planner.h:128
int season_offset
Definition squad_planner.h:121
std::vector< PlannerNeed > needs
Definition squad_planner.h:123
std::array< GroupDepth, PLANNER_GROUP_COUNT > groups
Definition squad_planner.h:122
float average_age
Definition squad_planner.h:125
std::vector< ContractExpiry > expiries
Definition squad_planner.h:126
uint32_t PlayerID
Type alias for Player identifiers.
Definition types.h:21
PlayerRole
Represents a specific tactical role on the pitch.
Definition types.h:63