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:
1 parent
44a7a77915
commit
77d1f93e8f
20 files changed
+333
-13
No files matched your search
@@ -7,6 +7,7 @@
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
#include "game/messages.hpp"
|
||||
#include "game/schedule.hpp"
|
||||
#include "game/table.hpp"
|
||||
#include "modern/content/statistics.hpp"
|
||||
@@ -203,6 +204,27 @@ J squad(const ModernState& g, int team) {
|
||||
return O{{"ok", true}, {"club", club_json(g, team)}, {"players", std::move(players)}};
|
||||
}
|
||||
|
||||
// The manager's exclusive sponsor offer or queued contract (docs/new_engine/trainingslager.md).
|
||||
// "asset" stays null: there is no artwork for these sponsors yet.
|
||||
J sponsor(const ModernState& g, int manager) {
|
||||
if (manager < 0 || size_t(manager) >= g.manager_teams.size()) return error("invalid_manager");
|
||||
J offer = nullptr, queued = nullptr;
|
||||
if (size_t(manager) < g.exclusive_sponsors.size()) {
|
||||
const auto& s = g.exclusive_sponsors[size_t(manager)];
|
||||
if (s.offered || s.queued) {
|
||||
std::string camp_name;
|
||||
for (const auto& c : g.training_camps)
|
||||
if (c.id == s.camp) camp_name = c.name;
|
||||
J row = O{{"kind", s.kind == 1 ? "shirt" : "boards"}, {"boards", s.kind == 1 ? 0 : int(s.units)},
|
||||
{"monthly", int64_t(s.monthly)}, {"months", int(s.months)},
|
||||
{"sponsor", almanac_utf8(message_text(g, ::bmh::layout::Advertising_FormatError_ExecutableField3 + uint32_t(s.sponsor) * 4))},
|
||||
{"asset", nullptr}, {"camp", O{{"id", s.camp}, {"name", camp_name}}}};
|
||||
(s.offered ? offer : queued) = std::move(row);
|
||||
}
|
||||
}
|
||||
return O{{"ok", true}, {"offer", std::move(offer)}, {"queued", std::move(queued)}};
|
||||
}
|
||||
|
||||
// The Toto coupon of the matchday and the manager's columns (docs/new_engine/toto.md).
|
||||
J toto(const ModernState& g, int manager) {
|
||||
if (manager < 0 || size_t(manager) >= g.manager_teams.size()) return error("invalid_manager");
|
||||
@@ -255,6 +277,7 @@ cli::Json query_projection(const ModernState& g, int manager, const cli::Json& r
|
||||
try {
|
||||
if (k == "status") return status(g, manager);
|
||||
if (k == "toto") return toto(g, manager);
|
||||
if (k == "sponsor") return sponsor(g, manager);
|
||||
if (k == "leagues") return leagues(g);
|
||||
if (k == "table" || k == "fixtures") {
|
||||
const int league = league_of_request(g, field(request, "league"));
|
||||
|
||||
@@ -138,6 +138,13 @@ World read_world(const obw::Documents& documents) {
|
||||
camp.quality[k] = uint8_t(grade);
|
||||
}
|
||||
if (camp.base_price < 0) fail("negative training camp price: " + camp.id);
|
||||
// exclusive sponsor (optional; -1 = not given: the built-in values of the same camp id apply)
|
||||
camp.sponsor_chance = integer(find(c, "sponsor_chance"), -1);
|
||||
camp.sponsor_bonus = integer(find(c, "sponsor_bonus"), 200);
|
||||
camp.sponsor_months = integer(find(c, "sponsor_months"), 12);
|
||||
if (camp.sponsor_chance > 100 || camp.sponsor_bonus < 100 || camp.sponsor_bonus > 500 ||
|
||||
camp.sponsor_months < 1 || camp.sponsor_months > 60)
|
||||
fail("training camp sponsor values out of range: " + camp.id);
|
||||
catalogue.camps.push_back(std::move(camp));
|
||||
}
|
||||
w.camps = std::move(catalogue);
|
||||
|
||||
@@ -462,6 +462,18 @@ void install_training_camps(ModernState& g, const World& world) {
|
||||
if (catalogue.camps.empty()) obw::detail::fail("the training camp catalogue is empty");
|
||||
g.camp_maps = catalogue.maps;
|
||||
g.training_camps = catalogue.camps;
|
||||
// A camp without sponsor values takes those of the built-in camp with the same id (the
|
||||
// Middle East camps), else none.
|
||||
for (TrainingCamp& camp : g.training_camps) {
|
||||
if (camp.sponsor_chance >= 0) continue;
|
||||
camp.sponsor_chance = 0;
|
||||
for (const TrainingCamp& built_in : default_camp_catalogue().camps)
|
||||
if (built_in.id == camp.id) {
|
||||
camp.sponsor_chance = built_in.sponsor_chance;
|
||||
camp.sponsor_bonus = built_in.sponsor_bonus;
|
||||
camp.sponsor_months = built_in.sponsor_months;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace bmh::modern
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user