Player12
An open source football management simulator
Loading...
Searching...
No Matches
holiday.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 <optional>
14#include <string>
15#include <vector>
16
17#include "global/types.h"
18#include "model/gamedate.h"
19
21
23enum class HolidayMode : std::uint8_t
24{
25 UntilDate = 0,
26 NextMatch,
28 WindowEnd,
29 COUNT
30};
31
33enum class HolidayStop : std::uint8_t
34{
35 Completed = 0,
38 BigBid,
44};
45
52{
53 bool stop_big_bid = true;
55 std::int64_t big_bid_threshold = 0;
57 bool stop_injury_crisis = true;
58 std::uint8_t injury_crisis_count = 5;
59 bool stop_key_injury = true;
60 bool assistant_lineup = true;
61 bool assistant_training = true;
62 bool assistant_inbox = true;
63};
64
73
76{
78 std::uint32_t fee = 0;
79 bool loan = false;
80 bool key_player = false;
81};
82
85{
87 std::string name;
88 std::string injury_key;
89 std::uint16_t days = 0;
90 bool key_player = false;
91};
92
95{
96 bool dismissed = false;
97 bool board_warning = false;
98 std::vector<HolidayOffer> new_offers;
99 std::vector<HolidayInjury> new_injuries;
100 int injured = 0;
102 bool new_decision = false;
103};
104
115
118{
120 std::string name;
122 std::uint32_t fee = 0;
123 bool incoming = true;
124};
125
128{
129 bool valid = false;
132 int days = 0;
134 std::string stop_detail;
135 std::int64_t stop_amount = 0;
136 std::vector<HolidayResult> results;
142 std::int64_t balance_before = 0;
143 std::int64_t balance_after = 0;
144 std::int64_t income = 0;
145 std::int64_t expenses = 0;
146 std::vector<HolidayMove> moves;
147 std::vector<HolidayInjury> injuries;
149};
150
155namespace Holiday
156{
158inline constexpr std::uint16_t KEY_INJURY_DAYS = 14;
159
166std::optional<GameDateValue> targetDate(
167 const HolidayPlan& plan, const GameDateValue& today,
168 const std::optional<GameDateValue>& next_match, LeagueID league);
169
172
174std::optional<HolidayStop> checkStop(const HolidayPlan& plan,
175 const HolidayDay& day);
176
178const char* stopKey(HolidayStop stop);
179
181 const std::shared_ptr<DatabaseConnection>& db_conn);
182void savePreferences(const std::shared_ptr<DatabaseConnection>& db_conn,
183 const HolidayPreferences& preferences);
184} // namespace Holiday
Manages the SQLite database connection and transaction lifecycle.
Definition database_connection.h:24
HolidayMode
How long the manager is away.
Definition holiday.h:24
HolidayStop
Why the holiday ended.
Definition holiday.h:34
bool day
Definition match_stadium_3d.cpp:447
Targets and stop rules of "continue until".
Definition holiday.cpp:18
constexpr std::uint16_t KEY_INJURY_DAYS
Definition holiday.h:158
void savePreferences(const std::shared_ptr< DatabaseConnection > &db_conn, const HolidayPreferences &preferences)
Definition holiday.cpp:132
std::optional< HolidayStop > checkStop(const HolidayPlan &plan, const HolidayDay &day)
Definition holiday.cpp:49
std::optional< GameDateValue > targetDate(const HolidayPlan &plan, const GameDateValue &today, const std::optional< GameDateValue > &next_match, LeagueID league)
Definition holiday.cpp:27
const char * stopKey(HolidayStop stop)
Definition holiday.cpp:79
GameDateValue windowEndDate(LeagueID league, const GameDateValue &today)
Definition holiday.cpp:19
HolidayPreferences loadPreferences(const std::shared_ptr< DatabaseConnection > &db_conn)
Definition holiday.cpp:106
Represents a specific date in the game world.
Definition gamedate.h:20
What changed on one simulated day (input of the stop rules).
Definition holiday.h:95
std::vector< HolidayOffer > new_offers
Definition holiday.h:98
int injured
Definition holiday.h:100
int injured_at_start
Definition holiday.h:101
bool dismissed
Definition holiday.h:96
bool new_decision
Definition holiday.h:102
bool board_warning
Definition holiday.h:97
std::vector< HolidayInjury > new_injuries
Definition holiday.h:99
A managed player injured during the holiday.
Definition holiday.h:85
PlayerID player_id
Definition holiday.h:86
std::uint16_t days
Definition holiday.h:89
bool key_player
Definition holiday.h:90
std::string name
Definition holiday.h:87
std::string injury_key
Definition holiday.h:88
A transfer in or out of the managed club during the holiday.
Definition holiday.h:118
TeamID other_team_id
Definition holiday.h:121
std::string name
Definition holiday.h:120
PlayerID player_id
Definition holiday.h:119
bool incoming
Definition holiday.h:123
std::uint32_t fee
Definition holiday.h:122
A new offer for a managed player seen during the holiday.
Definition holiday.h:76
PlayerID player_id
Definition holiday.h:77
bool key_player
Definition holiday.h:80
bool loan
Definition holiday.h:79
std::uint32_t fee
Definition holiday.h:78
A holiday request.
Definition holiday.h:67
HolidayPreferences preferences
Definition holiday.h:70
HolidayMode mode
Definition holiday.h:68
GameDateValue until
Definition holiday.h:69
int max_days
Definition holiday.h:71
What stops a holiday early and what the assistant takes over (persisted with the save).
Definition holiday.h:52
std::uint8_t injury_crisis_count
Definition holiday.h:58
bool stop_injury_crisis
Definition holiday.h:57
bool stop_sacking_warning
Definition holiday.h:56
bool assistant_inbox
Definition holiday.h:62
bool stop_key_injury
Definition holiday.h:59
bool assistant_training
Definition holiday.h:61
bool stop_big_bid
Definition holiday.h:53
bool assistant_lineup
Definition holiday.h:60
std::int64_t big_bid_threshold
Definition holiday.h:55
A managed result during the holiday.
Definition holiday.h:107
GameDateValue date
Definition holiday.h:108
bool home
Definition holiday.h:110
MatchType type
Definition holiday.h:111
std::uint8_t goals_for
Definition holiday.h:112
TeamID opponent_id
Definition holiday.h:109
std::uint8_t goals_against
Definition holiday.h:113
The assistant's report when the manager returns.
Definition holiday.h:128
int position_before
Definition holiday.h:137
int points_after
Definition holiday.h:141
std::int64_t balance_before
Definition holiday.h:142
GameDateValue end
Definition holiday.h:131
std::vector< HolidayResult > results
Definition holiday.h:136
HolidayStop reason
Definition holiday.h:133
std::string stop_detail
Definition holiday.h:134
int days
Definition holiday.h:132
std::vector< HolidayInjury > injuries
Definition holiday.h:147
std::int64_t income
Definition holiday.h:144
std::int64_t stop_amount
Definition holiday.h:135
int messages_filed
Definition holiday.h:148
bool valid
Definition holiday.h:129
int position_after
Definition holiday.h:138
int points_before
Definition holiday.h:139
std::vector< HolidayMove > moves
Definition holiday.h:146
std::int64_t expenses
Definition holiday.h:145
int played_before
Definition holiday.h:140
GameDateValue start
Definition holiday.h:130
std::int64_t balance_after
Definition holiday.h:143
MatchType
Represents the type or category of a match.
Definition types.h:40
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