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

+50
View File
@@ -5,6 +5,7 @@
#include <set>
#include <string>
#include "formats/executable_layout.hpp"
#include "game/random.hpp"
#include "modern/game/desk_actions.hpp"
#include "modern/game/training_camps.hpp"
@@ -117,6 +118,55 @@ int main() {
check(training_camp_booking_block(g, 0) == TrainingCampBookingBlock::invalid_request,
"no camp at the national coach's desk");
}
{
// Exclusive sponsor: a camp without a sponsor chance draws nothing; an accepted offer
// starts at once on a free place, waits for a taken one and starts when it is free.
ModernState g = squad();
g.training_camps = {camp({6, 6, 6, 6})};
g.memory.add_block(::bmh::layout::AdGroupId, 1);
WatcomRandom rand(5);
const uint64_t calls = rand.calls();
roll_exclusive_sponsor(g, 0, 0, rand);
check(rand.calls() == calls && (g.exclusive_sponsors.empty() || !g.exclusive_sponsors[0].offered),
"no sponsor chance: no draw, no offer");
check(answer_exclusive_sponsor(g, 0, true) == ExclusiveSponsorAnswer::invalid, "no offer to answer");
const auto row = [&](int slot) { return size_t(0xa34 + slot * 0xc); };
const auto amount = [&](int slot) {
const size_t at = row(slot);
return uint32_t(g.manager_records[at]) | uint32_t(g.manager_records[at + 1]) << 8 |
uint32_t(g.manager_records[at + 2]) << 16 | uint32_t(g.manager_records[at + 3]) << 24;
};
ModernState::ExclusiveSponsor shirt;
shirt.offered = true, shirt.kind = 1, shirt.units = 1, shirt.months = 12, shirt.sponsor = 3;
shirt.monthly = 300000, shirt.score = 50, shirt.camp = "resort:test";
g.exclusive_sponsors = {shirt};
check(answer_exclusive_sponsor(g, 0, true) == ExclusiveSponsorAnswer::started, "free shirt: starts at once");
check(amount(14) == 300000 && g.manager_records[row(14) + 5] == 12 && !g.exclusive_sponsors[0].offered,
"shirt contract installed (amount, months)");
shirt.monthly = 350000;
g.exclusive_sponsors = {shirt};
check(answer_exclusive_sponsor(g, 0, true) == ExclusiveSponsorAnswer::queued, "taken shirt: queued");
check(amount(14) == 300000 && g.exclusive_sponsors[0].queued, "running shirt contract untouched");
start_queued_exclusive_sponsor(g, 0);
check(g.exclusive_sponsors[0].queued, "still queued while the shirt is taken");
for (size_t i = 0; i < 0xc; ++i) g.manager_records[row(14) + i] = 0; // the running contract ended
start_queued_exclusive_sponsor(g, 0);
check(amount(14) == 350000 && !g.exclusive_sponsors[0].queued, "queued shirt starts once free");
ModernState::ExclusiveSponsor boards = shirt;
boards.kind = 0, boards.units = 4, boards.monthly = 40000;
g.exclusive_sponsors = {boards};
check(answer_exclusive_sponsor(g, 0, true) == ExclusiveSponsorAnswer::started, "four free boards: start at once");
int taken = 0;
for (int slot = 0; slot < 14; ++slot) taken += amount(slot) == 40000;
check(taken == 4, "four boards installed");
g.exclusive_sponsors = {shirt};
check(answer_exclusive_sponsor(g, 0, false) == ExclusiveSponsorAnswer::declined && !g.exclusive_sponsors[0].offered,
"declined offer is gone");
}
if (failures) return 1;
std::puts("modern camp checks passed");
return 0;