Player12
An open source football management simulator
Loading...
Searching...
No Matches
mentoring.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 <memory>
13#include <unordered_map>
14#include <vector>
15
16#include "global/types.h"
17
19class GameData;
20class Player;
21
37
39const char* mentoringErrorKey(MentoringError error);
40
43{
47 float temperament_shift = 0.0f;
49 float temperament_pending = 0.0f;
50};
51
54{
55 std::uint32_t id = 0;
58 std::vector<MenteeState> mentees;
59};
60
77namespace Mentoring
78{
79inline constexpr int MENTOR_MIN_AGE = 25;
80inline constexpr int MENTEE_MAX_AGE = 23;
81inline constexpr std::size_t MAX_MENTEES = 3;
83inline constexpr float WEEKLY_RATE = 0.006f;
84inline constexpr float MAX_WEEKLY_STEP = 0.1f;
85inline constexpr float MAX_TOTAL_SHIFT = 10.0f;
86inline constexpr float MAX_DEVELOPMENT_BONUS = 0.04f;
88inline constexpr float UNHAPPY_MENTOR_MORALE = 35.0f;
89inline constexpr float GLOOM_PER_WEEK = 0.5f;
90
92float receptiveness(int age);
93
95float influence(int mentor_age);
96
101float weeklyShift(float mentor_value, float mentee_value, float receptiveness,
102 float influence, float already_shifted);
103
105float developmentMultiplier(std::uint8_t mentor_professionalism);
106} // namespace Mentoring
107
116{
117 public:
119 MentoringError createGroup(const GameData& gamedata, TeamID team_id,
120 PlayerID mentor_id, std::uint32_t* id = nullptr);
121 MentoringError addMentee(const GameData& gamedata, std::uint32_t group_id,
122 PlayerID mentee_id);
123 MentoringError removeMentee(std::uint32_t group_id, PlayerID mentee_id);
124 MentoringError dissolve(std::uint32_t group_id);
125
127 void onWeek(GameData& gamedata);
128
130 float developmentMultiplier(const GameData& gamedata,
131 PlayerID player_id) const;
132
133 std::vector<MentoringGroup> groupsFor(TeamID team_id) const;
135 const MentoringGroup* groupOf(PlayerID player_id) const;
136
137 void clear();
138 void load(const std::shared_ptr<DatabaseConnection>& db_conn);
139 void save(const std::shared_ptr<DatabaseConnection>& db_conn) const;
140
141 private:
142 MentoringGroup* find(std::uint32_t group_id);
143 void prune(const GameData& gamedata);
144
145 std::vector<MentoringGroup> all;
146 std::uint32_t next_id = 1;
147};
Manages the SQLite database connection and transaction lifecycle.
Definition database_connection.h:24
Singleton class that acts as an in-memory cache for the database state.
Definition gamedata.h:43
Mentoring groups of the managed club.
Definition mentoring.h:116
std::vector< MentoringGroup > all
Definition mentoring.h:145
std::uint32_t next_id
Definition mentoring.h:146
MentoringError addMentee(const GameData &gamedata, std::uint32_t group_id, PlayerID mentee_id)
Definition mentoring.cpp:138
MentoringError dissolve(std::uint32_t group_id)
Definition mentoring.cpp:170
void prune(const GameData &gamedata)
Definition mentoring.cpp:178
std::vector< MentoringGroup > groupsFor(TeamID team_id) const
Definition mentoring.cpp:263
MentoringError removeMentee(std::uint32_t group_id, PlayerID mentee_id)
Definition mentoring.cpp:159
void clear()
Definition mentoring.cpp:275
MentoringGroup * find(std::uint32_t group_id)
Definition mentoring.cpp:99
void load(const std::shared_ptr< DatabaseConnection > &db_conn)
Definition mentoring.cpp:281
MentoringError createGroup(const GameData &gamedata, TeamID team_id, PlayerID mentor_id, std::uint32_t *id=nullptr)
Definition mentoring.cpp:117
float developmentMultiplier(const GameData &gamedata, PlayerID player_id) const
Definition mentoring.cpp:247
void save(const std::shared_ptr< DatabaseConnection > &db_conn) const
Definition mentoring.cpp:314
const MentoringGroup * groupOf(PlayerID player_id) const
Definition mentoring.cpp:105
void onWeek(GameData &gamedata)
Definition mentoring.cpp:199
Persistent career identity, attributes, traits and day-to-day state.
Definition player.h:104
MentoringError
Why a mentoring change was refused.
Definition mentoring.h:24
const char * mentoringErrorKey(MentoringError error)
Definition mentoring.cpp:32
Bounded, slow personality transfer from mentor to youngster.
Definition mentoring.cpp:64
float developmentMultiplier(std::uint8_t mentor_professionalism)
Definition mentoring.cpp:89
constexpr float WEEKLY_RATE
Definition mentoring.h:83
constexpr std::size_t MAX_MENTEES
Definition mentoring.h:81
constexpr float MAX_TOTAL_SHIFT
Definition mentoring.h:85
constexpr float MAX_WEEKLY_STEP
Definition mentoring.h:84
constexpr int MENTOR_MIN_AGE
Definition mentoring.h:79
float receptiveness(int age)
Definition mentoring.cpp:65
constexpr float MAX_DEVELOPMENT_BONUS
Definition mentoring.h:86
constexpr float GLOOM_PER_WEEK
Definition mentoring.h:89
float influence(int mentor_age)
Definition mentoring.cpp:71
constexpr float UNHAPPY_MENTOR_MORALE
Definition mentoring.h:88
float weeklyShift(float mentor_value, float mentee_value, float receptiveness, float influence, float already_shifted)
Definition mentoring.cpp:78
constexpr int MENTEE_MAX_AGE
Definition mentoring.h:80
One youngster in a mentoring group.
Definition mentoring.h:43
float temperament_shift
Definition mentoring.h:47
float professionalism_shift
Definition mentoring.h:46
float professionalism_pending
Definition mentoring.h:48
float temperament_pending
Definition mentoring.h:49
PlayerID player_id
Definition mentoring.h:44
A senior player guiding up to three youngsters.
Definition mentoring.h:54
PlayerID mentor_id
Definition mentoring.h:57
std::vector< MenteeState > mentees
Definition mentoring.h:58
TeamID team_id
Definition mentoring.h:56
uint16_t TeamID
Type alias for Team identifiers.
Definition types.h:18
uint32_t PlayerID
Type alias for Player identifiers.
Definition types.h:21