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
@@ -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;
|
||||
|
||||
@@ -493,6 +493,7 @@ int main(int argc, char** argv) {
|
||||
bool listed_for_sale = false;
|
||||
int ad_contracts = 0; // SIM_ADVERTISING: contracts accepted
|
||||
int camp_stays = 0; // SIM_CAMP: training camp stays booked
|
||||
int sponsor_offers = 0, sponsor_started = 0, sponsor_queued = 0; // SIM_SPONSOR
|
||||
for (; played < turns; played++) {
|
||||
// SIM_ADVERTISING=1: the manager keeps his advertising places filled, as every
|
||||
// player does (the largest income besides the gate): an expired contract is renewed
|
||||
@@ -506,6 +507,16 @@ int main(int argc, char** argv) {
|
||||
if (modern::training_camp_booking_block(g, 0) == TrainingCampBookingBlock::none &&
|
||||
modern::book_training_camp(g, 0, resort, session.rand()))
|
||||
++camp_stays;
|
||||
// SIM_SPONSOR=1: an exclusive sponsor offer from the stay is accepted
|
||||
if (std::getenv("SIM_SPONSOR") && !g.exclusive_sponsors.empty() && g.exclusive_sponsors[0].offered) {
|
||||
++sponsor_offers;
|
||||
std::printf("exclusive sponsor offer at turn %d: %s, %u per month%s, %d months\n", played,
|
||||
g.exclusive_sponsors[0].kind == 1 ? "shirt" : "4 boards", g.exclusive_sponsors[0].monthly,
|
||||
g.exclusive_sponsors[0].kind == 1 ? "" : " per board", int(g.exclusive_sponsors[0].months));
|
||||
const auto answer = modern::answer_exclusive_sponsor(g, 0, true);
|
||||
sponsor_started += answer == modern::ExclusiveSponsorAnswer::started;
|
||||
sponsor_queued += answer == modern::ExclusiveSponsorAnswer::queued;
|
||||
}
|
||||
}
|
||||
// SIM_TOTO=<columns>: the manager plays the Toto whenever a coupon is open, 400,000 in
|
||||
// all spread over the columns: the stronger side (team strength) wins, column k > 1
|
||||
@@ -683,6 +694,9 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
if (std::getenv("SIM_ADVERTISING")) std::printf("%d advertising contracts accepted (SIM_ADVERTISING=1)\n", ad_contracts);
|
||||
if (std::getenv("SIM_CAMP")) std::printf("%d training camp stays (SIM_CAMP=%s)\n", camp_stays, std::getenv("SIM_CAMP"));
|
||||
if (std::getenv("SIM_SPONSOR"))
|
||||
std::printf("exclusive sponsors: %d offers, %d started at once, %d queued (SIM_SPONSOR=1)\n", sponsor_offers,
|
||||
sponsor_started, sponsor_queued);
|
||||
if (std::getenv("SIM_TOTO")) {
|
||||
int won_coupons = 0;
|
||||
std::printf("toto (SIM_TOTO=%s): %d coupons, paid %llu, won %llu, return %.1f %%; hits per column:", std::getenv("SIM_TOTO"),
|
||||
|
||||
Reference in new issue
Block a user