Player12
An open source football management simulator
Loading...
Searching...
No Matches
global.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 <utility>
14
15#include "gamedate.h"
16
17// This file can be used for global constants, enums, and functions
18// that are used across the entire project.
19// If possible, use constexpr
20
22constexpr uint8_t FREE_AGENTS_TEAM_ID = 0;
23
25constexpr const char* FREE_AGENTS_TEAM_NAME = "Free agents";
26
31constexpr const char* FREE_AGENTS_NAME_ARG = "@INBOX_FREE_AGENCY";
32
34constexpr uint8_t TEAMS_PER_LEAGUE = 16;
35
37constexpr uint8_t MIN_STAT_VAL = 1;
38
40constexpr uint8_t MAX_STAT_VAL = 100;
41
42// Player Development
44constexpr float PLAYER_STAT_INCREASE_BASE = 0.03f;
45
47constexpr float PLAYER_AGE_FACTOR_DECAY_RATE = 0.05f;
48
50constexpr float PLAYER_AGE_FACTOR_DECLINE_AGE = 31.5f;
51
52// Player Retirement
54constexpr uint8_t PLAYER_RETIREMENT_AGE_THRESHOLD = 32;
55
57constexpr float PLAYER_RETIREMENT_BASE_CHANCE = 0.01f;
58
62
70static constexpr uint8_t LINEUP_GRID_ROWS = 5;
71static constexpr uint8_t LINEUP_GRID_COLS = 5;
73
74// Functions to access the array of lineup's grid
75
82constexpr uint8_t toIndex(uint8_t row, uint8_t col)
83{
84 return static_cast<uint8_t>(row * LINEUP_GRID_COLS + col);
85}
86
92constexpr std::pair<int, int> toRowCol(int i)
93{
94 return {i / LINEUP_GRID_COLS, i % LINEUP_GRID_COLS};
95}
96
99constexpr std::array<uint8_t, 12> DAYS_PER_MONTH = {31, 28, 31, 30, 31, 30,
100 31, 31, 30, 31, 30, 31};
101
103const GameDateValue START_DATE(2025, 7, 2);
104
static constexpr uint8_t LINEUP_GRID_COLS
Definition global.h:71
constexpr float PLAYER_STAT_INCREASE_BASE
Base rate at which player statistics increase.
Definition global.h:44
constexpr std::pair< int, int > toRowCol(int i)
Converts a 1D index into a 2D grid row/column pair.
Definition global.h:92
constexpr std::array< uint8_t, 12 > DAYS_PER_MONTH
Array mapping each month (0-11) to its number of days (ignoring leap years for simplicity).
Definition global.h:99
constexpr float PLAYER_RETIREMENT_CHANCE_INCREASE_PER_YEAR
Amount by which the retirement chance increases each year after the threshold.
Definition global.h:61
constexpr uint8_t PLAYER_RETIREMENT_AGE_THRESHOLD
Minimum age at which a player might consider retirement.
Definition global.h:54
static constexpr uint8_t LINEUP_GRID_ROWS
This is the size of the grid where to insert players it could be used to generate heatmaps where the ...
Definition global.h:70
const GameDateValue START_DATE(2025, 7, 2)
The starting date of the game.
constexpr uint8_t toIndex(uint8_t row, uint8_t col)
Converts a 2D grid position into a 1D index.
Definition global.h:82
static constexpr uint8_t LINEUP_GRID_SIZE
Definition global.h:72
constexpr float PLAYER_AGE_FACTOR_DECLINE_AGE
Age at which player performance starts to decline.
Definition global.h:50
constexpr uint8_t TEAMS_PER_LEAGUE
Number of teams in each league.
Definition global.h:34
constexpr const char * FREE_AGENTS_TEAM_NAME
Internal name of the free agents team (never shown).
Definition global.h:25
constexpr float PLAYER_RETIREMENT_BASE_CHANCE
Base probability of a player retiring.
Definition global.h:57
const GameDateValue START_SEASON_DATE(2025, 9, 1)
The date when the season officially starts.
constexpr float PLAYER_AGE_FACTOR_DECAY_RATE
Rate at which the age factor decays for player development.
Definition global.h:47
constexpr uint8_t FREE_AGENTS_TEAM_ID
Team ID reserved for free agents.
Definition global.h:22
constexpr uint8_t MAX_STAT_VAL
Maximum possible value for a player statistic.
Definition global.h:40
constexpr const char * FREE_AGENTS_NAME_ARG
The free agents in a message argument where a club name goes: a language key, so the reader sees it i...
Definition global.h:31
constexpr uint8_t MIN_STAT_VAL
Minimum possible value for a player statistic.
Definition global.h:37
Represents a specific date in the game world.
Definition gamedate.h:20