International marketing: a monthly budget builds up reach abroad
The reach grows over a year or two towards what the budget holds, falls faster when the budget is cut, and brings income every month by league and prestige. The investments page sets the budget and shows reach and income. Engine: marketing.hpp, read advertising.internationalMarketing, command marketing.commit; saved in state/modern.json. Also fixes the monthly amount on the naming rights tile, which was shown a hundredth too small. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
97acf0d74d
commit
7b3f52d809
18 files changed
+327
-7
No files matched your search
@@ -1236,6 +1236,9 @@ add_test(NAME modern_assembly_tests COMMAND modern_assembly_tests)
|
||||
add_executable(modern_naming_tests tests/modern_naming_tests.cpp)
|
||||
target_link_libraries(modern_naming_tests PRIVATE bmh_season_modern)
|
||||
add_test(NAME modern_naming_tests COMMAND modern_naming_tests)
|
||||
add_executable(modern_marketing_tests tests/modern_marketing_tests.cpp)
|
||||
target_link_libraries(modern_marketing_tests PRIVATE bmh_season_modern)
|
||||
add_test(NAME modern_marketing_tests COMMAND modern_marketing_tests)
|
||||
add_executable(modern_almanac_tests tests/modern_almanac_tests.cpp)
|
||||
target_link_libraries(modern_almanac_tests PRIVATE bmh_modern_content)
|
||||
add_test(NAME modern_almanac_tests COMMAND modern_almanac_tests)
|
||||
|
||||
@@ -52,6 +52,7 @@ describe deliberate changes; they are not a list of every known compatibility li
|
||||
- [src/modern/content/statistics.cpp](../src/modern/content/statistics.cpp): Modern chooses its own eleven of the day per league from the recorded facts of the matchday (goals, assists, cards, result, clean sheets) instead of the original's Sportschau rating, and words the ticker from several variants per event.
|
||||
- [src/modern/game/matchday_setup.cpp](../src/modern/game/matchday_setup.cpp): in Modern worlds a referee may take a second match on a day with more matches than referees.
|
||||
- [src/modern/game/month.cpp](../src/modern/game/month.cpp): in Modern every manager receives the monthly dividend of his own shares; the price product is kept in 64 bits until the division.
|
||||
- [src/modern/game/marketing.cpp](../src/modern/game/marketing.cpp): in Modern a monthly budget for international marketing builds up reach abroad, which brings monthly income by league and prestige.
|
||||
- [src/modern/game/naming_rights.cpp](../src/modern/game/naming_rights.cpp): in Modern a manager names his stadium and can sell the name to a sponsor for one to five years; the sponsor pays monthly and the name is fixed until the contract ends.
|
||||
- [src/modern/game/season.cpp](../src/modern/game/season.cpp): retains the enhanced academy player-generation strength bands with monthly youth budgets.
|
||||
- [src/modern/game/season.cpp](../src/modern/game/season.cpp): in Modern the age stops at 47, the most its five bits hold; real ages of a data set (a goalkeeper of 40) would otherwise run into the bits above.
|
||||
|
||||
@@ -13,6 +13,7 @@ Grundlage ist der [Engine-Split](../ENGINE_SPLIT.md); die Oberfläche ist in
|
||||
| [Trainingslager](trainingslager.md) | Katalog, Preis, Wirkung und die neue 6-Sterne-Stufe |
|
||||
| [Jahreshauptversammlung](hauptversammlung.md) | Abstimmung am Saisonende, interessierte Vereine, Vereinswechsel |
|
||||
| [Namensrecht](namensrecht.md) | Stadionname, Angebote der Sponsoren, monatliche Zahlung |
|
||||
| [Internationale Vermarktung](vermarktung.md) | Monatsbudget, Reichweite im Ausland, Einnahmen |
|
||||
| [Datenformat](datenformat.md) | **Formatänderungen für Engine und Editor** (F1–F8) |
|
||||
| [Agentenregeln](AGENTS.md) | Arbeitsregeln für diesen Bereich |
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ Revision kommt vom Aufrufer (Konsole bzw. AppController), der Read ändert nicht
|
||||
| `tactics` | die acht Einstellungen (`tactic:0` Grundausrichtung bis `tactic:7` Einsatz) mit Wert und Maximum aus der EXE; die Bedeutung der Diagramm-Einstellungen 1–3, 5, 6 ist nicht belegt, daher neutrale Namen |
|
||||
| `training` | Bälle je Spielertyp und Trainingsbereich (1–3) mit den Grenzen, je Spieler Intensität und Schwerpunkt, ob das Training eingerichtet ist, Automatik-Bits |
|
||||
| `contracts` | je Spieler Restlaufzeit, Monatsgehalt, Versicherung, Prämien; das offene Angebot (`quote`: ID, Spieler, Monatsforderung für 1–4 Jahre, Höchstgehalt 200.000 €) |
|
||||
| `advertising` | 14 Banden (`ad:board/<n>`), Trikot (`ad:shirt`), TV-Rechte (`ad:tv`) je mit Vertrag (Sponsor, Monatsbetrag, Restmonate, Verlängerung, Option) und den offenen Angeboten (`offer:ad-<Platz>-<Nr.>`, Sponsor, Betrag, Banden, Monate, `allowed`); die drei Budgets (Merchandising, Presse, Fanarbeit) mit Stand, Höchstbetrag, Lieferwochen; die Finanzvorschau des Originals |
|
||||
| `advertising` | 14 Banden (`ad:board/<n>`), Trikot (`ad:shirt`), TV-Rechte (`ad:tv`) je mit Vertrag (Sponsor, Monatsbetrag, Restmonate, Verlängerung, Option) und den offenen Angeboten (`offer:ad-<Platz>-<Nr.>`, Sponsor, Betrag, Banden, Monate, `allowed`); die drei Budgets (Merchandising, Presse, Fanarbeit) mit Stand, Höchstbetrag, Lieferwochen; die Finanzvorschau des Originals. Dazu `internationalMarketing` (`budget`, `maxBudget`, `reach`, `targetReach`, `maxReach` in Promille, `income`, `incomeAtTarget`) |
|
||||
| `stadium` | Umfeld (14 Objekte mit Namen und Bautagen; Verkehrsanbindung mit `stage` und `maxStage`: Classic 3, Modern-Welt 4; sonst `built`), die acht Anlagen (Stufe, Höchststufe, Bauwochen, ob ausbaubar), die acht Tribünenblöcke (Plätze, Höchstplätze, Sitzplätze, Dach, Bauwochen, Plätze nach dem Bau), Eintrittspreis (8–25 €); das offene Angebot des Stadion-Dialogs (`quote`: Umfeld mit Preis, oder Anlage mit Zielstufe, Preis, Bauwochen und dem Trinkgeld-Bereich 6–14 %). Dazu der Name: `name` (wie das Stadion heißt), `worldName` (Name des Datensatzes), `nameEditable`, `namingRights` (`null` oder `{sponsor, monthly, monthsLeft}`) und `namingOffers[]` (`id`, `sponsor`, `name`, `monthly`, `months`, `total`) |
|
||||
| `balance` | `view` current/real/future, optional `edits [{id: balance:<0–17>, amount: Money}]`; liefert ursprüngliche Posten/Labels/Grenzen, sechs Zusatzwerte, Abschreibung, Nettoergebnis und Bilanzwarnung. Prognose auf eigener Kopie, kein RNG/Live-Publish. |
|
||||
| `achievements` | Reine Manager-Saisonhistorie am Vereinsschreibtisch: `managerId`, aktuelles `teamId`, `currentSeasonYear`, `records` mit Jahr/Abschlussstatus, Liga-ID/Platz/Teilnehmerzahl und ursprünglichen Pokal-/Europapokalständen samt Text. Keine historische Vereinszuordnung erfinden. `available` bedeutet vorhandene Aufzeichnungen; `originalMenuAvailable` nennt zusätzlich die bisherige Ligaspiel-Sperre. Abgeschlossene Daten bleiben in der Modern UI auch zwischen Saisons lesbar; ungespielte neue Saisons werden nicht ergänzt. Kein RNG oder Schreibvorgang. |
|
||||
@@ -95,6 +95,7 @@ Die UI ruft diese über `DataSource::read_almanac` und `read_statistics` direkt
|
||||
| `environment.commit` | `itemId`, `level` 0–6 | setzt ein Monatsbudget des Umfelds (keine Sofortbuchung, kein Zufall); unverändert: `outcome: no_change`; Fehler `environment_refused` |
|
||||
| `manager.resign.commit` | `confirmed: true` | Aufgeben (neu in Modern, das Original kennt kein Aussteigen). Spielt nur ein Mensch (oder ist er der letzte), endet das Spiel wie mit dem Ablauf der festgelegten Dauer: die Highscore-Tabelle wird fortgeschrieben und angezeigt (der Hook der Saisonwende, erst Aktualisierung, dann Anzeige), `outcome: career_ended`, `ownershipChange` mit `archivedIdentity` (Manager `control: archived`, `status: resigned`, Amtszeiten mit `until` und `endReason: resigned`), `terminationReason: last_human_resigned`; danach antwortet jeder Befehl `career_ended`. Beim Ablauf der Dauer sind die Manager `retired`, die Amtszeiten enden mit `career_end`. Mit weiteren Menschen soll der Computer den Verein übernehmen; das braucht das Nachrücken aller Managertabellen und folgt (`resign_not_supported_yet`). Fehler `confirmation_required` |
|
||||
| `manager.clubChange` | `teamId`, `confirmed: true` | der Manager wechselt zu einem der interessierten Vereine des Reads `assembly` und beginnt dort mit dessen Kasse ([Regeln](hauptversammlung.md)). Fehler: `confirmation_required`, `not_at_desk`, `no_club` (Bundestrainer), `club_change_refused` (Verein nicht auf der Liste) |
|
||||
| `marketing.commit` | `budget` (`Money`, 0–500 000 € in ganzen Tausendern) | das Monatsbudget der [internationalen Vermarktung](vermarktung.md). Fehler: `no_club`, `invalid_budget` |
|
||||
| `stadium.rename` | `name` | benennt das eigene Stadion ([Regeln](namensrecht.md)): 1–40 Zeichen. Fehler: `no_club`, `invalid_name`, `name_sold` (der Name ist verkauft) |
|
||||
| `stadium.namingRights` | `offerId` (`naming:<n>` aus dem Read `stadium`), `confirmed: true` | verkauft den Stadionnamen an den Sponsor des Angebots; er zahlt mit jedem Monatswechsel. Fehler: `confirmation_required`, `name_sold`, `unknown_offer` |
|
||||
| `toto.submit` | `stake` (`Money` je Spalte), `columns` (bis 6 Spalten mit 11 Tipps: 1 Heim, 0 Unentschieden, 2 Auswärts) | gibt den Tippschein ab; Fehler `toto_refused` (z. B. kein offener Schein, Einsatzgrenzen, doppelte Spalte) |
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
# Internationale Vermarktung · Modern-Engine
|
||||
|
||||
Stand: 17. November 2026. Eine Modern-Regel; Classic kennt sie nicht.
|
||||
|
||||
## Regel
|
||||
|
||||
Der Manager legt ein Monatsbudget fest (0 bis 500 000 Euro in ganzen Tausendern). Das Budget
|
||||
kauft Reichweite im Ausland; die Reichweite bringt jeden Monat Einnahmen.
|
||||
|
||||
```
|
||||
Ziel = Budget / 500, höchstens 1000 (Promille)
|
||||
je Monatswechsel:
|
||||
Budget zahlen; reicht das Konto samt Kreditrahmen nicht, gilt der Monat als einer ohne Budget
|
||||
Reichweite unter dem Ziel: + (Ziel − Reichweite) / 6, mindestens 1
|
||||
Reichweite über dem Ziel: − (Reichweite − Ziel) / 4, mindestens 1
|
||||
Einnahme = wirksam × Wert × (60 + Ansehen × 4/5) %
|
||||
wirksam = Reichweite − Reichweite² / 2000 (die volle Reichweite zählt halb)
|
||||
Wert = 1600 / 700 / 300 / 120 / 120 Euro je Punkt (1. bis 5. Liga)
|
||||
```
|
||||
|
||||
- Die Reichweite wächst über etwa ein bis zwei Jahre an und fällt schneller, wenn das Budget
|
||||
gekürzt wird.
|
||||
- In der ersten Liga trägt sich ein mittleres Budget deutlich (200 000 Euro Budget bringen
|
||||
am Ziel rund 510 000 Euro im Monat bei mittlerem Ansehen); in der zweiten nur ein kleines,
|
||||
darunter gar nicht. Jeder weitere Punkt Reichweite ist weniger wert.
|
||||
- Keine Zufallszahl. Die Regel läuft als zweiter Schritt von `month_change`
|
||||
(`modern::marketing_month`).
|
||||
- Bei einem [Vereinswechsel](hauptversammlung.md) bleibt die Reichweite beim alten Verein.
|
||||
|
||||
## Speichern
|
||||
|
||||
`state/modern.json` erhält das optionale Feld `marketing`: je Managerplatz `{budget, reach}`.
|
||||
|
||||
## Anbindung
|
||||
|
||||
Read `advertising`, Feld `internationalMarketing` (`budget`, `maxBudget`, `reach`,
|
||||
`targetReach`, `maxReach`, `income`, `incomeAtTarget`); Befehl `marketing.commit {budget}`
|
||||
(Fehler `no_club`, `invalid_budget`).
|
||||
|
||||
## Prüfung
|
||||
|
||||
`modern_marketing_tests` (ohne Spieldaten): Ziel je Budget, Grenzen des Budgets, Einnahme nach
|
||||
Reichweite, Liga und Ansehen, Aufbau über die Monate, Überschuss am Ziel, Abbau ohne Budget,
|
||||
unbezahlter Monat.
|
||||
|
||||
## Offen
|
||||
|
||||
- Die Zahlungen sind einfache Buchungen ohne eigenen Bilanzposten; die Monatsprognose der
|
||||
Werbeseite enthält sie nicht.
|
||||
- Die Wirkung auf die Wirtschaft über mehrere Saisons ist nicht in einem Langlauf gemessen;
|
||||
die Sätze sind ein erster Ansatz.
|
||||
- Auf der leichtesten Stufe bucht das Spiel kein Geld; die Reichweite wächst dort trotzdem.
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "modern/content/world_save.hpp"
|
||||
#include "modern/game/assembly.hpp"
|
||||
#include "modern/game/naming_rights.hpp"
|
||||
#include "modern/game/marketing.hpp"
|
||||
#include "modern/game/balance_plan.hpp"
|
||||
#include "modern/game/bank_credit.hpp"
|
||||
#include "modern/game/career.hpp"
|
||||
@@ -9570,7 +9571,16 @@ cli::Json ModernSession::ui_read(const cli::Json& request, uint64_t revision) co
|
||||
{"maximum", modern::ui_money(a.spending[i].maximum_amount)}, {"deliveryWeeks", int(a.spending[i].delivery_weeks)},
|
||||
{"available", a.spending[i].available}});
|
||||
return modern::ui_snapshot(g_, context, request_id,
|
||||
O{{"kind", "advertising"}, {"teamId", modern::ui_team_id(g_, team)}, {"boards", std::move(boards)},
|
||||
O{{"kind", "advertising"}, {"internationalMarketing", [&] {
|
||||
// budget and reach of the manager's international marketing (vermarktung.md)
|
||||
const auto entry = size_t(manager) < g_.marketing.size() ? g_.marketing[size_t(manager)] : modern::ModernState::Marketing{};
|
||||
const int target = modern::marketing_target(entry.budget);
|
||||
return O{{"budget", modern::ui_money(int64_t(entry.budget))}, {"maxBudget", modern::ui_money(int64_t(modern::kMarketingBudgetMax))},
|
||||
{"reach", int(entry.reach)}, {"targetReach", target}, {"maxReach", modern::kMarketingReachMax},
|
||||
{"income", modern::ui_money(int64_t(modern::marketing_income(g_, manager, entry.reach)))},
|
||||
{"incomeAtTarget", modern::ui_money(int64_t(modern::marketing_income(g_, manager, target)))}};
|
||||
}()},
|
||||
{"teamId", modern::ui_team_id(g_, team)}, {"boards", std::move(boards)},
|
||||
{"shirt", contract(a.shirt, "ad:shirt", 14)}, {"television", contract(a.television, "ad:tv", 15)},
|
||||
{"budgets", std::move(budgets)},
|
||||
{"preview", O{{"income", modern::ui_money(a.finance_preview.income)}, {"expenses", modern::ui_money(a.finance_preview.expenses)},
|
||||
@@ -11087,6 +11097,17 @@ cli::Json ModernSession::ui_command(const cli::Json& request, uint64_t& revision
|
||||
} else if (kind == "manager.join.commit") {
|
||||
answer = ui_join_managers(*payload,request_id,revision);
|
||||
if (ui_text(answer,"messageType")=="error") return answer;
|
||||
} else if (kind == "marketing.commit") {
|
||||
// payload {budget: Money}: the monthly budget for international marketing, in whole thousands
|
||||
const cli::Json* amount = ui_field(*payload, "budget");
|
||||
int64_t cents = -1;
|
||||
try { cents = amount ? std::stoll(ui_text(*amount, "minor")) : -1; } catch (const std::exception&) { cents = -1; }
|
||||
if (const int team = g_.manager_teams[size_t(manager)]; team < 0 || team >= league_clubs())
|
||||
return refuse("no_club", "Am Schreibtisch des Bundestrainers gibt es keine Vermarktung.");
|
||||
if (cents < 0 || cents % 100 || cents / 100 > modern::kMarketingBudgetMax || !modern::set_marketing_budget(g_, manager, int32_t(cents / 100)))
|
||||
return refuse("invalid_budget", "Das Budget liegt zwischen 0 und 500.000 Euro in ganzen Tausendern.");
|
||||
revision = previous + 1;
|
||||
answer = modern::ui_command_result(request_id, previous, revision, {"advertising", "desktop"}, "Budget für die internationale Vermarktung übernommen.");
|
||||
} else if (kind == "stadium.rename") {
|
||||
// payload {name}: the manager names his stadium (namensrecht.md); not while the name is sold
|
||||
if (const int team = g_.manager_teams[size_t(manager)]; team < 0 || team >= league_clubs())
|
||||
|
||||
@@ -151,7 +151,7 @@ A allowed_commands(const ModernState& g, const UiContext& c) {
|
||||
const int team = team_of(g, c.manager);
|
||||
const bool national = team == no_team();
|
||||
static constexpr const char* kAll[] = {
|
||||
"session.advance", "lineup.commit", "lineup.setPiece", "lineup.setOrder", "lineup.setFormation", "tactics.commit", "friendly.book", "manager.resign.commit", "manager.clubChange", "stadium.rename", "stadium.namingRights",
|
||||
"session.advance", "lineup.commit", "lineup.setPiece", "lineup.setOrder", "lineup.setFormation", "tactics.commit", "friendly.book", "manager.resign.commit", "manager.clubChange", "stadium.rename", "stadium.namingRights", "marketing.commit",
|
||||
"training.commit", "camp.book", "bank.commit", "toto.submit", "quote.request", "contract.offer",
|
||||
"stadium.commit", "advertising.accept", "budget.commit", "ticket.commit", "transfer.submit",
|
||||
"sponsor.answer", "environment.commit", "fixture.reschedule", "contract.cancel", "news.update", "balance.commit", "settings.commit", "manager.join.commit"};
|
||||
|
||||
@@ -194,6 +194,11 @@ void save_world_career(const std::filesystem::path& path, const World& world, co
|
||||
return J(std::move(rows));
|
||||
}()},
|
||||
{"dismissals", state.dismissals},
|
||||
{"marketing", [&] {
|
||||
A rows;
|
||||
for (const auto& m : state.marketing) rows.push_back(O{{"budget", int64_t(m.budget)}, {"reach", int64_t(m.reach)}});
|
||||
return J(std::move(rows));
|
||||
}()},
|
||||
{"stadiums", [&] {
|
||||
A rows;
|
||||
for (const auto& s : state.stadiums)
|
||||
@@ -276,6 +281,14 @@ SavedWorldCareer load_world_career(const std::filesystem::path& path, const Worl
|
||||
if (const auto it = o->find("dismissals"); it != o->end() && std::holds_alternative<bool>(it->second.value))
|
||||
out.state.dismissals = std::get<bool>(it->second.value);
|
||||
}
|
||||
// international marketing (since 17 November 2026)
|
||||
if (o->count("marketing"))
|
||||
for (const J& row : arr(get(modern, "marketing"))) {
|
||||
ModernState::Marketing m;
|
||||
m.budget = int32_t(num(get(row, "budget"))), m.reach = uint16_t(num(get(row, "reach")));
|
||||
if (m.budget < 0 || m.budget > 500000 || m.reach > 1000) fail("invalid marketing state");
|
||||
out.state.marketing.push_back(m);
|
||||
}
|
||||
// stadium names and naming rights (since 17 November 2026)
|
||||
if (o->count("stadiums"))
|
||||
for (const J& row : arr(get(modern, "stadiums"))) {
|
||||
|
||||
@@ -698,6 +698,7 @@ bool change_club(ModernState& g, const LeImage& exe, int m, int team, int32_t ca
|
||||
}
|
||||
if (size_t(m) < g.pools.size()) g.pools[size_t(m)] = {};
|
||||
if (size_t(m) < g.exclusive_sponsors.size()) g.exclusive_sponsors[size_t(m)] = {};
|
||||
if (size_t(m) < g.marketing.size()) g.marketing[size_t(m)] = {}; // the reach abroad was the old club's
|
||||
if (size_t(m) < g.stadiums.size()) g.stadiums[size_t(m)] = {}; // the name and its sponsor belong to the old ground
|
||||
|
||||
// The club he leaves is a computer club again: its sales, bids and loans as a human club end.
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "modern/game/marketing.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "game/schedule.hpp"
|
||||
#include "modern/game/matchday.hpp"
|
||||
|
||||
namespace bmh::modern {
|
||||
namespace {
|
||||
|
||||
constexpr size_t kRecord = 0xb0c;
|
||||
|
||||
int league_club(const ModernState& g, int manager) {
|
||||
if (manager < 0 || size_t(manager) >= g.manager_teams.size() || g.manager_records.size() < size_t(manager + 1) * kRecord) return -1;
|
||||
const int team = g.manager_teams[size_t(manager)];
|
||||
return team >= 0 && team < league_clubs() ? team : -1;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int marketing_target(int32_t budget) { return std::clamp(int(budget / 500), 0, kMarketingReachMax); }
|
||||
|
||||
// OpenBMH deviates from the original: in Modern a monthly budget for international marketing builds up reach abroad, which brings monthly income by league and prestige.
|
||||
int32_t marketing_income(const ModernState& g, int manager, int reach) {
|
||||
const int team = league_club(g, manager);
|
||||
if (team < 0 || reach <= 0) return 0;
|
||||
// euros a month for a point of reach, by league
|
||||
static constexpr int kValue[5] = {1600, 700, 300, 120, 120};
|
||||
reach = std::min(reach, kMarketingReachMax);
|
||||
// every further point is worth less: the full reach counts as half of its points
|
||||
const int64_t effective = reach - int64_t(reach) * reach / (2 * kMarketingReachMax);
|
||||
const int prestige = g.manager_records[size_t(manager) * kRecord + 0x211];
|
||||
return int32_t(effective * kValue[std::clamp(team_league(team), 0, 4)] * (60 + prestige * 4 / 5) / 100);
|
||||
}
|
||||
|
||||
bool set_marketing_budget(ModernState& g, int manager, int32_t budget) {
|
||||
if (league_club(g, manager) < 0 || budget < 0 || budget > kMarketingBudgetMax || budget % 1000) return false;
|
||||
if (g.marketing.size() <= size_t(manager)) g.marketing.resize(size_t(manager) + 1);
|
||||
g.marketing[size_t(manager)].budget = budget;
|
||||
return true;
|
||||
}
|
||||
|
||||
void marketing_month(ModernState& g) {
|
||||
for (size_t m = 0; m < g.marketing.size() && m < g.manager_teams.size(); ++m) {
|
||||
auto& entry = g.marketing[m];
|
||||
if (league_club(g, int(m)) < 0 || (entry.budget == 0 && entry.reach == 0)) continue;
|
||||
const bool paid = entry.budget > 0 && modern::book_money(g, int(m), entry.budget, false);
|
||||
const int target = paid ? marketing_target(entry.budget) : 0;
|
||||
if (target > entry.reach) entry.reach = uint16_t(entry.reach + std::max(1, (target - entry.reach) / 6));
|
||||
else if (target < entry.reach) entry.reach = uint16_t(entry.reach - std::max(1, (entry.reach - target) / 4));
|
||||
if (const int32_t income = marketing_income(g, int(m), entry.reach); income > 0) modern::book_money(g, int(m), -income, true);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace bmh::modern
|
||||
@@ -0,0 +1,33 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
// International marketing (docs/new_engine/vermarktung.md). A Modern rule; Classic has none.
|
||||
//
|
||||
// A manager sets a monthly budget for making his club known abroad. The budget buys reach:
|
||||
// every month the reach moves a sixth of the way towards what the budget can hold, and falls a
|
||||
// quarter of the way when the budget is cut. Reach brings income every month - more in a higher
|
||||
// league and with more prestige, and less for every further step of reach. It is an investment
|
||||
// that pays after about a year and only for clubs of the upper leagues. Draws no random number.
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "modern/game/modern_state.hpp"
|
||||
|
||||
namespace bmh::modern {
|
||||
|
||||
constexpr int32_t kMarketingBudgetMax = 500000; // euros a month: the budget that holds the full reach
|
||||
constexpr int kMarketingReachMax = 1000; // per mille
|
||||
|
||||
// The reach a budget can hold: a point for every 500 euros.
|
||||
int marketing_target(int32_t budget);
|
||||
// What the reach brings a month for the manager's club now (league, prestige).
|
||||
int32_t marketing_income(const ModernState& g, int manager, int reach);
|
||||
|
||||
// Sets the monthly budget (0 to kMarketingBudgetMax in whole thousands). False, with nothing
|
||||
// changed, for a manager without a league club or another amount.
|
||||
bool set_marketing_budget(ModernState& g, int manager, int32_t budget);
|
||||
|
||||
// The month change: the budget is paid (not when the account cannot bear it - then the month
|
||||
// counts as one without budget), the reach moves, and the reach pays.
|
||||
void marketing_month(ModernState& g);
|
||||
|
||||
} // namespace bmh::modern
|
||||
@@ -149,6 +149,14 @@ struct ModernState : GameState {
|
||||
bool operator==(const StadiumName&) const = default;
|
||||
};
|
||||
std::vector<StadiumName> stadiums;
|
||||
// International marketing (docs/new_engine/vermarktung.md), per manager slot: the monthly
|
||||
// budget in euros and the reach it has built up so far, in per mille.
|
||||
struct Marketing {
|
||||
int32_t budget = 0;
|
||||
uint16_t reach = 0;
|
||||
bool operator==(const Marketing&) const = default;
|
||||
};
|
||||
std::vector<Marketing> marketing;
|
||||
// Whether a manager the meeting votes out has to leave his club. On until the options offer it.
|
||||
bool dismissals = true;
|
||||
// Players whose age the data set gives (birth date); the others carry a placeholder the
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "modern/game/environment.hpp"
|
||||
#include "modern/game/month.hpp"
|
||||
#include "modern/game/naming_rights.hpp"
|
||||
#include "modern/game/marketing.hpp"
|
||||
#include "modern/game/desk_actions.hpp"
|
||||
#include "game/trace.hpp"
|
||||
|
||||
@@ -949,6 +950,7 @@ void search_profile_news(ModernState& g, int manager, uint32_t list, int player)
|
||||
|
||||
void month_change(ModernState& g, WatcomRandom& rand, MinuteReport& report, GameRandom* game) {
|
||||
modern::naming_rights_month(g); // Modern: the stadium sponsors pay (naming_rights.hpp)
|
||||
modern::marketing_month(g); // Modern: international marketing costs and pays (marketing.hpp)
|
||||
StaticMemory& mem = g.memory;
|
||||
std::vector<uint8_t>& r = g.manager_records;
|
||||
const int managers = int(g.manager_teams.size());
|
||||
|
||||
@@ -159,8 +159,24 @@ std::string App::render_advertising() {
|
||||
use += "<div class=\"ad-use\"><div class=\"pg-row\" style=\"justify-content:space-between;\"><span>" + esc(row.at("name").get<std::string>()) + "</span><span class=\"pg-mut\">" +
|
||||
esc(limit > 0 ? std::to_string(int(std::lround(share))) + " % von " + ad_cash(limit) : amount) + "</span></div>" + pg_bar(share, i == 0 ? "soft" : i == 1 ? "accent" : "sage") + "</div>";
|
||||
}
|
||||
out += tile("ad-soon", "ad-spending-international", soon, "investment.scene.international", "Internationale Vermarktung", "Neu", "Noch nicht im Spiel", "Diese Investition folgt", false, "big", "—") + "</div><div class=\"pg-col pg-grow\"><div class=\"pg-panel pg-col\" style=\"" +
|
||||
pg_css("gap:4px;") + "\">" + pg_kicker("Investitionen") + rows + "<div class=\"pg-kv\"><span>Internationale Vermarktung</span><strong class=\"pg-mut\">folgt</strong></div>" +
|
||||
// international marketing: a monthly budget that builds up reach abroad, and what the reach brings
|
||||
Json abroad;
|
||||
if (engine_mode_) try { abroad = engine_data_.at("advertising").at("data").at("internationalMarketing"); } catch (const std::exception &) {}
|
||||
const auto euros = [](const Json &money) { try { return std::stoll(money.at("minor").get<std::string>()); } catch (const std::exception &) { return 0LL; } }; // (ad_cash takes cents)
|
||||
std::string abroad_rows = "<div class=\"pg-kv\"><span>Internationale Vermarktung</span><strong class=\"pg-mut\">folgt</strong></div>";
|
||||
if (abroad.is_object()) {
|
||||
const auto budget = ad_cash(euros(abroad.at("budget")));
|
||||
const int reach = abroad.value("reach", 0), target = abroad.value("targetReach", 0);
|
||||
out += tile("ad-marketing", "ad-spending-international", "", "investment.scene.international", "Internationale Vermarktung", "Monatsbudget", budget,
|
||||
"Reichweite " + std::to_string(reach / 10) + " % · bringt " + ad_cash(euros(abroad.at("income"))) + " im Monat", false, "big", budget) + "</div>";
|
||||
abroad_rows = "<div class=\"pg-kv\"><span>Internationale Vermarktung</span><strong>" + esc(budget) + " / Monat</strong></div><div class=\"pg-kv\"><span>Reichweite im Ausland</span><strong>" + std::to_string(reach / 10) + " % · Ziel " +
|
||||
std::to_string(target / 10) + " %</strong></div><div class=\"pg-kv\"><span>Einnahmen daraus</span><strong class=\"ad-plus\">" + esc(ad_cash(euros(abroad.at("income")))) + " / Monat</strong></div>";
|
||||
use += "<div class=\"ad-use\"><div class=\"pg-row\" style=\"justify-content:space-between;\"><span>Reichweite im Ausland</span><span class=\"pg-mut\">" + std::to_string(reach / 10) + " % · am Ziel " +
|
||||
esc(ad_cash(euros(abroad.at("incomeAtTarget")))) + " im Monat</span></div>" + pg_bar(reach / 10.0, "accent") + "</div>";
|
||||
} else
|
||||
out += tile("ad-soon", "ad-spending-international", soon, "investment.scene.international", "Internationale Vermarktung", "Neu", "Noch nicht im Spiel", "Diese Investition folgt", false, "big", "—") + "</div>";
|
||||
out += "<div class=\"pg-col pg-grow\"><div class=\"pg-panel pg-col\" style=\"" +
|
||||
pg_css("gap:4px;") + "\">" + pg_kicker("Investitionen") + rows + abroad_rows +
|
||||
(delivery.empty() ? std::string() : "<span class=\"pg-tag accent\" style=\"align-self:flex-start;margin-top:" + pg(6) + ";\">" + esc(delivery) + "</span>") + "</div><div class=\"pg-panel pg-col\" style=\"" + pg_css("gap:4px;") + "\">" + pg_kicker("Vereinsprognose / Monat") + "<div class=\"pg-kv\"><span>Einnahmen</span><strong>" + esc(ad_cash(view.at("income").get<int64_t>())) +
|
||||
"</strong></div><div class=\"pg-kv\"><span>Ausgaben</span><strong>" + esc(ad_cash(view.at("expenses").get<int64_t>())) + "</strong></div><div class=\"pg-kv\"><span>Saldo</span><strong class=\"" + (view.at("balance").get<int64_t>() >= 0 ? "ad-plus" : "ad-minus") + "\">" +
|
||||
esc((view.at("balance").get<int64_t>() > 0 ? "+ " : "") + ad_cash(view.at("balance").get<int64_t>())) + "</strong></div></div>";
|
||||
@@ -174,7 +190,11 @@ std::string App::render_advertising() {
|
||||
} else lines.push_back("Presse und Fans bekommen gerade nichts!");
|
||||
lines.push_back(!delivery.empty() ? "Fanartikel sind unterwegs – abwarten." : merchandise > 0 ? "Fanartikel zuletzt bestellt für " + ad_cash(merchandise) + "." : "Fanshop leer. Nachbestellen?");
|
||||
if (view.at("balance").get<int64_t>() < 0) lines.push_back("Achtung: Der Monat schließt im Minus.");
|
||||
lines.push_back("Ausland: kommt noch.");
|
||||
if (!abroad.is_object()) lines.push_back("Ausland: kommt noch.");
|
||||
else if (abroad.value("targetReach", 0) == 0 && abroad.value("reach", 0) == 0) lines.push_back("Ausland: noch kein Budget.");
|
||||
else if (abroad.value("reach", 0) < abroad.value("targetReach", 0)) lines.push_back("Ausland: Die Reichweite wächst noch.");
|
||||
else if (abroad.value("reach", 0) > abroad.value("targetReach", 0)) lines.push_back("Ausland: Die Reichweite schwindet!");
|
||||
else lines.push_back("Ausland: Reichweite am Ziel.");
|
||||
out += "<div class=\"pg-panel pg-col\" style=\"" + pg_css("gap:8px;") + "\">" + pg_kicker("Auslastung der Budgets") + use + "</div><span class=\"pg-sp\"></span><div class=\"ad-memo\"><span class=\"ad-memo-tape\"></span><strong>Merkzettel</strong>";
|
||||
for (const auto &line : lines) out += "<span>" + esc(line) + "</span>";
|
||||
out += "</div></div>";
|
||||
@@ -213,7 +233,7 @@ std::string App::render_advertising() {
|
||||
const Json sold = ground.value("namingRights", Json());
|
||||
out += tile("ad-naming", "ad-contract-naming", "", "advertising.scene.arena", "Namensrecht Stadion", sold.is_object() ? "Namensgeber" : "Name frei",
|
||||
ground.value("name", std::string("Stadion")),
|
||||
sold.is_object() ? ad_cash(std::stoll(sold.at("monthly").value("minor", std::string("0"))) / 100) + " monatlich · noch " + std::to_string(sold.value("monthsLeft", 0)) + " Monate" : std::string("Anklicken für Angebote"), false, "four") + "</div>";
|
||||
sold.is_object() ? ad_cash(std::stoll(sold.at("monthly").value("minor", std::string("0")))) + " monatlich · noch " + std::to_string(sold.value("monthsLeft", 0)) + " Monate" : std::string("Anklicken für Angebote"), false, "four") + "</div>";
|
||||
} else
|
||||
out += tile("ad-soon", "ad-contract-naming", soon, "advertising.scene.arena", "Namensrecht Stadion", "Neu", "Noch nicht im Spiel", "Dieser Vertrag folgt", false, "four") + "</div>";
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@ Json engine_ticket_command(const Json &bundle, int euros, const std::string &req
|
||||
|
||||
Json engine_environment_projection(const Json &bundle);
|
||||
Json engine_environment_command(const Json &bundle, const std::string &item, int level, const std::string &request_id);
|
||||
// The monthly budget for international marketing (read "advertising", internationalMarketing).
|
||||
Json engine_marketing_command(const Json &bundle, int64_t euros, const std::string &request_id);
|
||||
// The manager names his stadium, or sells its name to the sponsor of an offer (read "stadium").
|
||||
Json engine_stadium_rename_command(const Json &bundle, const std::string &name, const std::string &request_id);
|
||||
Json engine_naming_rights_command(const Json &bundle, const std::string &offer, const std::string &request_id);
|
||||
|
||||
@@ -15,6 +15,23 @@ bool App::engine_commerce_action(const std::string &action, Rml::Element *target
|
||||
}
|
||||
if (!action.starts_with("ad-") || menu_ != "advertising") return false;
|
||||
const auto view = engine_advertising_projection(engine_data_);
|
||||
if (action == "ad-marketing" && engine_fresh_ && !engine_busy_) {
|
||||
Json abroad;
|
||||
try { abroad = engine_data_.at("advertising").at("data").at("internationalMarketing"); } catch (const std::exception &) { return true; }
|
||||
const auto euros = [](const Json &money) { try { return std::stoll(money.at("minor").get<std::string>()) / 100; } catch (const std::exception &) { return 0LL; } };
|
||||
const auto meta = engine_data_.at("desktop").at("meta");
|
||||
AmountRequest request;
|
||||
request.title = "Internationale Vermarktung";
|
||||
request.review_text = [](int64_t) { return "Monatliches Budget. Die Reichweite wächst und fällt über Monate; sie bringt Einnahmen nach Liga und Ansehen."; };
|
||||
request.unit = "€";
|
||||
request.value = euros(abroad.at("budget")); request.min = 0; request.max = euros(abroad.at("maxBudget"));
|
||||
request.step = 1000; request.suggestion_step = 50000; request.review = true;
|
||||
request.accept = [this, meta](int64_t value) {
|
||||
if (engine_busy_ || !engine_fresh_ || menu_ != "advertising" || meta != engine_data_.at("desktop").at("meta")) return false;
|
||||
engine_finance_submit(engine_marketing_command(engine_data_, value / 1000 * 1000, editor::new_id("request:ui-"))); return true;
|
||||
};
|
||||
open_amount(std::move(request)); return true;
|
||||
}
|
||||
if (action == "ad-naming" && engine_fresh_ && !engine_busy_) {
|
||||
Json ground;
|
||||
try { ground = engine_data_.at("stadium").at("data"); } catch (const std::exception &) { return true; }
|
||||
|
||||
@@ -513,6 +513,9 @@ Json engine_environment_projection(const Json &bundle) {
|
||||
}
|
||||
return {{"ok", true}, {"rows", rows}};
|
||||
}
|
||||
Json engine_marketing_command(const Json &bundle, int64_t euros, const std::string &request_id) {
|
||||
return sports_command(bundle, "marketing.commit", {{"budget", {{"currency", "EUR"}, {"minorUnits", 2}, {"minor", std::to_string(euros * 100)}}}}, request_id);
|
||||
}
|
||||
Json engine_stadium_rename_command(const Json &bundle, const std::string &name, const std::string &request_id) {
|
||||
return sports_command(bundle, "stadium.rename", {{"name", name}}, request_id);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// International marketing (docs/new_engine/vermarktung.md) on a synthetic manager: the budget,
|
||||
// how the reach builds up and falls, what it brings by league, and a month that cannot be paid.
|
||||
#include <cstdio>
|
||||
|
||||
#include "modern/game/marketing.hpp"
|
||||
|
||||
using namespace bmh;
|
||||
using namespace bmh::modern;
|
||||
|
||||
namespace {
|
||||
int failures = 0;
|
||||
void check(bool ok, const char* what) {
|
||||
if (!ok) {
|
||||
std::fprintf(stderr, "FAIL: %s\n", what);
|
||||
++failures;
|
||||
}
|
||||
}
|
||||
int32_t cash(const ModernState& g) {
|
||||
return int32_t(uint32_t(g.manager_records[0x314]) | uint32_t(g.manager_records[0x315]) << 8 | uint32_t(g.manager_records[0x316]) << 16 |
|
||||
uint32_t(g.manager_records[0x317]) << 24);
|
||||
}
|
||||
void set_cash(ModernState& g, int32_t euros) {
|
||||
for (int i = 0; i < 4; ++i) g.manager_records[0x314 + size_t(i)] = uint8_t(uint32_t(euros) >> (8 * i));
|
||||
}
|
||||
// Manager 0 runs club `team` with a prestige of 50 and ten million in the account.
|
||||
ModernState world(int team = 0) {
|
||||
ModernState g;
|
||||
g.level = 2;
|
||||
g.manager_teams = {int16_t(team)};
|
||||
g.manager_records.assign(5 * 0xb0c, 0);
|
||||
g.manager_records[0x211] = 50;
|
||||
set_cash(g, 10000000);
|
||||
return g;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int main() {
|
||||
check(marketing_target(0) == 0 && marketing_target(100000) == 200 && marketing_target(500000) == 1000 && marketing_target(900000) == 1000,
|
||||
"a point of reach for every 500 euros, a thousand at most");
|
||||
{
|
||||
ModernState g = world();
|
||||
check(set_marketing_budget(g, 0, 200000) && g.marketing.at(0).budget == 200000, "the budget is set");
|
||||
check(!set_marketing_budget(g, 0, -1000) && !set_marketing_budget(g, 0, 501000) && !set_marketing_budget(g, 0, 1500) && !set_marketing_budget(g, 1, 1000) &&
|
||||
g.marketing.at(0).budget == 200000,
|
||||
"a negative, too high or uneven budget and a missing manager are refused");
|
||||
// first league, prestige 50: 1600 euros a point, the full reach counts as half its points
|
||||
check(marketing_income(g, 0, 0) == 0 && marketing_income(g, 0, 200) == 180 * 1600 && marketing_income(g, 0, 1000) == 500 * 1600,
|
||||
"income by reach: every further point is worth less");
|
||||
check(marketing_income(world(20), 0, 200) == 180 * 700 && marketing_income(world(60), 0, 200) == 180 * 120, "lower leagues earn much less");
|
||||
ModernState famous = world();
|
||||
famous.manager_records[0x211] = 100;
|
||||
check(marketing_income(famous, 0, 200) == 180 * 1600 * 140 / 100, "prestige raises the income");
|
||||
|
||||
const int32_t before = cash(g);
|
||||
marketing_month(g);
|
||||
// target 400: the first month brings a sixth of the way (66 points)
|
||||
check(g.marketing[0].reach == 66 && cash(g) == before - 200000 + marketing_income(g, 0, 66), "the first month: budget paid, a sixth of the way, first income");
|
||||
int months = 1;
|
||||
while (g.marketing[0].reach < 400 && months < 60) marketing_month(g), ++months;
|
||||
check(g.marketing[0].reach == 400 && months > 10 && months < 40, "the reach arrives at what the budget holds after a year or two");
|
||||
const int32_t steady = cash(g);
|
||||
marketing_month(g);
|
||||
check(cash(g) - steady == marketing_income(g, 0, 400) - 200000 && cash(g) > steady, "at the target the marketing pays more than it costs in the first league");
|
||||
|
||||
check(set_marketing_budget(g, 0, 0), "the budget is cut");
|
||||
marketing_month(g);
|
||||
check(g.marketing[0].reach == 300, "without budget the reach falls by a quarter");
|
||||
while (g.marketing[0].reach > 0) marketing_month(g);
|
||||
const int32_t empty = cash(g);
|
||||
marketing_month(g);
|
||||
check(cash(g) == empty, "no budget, no reach: nothing is booked");
|
||||
}
|
||||
// a month the account cannot bear counts as one without budget
|
||||
{
|
||||
ModernState g = world();
|
||||
set_marketing_budget(g, 0, 300000);
|
||||
g.marketing[0].reach = 400;
|
||||
set_cash(g, 1000);
|
||||
marketing_month(g);
|
||||
check(g.marketing[0].reach == 300 && cash(g) == 1000 + marketing_income(g, 0, 300), "unpaid month: the reach falls, the account is not charged");
|
||||
}
|
||||
if (failures) return 1;
|
||||
std::puts("modern_marketing_tests: ok");
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user