Exclusive sponsor from training camp stays (Modern)

The Middle East camps share their grades but differ in price; a stay
can now bring an exclusive sponsor: 15 / 30 / 45 % per stay (Doha /
Abu Dhabi / Dubai), a shirt (about every third offer) or four boards at
twice the club's best regular offer for 12 months. Accepted on a free
place it starts at once, otherwise it is queued and starts at a month
change once the place is free. The offer goes through the regular
advertising acceptance.

Camp fields sponsor_chance / sponsor_bonus / sponsor_months (data
format F4, editable; built-in values for the Middle East camps), state
saved in state/modern.json, read query {kind: "sponsor"}, session action
dispatch_exclusive_sponsor, tests in modern_camp_tests, SIM_SPONSOR=1.
Sponsor artwork does not exist yet (asset: null, documented).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-25 09:15:38 +01:00
1 parent 44a7a77915
commit 77d1f93e8f
20 files changed
+333 -13

No files matched your search

+30 -1
View File
@@ -4,6 +4,7 @@
#include <algorithm>
#include <bit>
#include <utility>
#include <variant>
#include "content/digest.hpp"
#include "content/package.hpp"
@@ -44,6 +45,32 @@ std::vector<std::string> strings(const J& value) {
}
std::string world_identity(const World& world) { return world.id + "@" + world.data_revision; }
// Exclusive sponsor offers and queued contracts per manager (docs/new_engine/trainingslager.md).
J sponsors_json(const std::vector<ModernState::ExclusiveSponsor>& sponsors) {
A out;
for (const auto& s : sponsors)
out.push_back(O{{"offered", s.offered}, {"queued", s.queued}, {"kind", int(s.kind)}, {"units", int(s.units)},
{"months", int(s.months)}, {"sponsor", int(s.sponsor)}, {"monthly", int64_t(s.monthly)}, {"score", int(s.score)}, {"camp", s.camp}});
return out;
}
std::vector<ModernState::ExclusiveSponsor> sponsors_json(const J& value) {
std::vector<ModernState::ExclusiveSponsor> out;
for (const J& row : arr(value)) {
ModernState::ExclusiveSponsor s;
const J& offered = get(row, "offered");
const J& queued = get(row, "queued");
if (!std::holds_alternative<bool>(offered.value) || !std::holds_alternative<bool>(queued.value)) fail("invalid sponsor flags");
s.offered = std::get<bool>(offered.value), s.queued = std::get<bool>(queued.value);
s.kind = uint8_t(num(get(row, "kind"))), s.units = uint8_t(num(get(row, "units")));
s.months = uint8_t(num(get(row, "months"))), s.sponsor = uint8_t(num(get(row, "sponsor")));
s.monthly = uint32_t(num(get(row, "monthly"))), s.camp = str(get(row, "camp"));
s.score = uint16_t(num(get(row, "score")));
if (s.kind > 1 || s.units > 14 || s.sponsor > 9) fail("invalid exclusive sponsor");
out.push_back(std::move(s));
}
return out;
}
// The Toto columns 2-6 and the last settlement per manager (docs/new_engine/toto.md).
J pools_json(const std::vector<ModernState::PoolsColumns>& pools) {
A out;
@@ -107,7 +134,8 @@ void save_world_career(const std::filesystem::path& path, const World& world, co
{"league_ids", strings(state.world_league_id)},
{"league_names", strings(state.world_league_name)},
{"generated_players", int64_t(state.almanac.generated_players)},
{"pools", pools_json(state.pools)}});
{"pools", pools_json(state.pools)},
{"exclusive_sponsors", sponsors_json(state.exclusive_sponsors)}});
// The almanac: finished seasons unchanged, the running one encoded now.
for (const auto& [name, bytes] : state.almanac.finished) docs[name] = bytes;
if (state.almanac.current.season >= 0) docs["history/current.bin"] = encode_almanac_season(state.almanac.current);
@@ -156,6 +184,7 @@ SavedWorldCareer load_world_career(const std::filesystem::path& path, const Worl
out.state.world_league_name = strings(get(modern, "league_names"));
out.state.almanac.generated_players = uint32_t(num(get(modern, "generated_players")));
out.state.pools = pools_json(get(modern, "pools"));
out.state.exclusive_sponsors = sponsors_json(get(modern, "exclusive_sponsors"));
for (const auto& [name, bytes] : docs) {
if (!name.starts_with("history/season-")) continue;
decode_almanac_season(bytes); // a damaged season fails here, not in the almanac screen