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
@@ -1481,6 +1481,7 @@ bool book_training_camp(ModernState& g, int manager, int resort, WatcomRandom& r
|
||||
uint8_t& stays = g.manager_records.at(rec + kStays);
|
||||
stays = uint8_t((stays + 1) | 0x80);
|
||||
modern::training_camp_effect(g, manager, resort, rand);
|
||||
modern::roll_exclusive_sponsor(g, manager, resort, rand); // Modern: a chance of an exclusive sponsor
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2159,6 +2160,106 @@ AdvertisingOfferResult accept_advertising_offer(ModernState& g,
|
||||
return result;
|
||||
}
|
||||
|
||||
// --- Exclusive sponsor (Modern) -------------------------------------------------------------
|
||||
// OpenBMH deviates from the original: in Modern a training camp stay can bring an exclusive sponsor (shirt or four boards at twice the best regular offer), taken now or after the running contract.
|
||||
namespace {
|
||||
|
||||
ModernState::ExclusiveSponsor& exclusive_sponsor(ModernState& g, int manager) {
|
||||
if (g.exclusive_sponsors.size() < g.manager_teams.size()) g.exclusive_sponsors.resize(g.manager_teams.size());
|
||||
return g.exclusive_sponsors.at(size_t(manager));
|
||||
}
|
||||
|
||||
// The offer goes through the regular acceptance: it is written over the last offer of its pool
|
||||
// and accepted there, so boards, sorting and group ids follow the original rules. Nothing
|
||||
// changes (the pool offer is restored) when the place is taken.
|
||||
bool install_exclusive_sponsor(ModernState& g, int manager, const ModernState::ExclusiveSponsor& s) {
|
||||
if (!ad_manager_record_valid(g, manager)) return false;
|
||||
const size_t rec = size_t(manager) * kAdRecord;
|
||||
const int group = s.kind == 1 ? 1 : 0;
|
||||
constexpr int kRaw = 9;
|
||||
const size_t at = rec + kAdPool + size_t(group) * 0x78 + size_t(kRaw) * kAdContractBytes;
|
||||
std::array<uint8_t, kAdContractBytes> saved{};
|
||||
std::copy_n(g.manager_records.begin() + std::ptrdiff_t(at), kAdContractBytes, saved.begin());
|
||||
auto& r = g.manager_records;
|
||||
const uint16_t score = s.score;
|
||||
for (size_t i = 0; i < 4; ++i) r.at(at + i) = uint8_t(s.monthly >> (8 * i));
|
||||
r.at(at + 4) = s.kind == 1 ? 1 : s.units;
|
||||
r.at(at + 5) = s.months;
|
||||
r.at(at + 6) = 0;
|
||||
r.at(at + 7) = s.sponsor;
|
||||
r.at(at + 8) = uint8_t(score), r.at(at + 9) = uint8_t(score >> 8);
|
||||
const int display = s.kind == 1 ? 14 : 13;
|
||||
const AdvertisingOfferList view = modern::advertising_offers(g, manager, display);
|
||||
bool accepted = false;
|
||||
for (const AdvertisingOfferCandidate& c : view.offers)
|
||||
if (c.raw_slot == kRaw && c.can_accept) {
|
||||
AdvertisingOfferRequest request;
|
||||
request.manager = manager;
|
||||
request.display_slot = display;
|
||||
request.contract_slot = view.contract_slot;
|
||||
request.expected_contract = view.contract_bytes;
|
||||
request.raw_slot = kRaw;
|
||||
request.expected_offer = c.bytes;
|
||||
accepted = modern::accept_advertising_offer(g, request).status == AdvertisingOfferStatus::accepted;
|
||||
}
|
||||
if (!accepted) std::copy(saved.begin(), saved.end(), r.begin() + std::ptrdiff_t(at));
|
||||
return accepted;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void roll_exclusive_sponsor(ModernState& g, int manager, int resort, WatcomRandom& rand) {
|
||||
if (manager < 0 || size_t(manager) >= g.manager_teams.size() || resort < 0 || size_t(resort) >= g.training_camps.size())
|
||||
return;
|
||||
const TrainingCamp& camp = g.training_camps[size_t(resort)];
|
||||
if (camp.sponsor_chance <= 0) return; // (no draw: camps without a sponsor keep the stream)
|
||||
ModernState::ExclusiveSponsor& s = exclusive_sponsor(g, manager);
|
||||
if (s.offered || s.queued) return; // one offer or contract at a time
|
||||
if (rand.range(1, 100) > camp.sponsor_chance) return;
|
||||
const AdvertisingBase value = modern::advertising_base(g, manager);
|
||||
const bool shirt = rand.range(0, 2) == 0;
|
||||
// the best regular offer: offer k = 9 at the top of its +-25 % (TransferListCountdown2)
|
||||
int best = shirt ? (value.base >> 2) * (0x50 + 9 * 4) / 100 : ((value.base / 2) / 8) * (0x46 + 9 * 6) / 100;
|
||||
best += best >> 2;
|
||||
s = {};
|
||||
s.offered = true;
|
||||
s.kind = shirt ? 1 : 0;
|
||||
s.units = shirt ? 1 : 4;
|
||||
s.months = uint8_t(std::clamp(camp.sponsor_months, 1, 60));
|
||||
s.sponsor = uint8_t(rand.range(0, 9));
|
||||
s.monthly = uint32_t(std::max(0, int(int64_t(best) * camp.sponsor_bonus / 100)));
|
||||
s.camp = camp.id;
|
||||
s.score = uint16_t(value.score);
|
||||
// (Modern has no text catalogue yet; the sponsor's name is one of the advertising firms)
|
||||
const std::string sponsor = message_text(g, ::bmh::layout::Advertising_FormatError_ExecutableField3 + uint32_t(s.sponsor) * 4);
|
||||
post_composed(g, manager, "Exklusiv-Sponsor: " + sponsor + " bietet Ihnen nach Ihrem Aufenthalt in " + camp.place +
|
||||
(shirt ? " die Trikotwerbung" : " vier Banden") + " f}r " + format_amount(g, int32_t(s.monthly)) +
|
||||
(shirt ? "" : " je Bande") + " monatlich an (" + std::to_string(s.months) + " Monate).");
|
||||
}
|
||||
|
||||
ExclusiveSponsorAnswer answer_exclusive_sponsor(ModernState& g, int manager, bool accept) {
|
||||
if (manager < 0 || size_t(manager) >= g.manager_teams.size()) return ExclusiveSponsorAnswer::invalid;
|
||||
ModernState::ExclusiveSponsor& s = exclusive_sponsor(g, manager);
|
||||
if (!s.offered) return ExclusiveSponsorAnswer::invalid;
|
||||
if (!accept) {
|
||||
s = {};
|
||||
return ExclusiveSponsorAnswer::declined;
|
||||
}
|
||||
if (install_exclusive_sponsor(g, manager, s)) {
|
||||
s = {};
|
||||
return ExclusiveSponsorAnswer::started;
|
||||
}
|
||||
s.offered = false;
|
||||
s.queued = true;
|
||||
return ExclusiveSponsorAnswer::queued;
|
||||
}
|
||||
|
||||
void start_queued_exclusive_sponsor(ModernState& g, int manager) {
|
||||
if (manager < 0 || size_t(manager) >= g.exclusive_sponsors.size()) return;
|
||||
ModernState::ExclusiveSponsor& s = g.exclusive_sponsors[size_t(manager)];
|
||||
if (s.queued && install_exclusive_sponsor(g, manager, s)) s = {};
|
||||
}
|
||||
|
||||
AdvertisingSpendingView advertising_spending(const ModernState& g, int manager, int target_slot) {
|
||||
AdvertisingSpendingView view;
|
||||
view.manager = manager;
|
||||
|
||||
@@ -307,6 +307,18 @@ AdvertisingOfferList advertising_offers(const ModernState& g, int manager, int d
|
||||
AdvertisingOfferResult accept_advertising_offer(ModernState& g,
|
||||
const AdvertisingOfferRequest& request);
|
||||
|
||||
// Exclusive sponsor from a training camp stay (Modern; docs/new_engine/trainingslager.md).
|
||||
// book_training_camp rolls the camp's sponsor_chance; a hit offers a shirt (about every third
|
||||
// offer) or four boards at sponsor_bonus percent of the club's best regular offer for
|
||||
// sponsor_months months, and posts a message. One offer or queued contract per manager.
|
||||
void roll_exclusive_sponsor(ModernState& g, int manager, int resort, WatcomRandom& rand);
|
||||
enum class ExclusiveSponsorAnswer { declined, started, queued, invalid };
|
||||
// The manager's answer. Accepted: the contract starts now when its place is free (the shirt
|
||||
// without a running contract, enough free boards), else it waits for the place (queued).
|
||||
ExclusiveSponsorAnswer answer_exclusive_sponsor(ModernState& g, int manager, bool accept);
|
||||
// At the month change: a queued contract starts once its place is free.
|
||||
void start_queued_exclusive_sponsor(ModernState& g, int manager);
|
||||
|
||||
// CheckAdvertisingRenewal: a click on a contract whose months ran out (sponsor set, months 0 - the
|
||||
// month change posted "kann verlängert werden", Month_MonthChange_TextPointer). The sponsor's demand (word
|
||||
// +8, the club attraction it wants) is scaled by W(95, 105) % (WatcomRandom); if it stays
|
||||
|
||||
@@ -63,6 +63,20 @@ struct ModernState : GameState {
|
||||
bool operator==(const PoolsColumns&) const = default;
|
||||
};
|
||||
std::vector<PoolsColumns> pools;
|
||||
// Exclusive sponsor from a training camp stay (docs/new_engine/trainingslager.md), per manager.
|
||||
struct ExclusiveSponsor {
|
||||
bool offered = false; // an offer waits for the manager's answer
|
||||
bool queued = false; // accepted while the place was taken: starts when it is free
|
||||
uint8_t kind = 0; // 0 boards, 1 shirt
|
||||
uint8_t units = 0; // boards of a board offer
|
||||
uint8_t months = 0; // contract months
|
||||
uint8_t sponsor = 0; // sponsor name index of the advertising list
|
||||
uint32_t monthly = 0; // per board / for the shirt, per month
|
||||
uint16_t score = 0; // the club's advertising score when offered (offer byte +8)
|
||||
std::string camp; // the camp that brought it
|
||||
bool operator==(const ExclusiveSponsor&) const = default;
|
||||
};
|
||||
std::vector<ExclusiveSponsor> exclusive_sponsors;
|
||||
// Players whose age the data set gives (birth date); the others carry a placeholder the
|
||||
// career start replaces as in the original. Needed only while a career starts (not saved).
|
||||
std::vector<bool> world_age_known;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "modern/game/modern_state.hpp"
|
||||
#include "modern/game/environment.hpp"
|
||||
#include "modern/game/month.hpp"
|
||||
#include "modern/game/desk_actions.hpp"
|
||||
#include "game/trace.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -959,6 +960,8 @@ void month_change(ModernState& g, WatcomRandom& rand, MinuteReport& report, Game
|
||||
else turn_step = "month_change: advertising text", post_text(g, m, text_id(::bmh::layout::Month_MonthChange_TextPointer)); // the contract can be renewed
|
||||
}
|
||||
}
|
||||
// Modern: a queued exclusive sponsor starts once its place is free (trainingslager.md)
|
||||
for (int m = 0; m < managers; m++) modern::start_queued_exclusive_sponsor(g, m);
|
||||
// 2. new players on the transfer list
|
||||
turn_step = "month_change: new list entries";
|
||||
new_list_entries(g, rand, report);
|
||||
|
||||
@@ -39,6 +39,11 @@ const CampCatalogue& default_camp_catalogue() {
|
||||
camp(15, "map:me", "Abu Dhabi Royal Training", "Abu Dhabi", "nation:ae", {6, 6, 6, 6}, 3200000);
|
||||
camp(16, "map:me", "Dubai Platinum Sports Camp", "Dubai", "nation:ae", {6, 6, 6, 6}, 3600000);
|
||||
camp(17, "map:eu", "Riviera Trainingscamp Belek", "Belek", "nation:tr", {5, 5, 5, 4}, 790000);
|
||||
// The Middle East camps share their grades; a stay can bring an exclusive sponsor, the
|
||||
// dearer the camp the likelier (15 / 30 / 45 %; trainingslager.md).
|
||||
c.camps[14].sponsor_chance = 15;
|
||||
c.camps[15].sponsor_chance = 30;
|
||||
c.camps[16].sponsor_chance = 45;
|
||||
return c;
|
||||
}();
|
||||
return catalogue;
|
||||
|
||||
@@ -29,6 +29,9 @@ struct TrainingCamp {
|
||||
std::string name, place, country;
|
||||
int32_t base_price = 0; // the price is base_price + 5000 per squad player
|
||||
std::array<uint8_t, 4> quality{}; // pitch, fitness, catering, lodging (0-6)
|
||||
// Exclusive sponsor (docs/new_engine/trainingslager.md): chance per stay in percent (0 = none),
|
||||
// the offer's amount in percent of the best regular offer, its contract months.
|
||||
int sponsor_chance = 0, sponsor_bonus = 200, sponsor_months = 12;
|
||||
};
|
||||
|
||||
struct CampCatalogue {
|
||||
|
||||
+18
-11
@@ -497,18 +497,8 @@ int club_attraction(const ModernState& g, int team) {
|
||||
return std::clamp(v, 0, 100);
|
||||
}
|
||||
|
||||
void advertising_offers(ModernState& g, int manager, WatcomRandom& rand, MinuteReport& report) {
|
||||
(void)report;
|
||||
if (g.memory.u8(::bmh::layout::CareerDuration) == 1) return;
|
||||
AdvertisingBase advertising_base(ModernState& g, int manager) {
|
||||
Record rec = record(g, manager);
|
||||
if (manager == 0) {
|
||||
// "Es gibt neue Werbeangebote!" to every manager with a free advertising slot
|
||||
uint32_t mask = 0x80000000u;
|
||||
for (size_t m = 0; m < g.manager_teams.size(); m++)
|
||||
for (int k = 0; k < 0x10; k++)
|
||||
if (g.manager_records.at(m * kRecord + 0xa39 + size_t(k) * 0xc) == 0) mask |= 1u << m;
|
||||
if (mask != 0x80000000u) post_text(g, int64_t(mask), text_id(::bmh::layout::Weekly_AdvertisingOffers_TextPointer));
|
||||
}
|
||||
int score = int16_t(int8_t(modern::club_attraction(g, int16_t(rec.u16(0x290)))));
|
||||
if (g.memory.u8(::bmh::layout::GameMode) == 3 && g.league_rounds.at(size_t(league_of(int16_t(rec.u16(0x290))))) > 0x11) {
|
||||
int t = rec.i32(0x320) / 100000;
|
||||
@@ -521,6 +511,23 @@ void advertising_offers(ModernState& g, int manager, WatcomRandom& rand, MinuteR
|
||||
score = int16_t(score) * 100 / 0x78;
|
||||
int base = (int16_t(score) * 60000 + 1000000) / 0xc;
|
||||
base = ((0xb4 - g.level * 5) * base) / 100;
|
||||
return {score, base};
|
||||
}
|
||||
|
||||
void advertising_offers(ModernState& g, int manager, WatcomRandom& rand, MinuteReport& report) {
|
||||
(void)report;
|
||||
if (g.memory.u8(::bmh::layout::CareerDuration) == 1) return;
|
||||
Record rec = record(g, manager);
|
||||
if (manager == 0) {
|
||||
// "Es gibt neue Werbeangebote!" to every manager with a free advertising slot
|
||||
uint32_t mask = 0x80000000u;
|
||||
for (size_t m = 0; m < g.manager_teams.size(); m++)
|
||||
for (int k = 0; k < 0x10; k++)
|
||||
if (g.manager_records.at(m * kRecord + 0xa39 + size_t(k) * 0xc) == 0) mask |= 1u << m;
|
||||
if (mask != 0x80000000u) post_text(g, int64_t(mask), text_id(::bmh::layout::Weekly_AdvertisingOffers_TextPointer));
|
||||
}
|
||||
const AdvertisingBase value = modern::advertising_base(g, manager);
|
||||
const int score = value.score, base = value.base;
|
||||
for (int kind = 0; kind < 3; kind++)
|
||||
for (int k = 0; k < 10; k++) {
|
||||
const size_t o = 0x8cc + size_t(kind) * 0x78 + size_t(k) * 0xc;
|
||||
|
||||
@@ -52,6 +52,11 @@ void season_ticket_compensation(ModernState& g, int manager);
|
||||
void season_ticket_compensation_source(ModernState& g, int manager,
|
||||
const SeasonTicketCompensationNoticeHook& notice = {});
|
||||
void advertising_offers(ModernState& g, int manager, WatcomRandom& rand, MinuteReport& report); // TransferListCountdown2
|
||||
// The club's advertising score and the base of its offers (TransferListCountdown2, no draws): a
|
||||
// board offer is about base / 16 per board and month, a shirt offer base / 4 (offer k: 70 + 6k
|
||||
// resp. 80 + 4k percent of that, then +-25 %).
|
||||
struct AdvertisingBase { int score = 0, base = 0; };
|
||||
AdvertisingBase advertising_base(ModernState& g, int manager);
|
||||
// TransferListCountdown(all): the days left of every listed player count down; at 0 the best bid wins
|
||||
// (with `all`, at the season end, every list is settled at once)
|
||||
void transfer_list_countdown(ModernState& g, GameRandom& game, WatcomRandom& rand, MinuteReport& report, bool all = false,
|
||||
|
||||
Reference in new issue
Block a user