Player12
An open source football management simulator
Loading...
Searching...
No Matches
board.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 <cstdint>
13#include <optional>
14
15#include "global/types.h"
16
21enum class BoardObjective : std::uint8_t
22{
23 WinLeague = 0,
24 TopFour,
25 TopHalf,
28};
29
31enum class CupObjective : std::uint8_t
32{
33 None = 0,
36 Final,
37 Win
38};
39
41enum class FinanceObjective : std::uint8_t
42{
45};
46
48enum class ObjectiveGrade : std::uint8_t
49{
50 Exceeded = 0,
51 Met,
52 Missed,
53 Failed
54};
55
57enum class BoardReviewOutcome : std::uint8_t
58{
60 Warning,
62};
63
69{
70 static constexpr std::size_t RESULT_WINDOW = 8;
71
73 std::uint16_t season_year = 0;
75 std::uint8_t expected_position = 0;
76 std::uint8_t target_position = 0;
77 float confidence = 60.0f;
78 std::uint8_t low_reviews = 0;
79 std::uint8_t league_matches = 0;
80 bool dismissed = false;
83 std::uint8_t youth_target = 0;
84 std::int64_t start_balance = 0;
87 bool targets_set = false;
88 std::uint8_t result_count = 0;
90 std::array<float, RESULT_WINDOW> recent_deltas{};
91};
92
93namespace BoardModel
94{
100BoardObjective objectiveFor(int expected_position, int league_size);
101
103std::uint8_t targetPosition(BoardObjective objective, int league_size);
104
106const char* objectiveKey(BoardObjective objective);
107
113float expectedPoints(float own_strength, float opponent_strength, bool home);
114
119void recordMatch(BoardState& state, float points, float expected_points);
120
128BoardReviewOutcome monthlyReview(BoardState& state, int position,
129 int league_size, bool negative_balance,
130 bool over_wage_budget, bool in_season = true);
131
133void seasonReview(BoardState& state, int final_position);
134
136void adjustConfidence(BoardState& state, float delta);
137
139CupObjective cupObjectiveFor(BoardObjective objective, int tier);
141FinanceObjective financeObjectiveFor(float tight_budget, std::int64_t balance);
143std::uint8_t youthTargetFor(float youth_focus);
144
146const char* cupObjectiveKey(CupObjective objective);
147const char* financeObjectiveKey(FinanceObjective objective);
148const char* youthTargetKey(std::uint8_t target);
150const char* targetStatusKey(ObjectiveGrade grade);
151
157ObjectiveGrade gradeCup(CupObjective objective, std::optional<int> rounds_left,
158 bool won, bool still_in);
161ObjectiveGrade gradeLeague(int target_position, int position, int league_size);
163ObjectiveGrade gradeFinances(FinanceObjective objective, std::int64_t balance,
164 std::int64_t start_balance, bool over_wage_budget);
166ObjectiveGrade gradeYouth(std::uint8_t target, int young_regulars);
167} // namespace BoardModel
168
169// ---------------------------------------------------------------------------
170// Facility projects the manager can ask the board to fund
171// ---------------------------------------------------------------------------
172
174enum class FacilityProjectType : std::uint8_t
175{
176 TrainingGround = 0,
179 COUNT
180};
181
183enum class ProjectVerdict : std::uint8_t
184{
185 Approved = 0,
188 Cooldown,
189 AtMaximum,
190 NotNeeded,
193};
194
197{
199 std::int64_t cost = 0;
200 std::uint16_t days = 0;
201 std::uint32_t amount = 0;
202 std::uint32_t disruption = 0;
203};
204
207{
208 float confidence = 60.0f;
209 std::int64_t balance = 0;
210 std::int64_t weekly_payroll = 0;
211 std::uint8_t reputation = 50;
212 std::uint8_t current_level = 50;
214 bool same_type_running = false;
215 bool cooling_down = false;
216};
217
218namespace BoardModel
219{
222inline constexpr int PROJECT_COOLDOWN_DAYS = 90;
223inline constexpr int MAX_RUNNING_PROJECTS = 2;
225inline constexpr int PROJECT_CASH_RESERVE_WEEKS = 16;
226inline constexpr float PROJECT_MIN_CONFIDENCE = 45.0f;
227inline constexpr std::uint32_t MIN_EXPANSION_SEATS = 1'000;
228inline constexpr std::uint32_t MAX_STADIUM_CAPACITY = 100'000;
229
237ProjectQuote quoteProject(FacilityProjectType type, std::uint8_t current_level,
238 std::uint32_t capacity, std::uint8_t reputation,
239 double season_income, std::uint32_t seats);
240
243 const ProjectRequestContext& context);
244
246float medicalLayoffMultiplier(std::uint8_t medical_level);
247
249const char* projectTypeKey(FacilityProjectType type);
250const char* projectVerdictKey(ProjectVerdict verdict);
251} // namespace BoardModel
FacilityProjectType
Facility project (values are persisted).
Definition board.h:175
ProjectVerdict
The board's answer to a project request.
Definition board.h:184
CupObjective
How far the board expects the domestic cup run to go (persisted).
Definition board.h:32
BoardReviewOutcome
Outcome of a monthly board review.
Definition board.h:58
FinanceObjective
What the board expects from the books (persisted).
Definition board.h:42
ObjectiveGrade
How one objective went, or is going (values are persisted).
Definition board.h:49
BoardObjective
Season objective set from the club's expected finish (persisted).
Definition board.h:22
Definition board.cpp:34
const char * targetStatusKey(ObjectiveGrade grade)
Definition board.cpp:263
ObjectiveGrade gradeYouth(std::uint8_t target, int young_regulars)
Definition board.cpp:310
ProjectVerdict reviewProject(const ProjectQuote &quote, const ProjectRequestContext &context)
Definition board.cpp:375
ObjectiveGrade gradeCup(CupObjective objective, std::optional< int > rounds_left, bool won, bool still_in)
Definition board.cpp:229
float medicalLayoffMultiplier(std::uint8_t medical_level)
Definition board.cpp:394
const char * projectVerdictKey(ProjectVerdict verdict)
Definition board.cpp:416
void recordMatch(BoardState &state, float points, float expected_points)
Definition board.cpp:99
const char * objectiveKey(BoardObjective objective)
Definition board.cpp:70
ProjectQuote quoteProject(FacilityProjectType type, std::uint8_t current_level, std::uint32_t capacity, std::uint8_t reputation, double season_income, std::uint32_t seats)
Definition board.cpp:326
constexpr int PROJECT_CASH_RESERVE_WEEKS
Definition board.h:225
const char * cupObjectiveKey(CupObjective objective)
Definition board.cpp:198
float expectedPoints(float own_strength, float opponent_strength, bool home)
Definition board.cpp:89
std::uint8_t targetPosition(BoardObjective objective, int league_size)
Definition board.cpp:45
const char * projectTypeKey(FacilityProjectType type)
Definition board.cpp:400
constexpr std::uint32_t MAX_STADIUM_CAPACITY
Definition board.h:228
std::uint8_t youthTargetFor(float youth_focus)
Definition board.cpp:191
constexpr int MAX_RUNNING_PROJECTS
Definition board.h:223
const char * youthTargetKey(std::uint8_t target)
Definition board.cpp:223
constexpr std::uint32_t MIN_EXPANSION_SEATS
Definition board.h:227
ObjectiveGrade gradeLeague(int target_position, int position, int league_size)
Definition board.cpp:280
constexpr float PROJECT_MIN_CONFIDENCE
Definition board.h:226
BoardObjective objectiveFor(int expected_position, int league_size)
Definition board.cpp:35
constexpr int PROJECT_COOLDOWN_DAYS
Definition board.h:222
CupObjective cupObjectiveFor(BoardObjective objective, int tier)
Definition board.cpp:164
FinanceObjective financeObjectiveFor(float tight_budget, std::int64_t balance)
Definition board.cpp:184
BoardReviewOutcome monthlyReview(BoardState &state, int position, int league_size, bool negative_balance, bool over_wage_budget, bool in_season)
Definition board.cpp:116
const char * financeObjectiveKey(FinanceObjective objective)
Definition board.cpp:217
void seasonReview(BoardState &state, int final_position)
Definition board.cpp:153
void adjustConfidence(BoardState &state, float delta)
Definition board.cpp:159
ObjectiveGrade gradeFinances(FinanceObjective objective, std::int64_t balance, std::int64_t start_balance, bool over_wage_budget)
Definition board.cpp:291
The board's view of the manager of the managed club.
Definition board.h:69
std::uint8_t youth_target
Definition board.h:83
std::uint16_t season_year
Definition board.h:73
BoardObjective objective
Definition board.h:74
bool targets_set
Definition board.h:87
std::int64_t start_balance
Definition board.h:84
float confidence
Definition board.h:77
FinanceObjective finance_objective
Definition board.h:82
TeamID team_id
Definition board.h:72
CupObjective cup_objective
Definition board.h:81
std::uint8_t low_reviews
Definition board.h:78
std::uint8_t league_matches
Definition board.h:79
static constexpr std::size_t RESULT_WINDOW
Definition board.h:70
std::uint8_t result_count
Definition board.h:88
bool dismissed
Definition board.h:80
std::uint8_t expected_position
Definition board.h:75
std::uint8_t target_position
Definition board.h:76
std::array< float, RESULT_WINDOW > recent_deltas
Definition board.h:90
Cost, duration and size of a project for one club.
Definition board.h:197
std::uint32_t amount
Definition board.h:201
std::int64_t cost
Definition board.h:199
FacilityProjectType type
Definition board.h:198
std::uint16_t days
Definition board.h:200
std::uint32_t disruption
Definition board.h:202
What the board weighs when a project is requested.
Definition board.h:207
std::uint8_t reputation
Definition board.h:211
bool cooling_down
Definition board.h:215
std::uint8_t current_level
Definition board.h:212
std::int64_t balance
Definition board.h:209
bool same_type_running
Definition board.h:214
float confidence
Definition board.h:208
int running_projects
Definition board.h:213
std::int64_t weekly_payroll
Definition board.h:210
uint16_t TeamID
Type alias for Team identifiers.
Definition types.h:18