Player12
An open source football management simulator
Loading...
Searching...
No Matches
team.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 <cstdint>
12#include <string>
13#include <string_view>
14#include <vector>
15
16#include "finances.h"
17#include "global/types.h"
18#include "lineup.h"
19#include "strategy.h"
20
26{
27 std::uint8_t reputation = 50;
28 std::uint32_t stadium_capacity = 10'000;
29 std::uint32_t ticket_price = 20;
30 std::uint8_t training_facilities = 50;
31 std::uint8_t youth_facilities = 50;
32};
33
35enum class MatchOutcome : char
36{
37 Win = 'W',
38 Draw = 'D',
39 Loss = 'L'
40};
41
46class Team
47{
48 public:
59 Team(TeamID team_id, uint8_t team_league_id, std::string_view team_name,
60 int64_t initial_balance,
61 const std::vector<PlayerID>& initial_player_ids = {},
62 const Strategy& strategy = Strategy{},
63 const Lineup& lineup_data = Lineup{});
64
65 // Accessors
66
68 TeamID getId() const;
69
71 LeagueID getLeagueId() const;
72
74 void setLeagueId(LeagueID new_league_id);
75
77 const std::string& getName() const;
78
80 const std::vector<PlayerID>& getPlayerIDs() const;
81
83 const std::vector<PlayerID>& getAcademyIDs() const;
84
85 // Manage roster
86
91 void addPlayerID(PlayerID id);
92
94 void addAcademyID(PlayerID id);
95
100 void setAcademyMember(PlayerID id, bool academy);
101
107 bool removePlayerID(PlayerID id);
108
109 // Lineup access
110
112 Lineup& getLineup();
113
115 const Lineup& getLineup() const;
116
117 // Strategy access
118
121
123 const Strategy& getStrategy() const;
124
126 void setStrategy(const Strategy& strategy);
127
134 void generateStartingXI(const class GameData& gamedata,
135 const StatsConfig& stats_config);
136
137 // Finances access
138
140 Finances& getFinances() noexcept;
141
143 const Finances& getFinances() const noexcept;
144
145 // Club profile
146
148 const ClubProfile& getProfile() const noexcept;
149
151 void setProfile(const ClubProfile& profile);
152
154 std::uint8_t getReputation() const noexcept;
155
157 std::uint32_t getStadiumCapacity() const noexcept;
158
160 const std::string& getRecentForm() const noexcept;
161
163 void setRecentForm(std::string_view form);
164
166 void pushResult(MatchOutcome outcome);
167
168 private:
171 std::string name;
172
173 /*
174 * the main idea is to have a players map *map[player_id]-- > player;
175 * and here we just iterate on the ids to get *all players.
176 */
177 std::vector<PlayerID> player_ids;
178 std::vector<PlayerID> academy_ids;
179
184 std::string recent_form;
185};
A club's balance, budgets and dated transaction ledger.
Definition finances.h:83
Singleton class that acts as an in-memory cache for the database state.
Definition gamedata.h:43
Manages the starting XI and reserves of a team.
Definition lineup.h:85
Represents the tactical setup of a team for a match.
Definition strategy.h:61
Represents a football team.
Definition team.h:47
void addAcademyID(PlayerID id)
Adds a player to the club's academy.
Definition team.cpp:90
void addPlayerID(PlayerID id)
Adds a player to the team.
Definition team.cpp:81
void setAcademyMember(PlayerID id, bool academy)
Moves a club player between the senior squad and the academy (use GameData::setAcademyMember,...
Definition team.cpp:97
Strategy team_strategy
Definition team.h:180
Lineup lineup
Definition team.h:181
Strategy & getStrategy()
Gets the team's strategy (non-const).
Definition team.cpp:116
void setLeagueId(LeagueID new_league_id)
Moves the team to another league (promotion/relegation).
Definition team.cpp:74
Finances & getFinances() noexcept
Gets the team's finances (non-const).
Definition team.cpp:174
void setProfile(const ClubProfile &profile)
Replaces the club profile.
Definition team.cpp:179
const std::vector< PlayerID > & getAcademyIDs() const
Player IDs of the club's academy (U18 squad and trialists).
Definition team.cpp:79
std::vector< PlayerID > academy_ids
Definition team.h:178
const std::string & getName() const
Gets the name of the team.
Definition team.cpp:75
TeamID id
Definition team.h:169
const ClubProfile & getProfile() const noexcept
Reputation, stadium, ticket price and facilities.
Definition team.cpp:178
void setRecentForm(std::string_view form)
Restores the recent-form string (persistence).
Definition team.cpp:188
void pushResult(MatchOutcome outcome)
Prepends a result to the recent form.
Definition team.cpp:193
std::vector< PlayerID > player_ids
Definition team.h:177
std::string name
Definition team.h:171
std::uint8_t getReputation() const noexcept
Club reputation (1-100).
Definition team.cpp:180
LeagueID league_id
Definition team.h:170
const std::vector< PlayerID > & getPlayerIDs() const
Player IDs of the senior squad (academy players excluded).
Definition team.cpp:77
std::uint32_t getStadiumCapacity() const noexcept
Stadium capacity in seats.
Definition team.cpp:181
bool removePlayerID(PlayerID id)
Removes a player from the team (senior squad or academy).
Definition team.cpp:104
std::string recent_form
Definition team.h:184
const std::string & getRecentForm() const noexcept
Last results, newest first ("WDL..."), at most 5 letters.
Definition team.cpp:186
Lineup & getLineup()
Gets the team's lineup (non-const).
Definition team.cpp:112
void setStrategy(const Strategy &strategy)
Sets the team's strategy.
Definition team.cpp:118
TeamID getId() const
Gets the team's ID.
Definition team.cpp:72
ClubProfile profile
Definition team.h:183
void generateStartingXI(const class GameData &gamedata, const StatsConfig &stats_config)
Generates the best starting XI automatically based on stats.
Definition team.cpp:121
LeagueID getLeagueId() const
Gets the ID of the team's league.
Definition team.cpp:73
Finances finances
Definition team.h:182
Persistent club attributes that drive revenue and development.
Definition team.h:26
std::uint32_t stadium_capacity
Definition team.h:28
std::uint8_t training_facilities
Definition team.h:30
std::uint32_t ticket_price
Definition team.h:29
std::uint8_t youth_facilities
Definition team.h:31
std::uint8_t reputation
Definition team.h:27
Configuration mapping roles to their focus areas and listing all possible stats.
Definition stats_config.h:42
MatchOutcome
Result letters stored in the recent-form string.
Definition team.h:36
uint8_t LeagueID
Type alias for League identifiers.
Definition types.h:15
uint16_t TeamID
Type alias for Team identifiers.
Definition types.h:18
uint32_t PlayerID
Type alias for Player identifiers.
Definition types.h:21