The stadium has a name of its own, and the name can be sold

A manager renames his stadium on the stadium page. On the advertising page
three sponsors offer to buy the name for one to five years; the sponsor
pays with every month change, the stadium is called after him, and until
the contract ends it can be neither renamed nor sold again. The match
sheet shows the name.

Engine: naming_rights.hpp; read stadium (name, nameEditable, namingRights,
namingOffers), commands stadium.rename and stadium.namingRights, live read
stadiumName; saved in state/modern.json.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Fable 5.2 committed 2026-11-17 15:09:01 +01:00
1 parent 83bd96c1ff
commit 2639f37def
26 files changed
+507 -9

No files matched your search

+10 -1
View File
@@ -206,7 +206,16 @@ std::string App::render_advertising() {
out += tile("ad-contract", "ad-contract-" + std::to_string(slot), "data-ad-contract=\"" + std::to_string(slot) + "\" data-id=\"" + std::to_string(slot) + "\" aria-pressed=\"" + (advertising_selected_ == slot ? "true" : "false") + "\"", art, title,
on ? (slot == 14 ? "Aktueller Sponsor" : "Aktueller Sender") : "Platz frei", on ? c.at("name").get<std::string>() : std::string("Kein Vertrag"), on ? terms(c) : std::string("Anklicken für Angebote"), advertising_selected_ == slot, "four");
}
out += tile("ad-soon", "ad-contract-naming", soon, "advertising.scene.arena", "Namensrecht Stadion", "Neu", "Noch nicht im Spiel", "Dieser Vertrag folgt", false, "four") + "</div>";
// the stadium's name: free, or sold to a sponsor until the contract ends
Json ground;
if (engine_mode_) try { ground = engine_data_.at("stadium").at("data"); } catch (const std::exception &) {}
if (ground.is_object() && ground.contains("namingOffers")) {
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>";
} 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>";
}
out += "</div></section>";
if (advertising_selected_ < 0 || advertising_selected_ > 15) return out;
+3
View File
@@ -32,6 +32,9 @@ 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 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);
// The manager leaves for one of the clubs interested in him (read "assembly").
Json engine_club_change_command(const Json &bundle, const std::string &team, const std::string &request_id);
Json engine_advertising_projection(const Json &bundle);
+24
View File
@@ -15,6 +15,30 @@ 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-naming" && engine_fresh_ && !engine_busy_) {
Json ground;
try { ground = engine_data_.at("stadium").at("data"); } catch (const std::exception &) { return true; }
const Json sold = ground.value("namingRights", Json());
if (sold.is_object()) {
message("Das Stadion trägt den Namen " + ground.value("name", std::string()) + ". " + sold.value("sponsor", std::string()) + " zahlt " + engine_price(sold.at("monthly")) + " im Monat, noch " +
std::to_string(sold.value("monthsLeft", 0)) + " Monate. Bis dahin lässt sich der Name nicht ändern.");
popup_title_ = "Namensrecht Stadion";
return true;
}
std::string body = "<div class=\"po-offers\">";
for (const auto &offer : ground.value("namingOffers", Json::array())) {
const std::string id = offer.value("id", std::string());
body += "<div class=\"po-offer\"><div class=\"po-text\"><strong>" + esc(offer.value("name", std::string())) + "</strong><span>" + esc(engine_price(offer.at("monthly"))) + " monatlich · " +
std::to_string(offer.value("months", 0) / 12) + (offer.value("months", 0) == 12 ? " Jahr" : " Jahre") + "</span><span>zusammen " + esc(engine_price(offer.at("total"))) + "</span></div>" +
pg_button("naming-accept", "Verkaufen", "primary", "id=\"naming-accept-" + esc(id) + "\" data-id=\"" + esc(id) + "\"") + "</div>";
}
body += "</div>";
message("Drei Sponsoren wollen dem Stadion ihren Namen geben. Solange der Vertrag läuft, heißt es wie der Sponsor, und du kannst es nicht umbenennen. Heute heißt es " + ground.value("name", std::string("Stadion")) + ".");
popup_title_ = "Namensrecht Stadion";
popup_close_ = "Abbrechen";
popup_body_ = body;
return true;
}
if (action == "ad-contract" && target) {
const int slot = target->GetAttribute<int>("data-id", -1);
if (slot < 0 || slot > 15) return true;
+21
View File
@@ -481,6 +481,27 @@ void App::engine_event(Rml::Event &event) {
const auto action = node->GetAttribute<Rml::String>("data-action", ""), id = node->GetAttribute<Rml::String>("data-id", "");
if (!popup_.empty()) {
if(action=="balance-discard"){engine_balance_action(action,node);return;}
if (action == "naming-accept") {
const std::string offer = id;
std::string name, terms;
try {
for (const auto &row : engine_data_.at("stadium").at("data").at("namingOffers"))
if (row.value("id", std::string()) == offer) {
name = row.value("name", std::string());
terms = engine_price(row.at("monthly")) + " im Monat für " + std::to_string(row.value("months", 0) / 12) + (row.value("months", 0) == 12 ? " Jahr" : " Jahre");
}
} catch (const std::exception &) {}
popup_.clear(); reset_popup(); confirm_ = {}; dirty_ = true;
if (name.empty()) return;
confirmation("Den Stadionnamen wirklich verkaufen? Das Stadion heißt dann " + name + " (" + terms + "). Bis zum Vertragsende lässt sich der Name nicht mehr ändern.", [this, offer] {
try {
engine_finance_submit(engine_naming_rights_command(engine_data_, offer, editor::new_id("request:ui-")));
} catch (const std::exception &e) { message(e.what()); }
});
popup_title_ = "Namensrecht verkaufen";
popup_accept_ = "Verkaufen";
return;
}
if (action == "engine-offer-accept") {
const auto player = engine_offer_player_;
const int index = node->GetAttribute<int>("data-id", -1);
+6
View File
@@ -513,6 +513,12 @@ Json engine_environment_projection(const Json &bundle) {
}
return {{"ok", true}, {"rows", rows}};
}
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);
}
Json engine_naming_rights_command(const Json &bundle, const std::string &offer, const std::string &request_id) {
return sports_command(bundle, "stadium.namingRights", {{"offerId", offer}, {"confirmed", true}}, request_id);
}
Json engine_club_change_command(const Json &bundle, const std::string &team, const std::string &request_id) {
return sports_command(bundle, "manager.clubChange", {{"teamId", team}, {"confirmed", true}}, request_id);
}
+1 -1
View File
@@ -329,7 +329,7 @@ Json engine_live_progress(const Json &previous, const Json &state, const Json &b
} catch (const std::exception &) {}
out["matches"].push_back({{"id", id}, {"home", home}, {"away", away}, {"owners", owners}, {"competition", competition},
{"attendance", m.value("attendance", Json())}, {"weather", m.value("weather", Json())}, {"capacity", m.value("capacity", Json())},
{"attendance", m.value("attendance", Json())}, {"weather", m.value("weather", Json())}, {"capacity", m.value("capacity", Json())}, {"stadiumName", m.value("stadiumName", Json())},
{"lineups", m.value("lineups", Json())}});
}
if (out.at("owners").empty() || out.at("matches").empty()) return failure("live_no_human_match");
+2
View File
@@ -118,6 +118,8 @@ Json engine_stadium_projection(const Json &bundle, bool future) {
return {{"ok", true},
{"club", d.at("teamId")},
{"name", d.value("name", std::string("Stadion"))},
{"name_editable", d.value("nameEditable", false)},
{"naming", d.value("namingRights", Json())},
{"budget", engine_money_minor(bundle.at("desktop").at("data").at("accounts").at("cash"))},
{"blocks", blocks},
{"facilities", facilities},
+13
View File
@@ -217,6 +217,19 @@ bool App::engine_stadium_action(const std::string &action, Rml::Element *target)
refresh();
return true;
}
if (action == "stadium-rename" && engine_fresh_ && !engine_busy_) {
Json data;
try { data = engine_data_.at("stadium").at("data"); } catch (const std::exception &) { return true; }
if (!data.value("nameEditable", false)) { message("Der Stadionname ist verkauft und lässt sich bis zum Vertragsende nicht ändern."); return true; }
text_dialog("Wie soll das Stadion heißen? (höchstens 40 Zeichen)", data.value("name", std::string()), [this](const std::string &name) {
try {
engine_finance_submit(engine_stadium_rename_command(engine_data_, name, editor::new_id("request:ui-")));
} catch (const std::exception &e) { message(e.what()); }
});
popup_title_ = "Stadion umbenennen";
popup_accept_ = "Umbenennen";
return true;
}
if (action == "stadium-data") {
stadium_view_["view"] = "data";
refresh();
+1 -1
View File
@@ -48,7 +48,7 @@ bool App::engine_live_open(const Json &recording) {
if (at_end && fixture.value("ok", false) && live_.available())
for (auto &match : fixture.at("matches"))
for (const auto &known : live_.fixture().at("matches"))
if (known.at("home").at("id") == match.at("home").at("id") && known.contains("capacity") && !match.contains("capacity")) match["capacity"] = known.at("capacity");
if (known.at("home").at("id") == match.at("home").at("id") && known.contains("capacity") && !match.contains("capacity")) { match["capacity"] = known.at("capacity"); if (known.contains("stadiumName")) match["stadiumName"] = known.at("stadiumName"); }
engine_live_at_end_ = false;
if (!fixture.value("ok", false) || !(at_end ? live_.follow(fixture) : live_.open(fixture, ""))) {
engine_notice_ = "Spieltag gespielt · Der Ticker kann diese Aufzeichnung nicht zeigen (" +
+1 -1
View File
@@ -603,7 +603,7 @@ std::string App::live_sheet(const std::string &over) {
filling = "von " + number(places) + " Plätzen · " + std::to_string(percent) + " % ausgelastet · ";
bar = "<span class=\"mv-capbar\"><div style=\"width:" + std::to_string(percent) + "%;\"></div></span>";
}
out += "<div class=\"mv-info\"><div class=\"main\"><span class=\"mv-k\">" + esc(pg_upper(indoor ? "Halle" : "Stadion")) + "</span><span class=\"big\">" + esc(crowd) +
out += "<div class=\"mv-info\"><div class=\"main\"><span class=\"mv-k\">" + esc(pg_upper(indoor ? std::string("Halle") : match->contains("stadiumName") && match->at("stadiumName").is_string() ? match->at("stadiumName").get<std::string>() : std::string("Stadion"))) + "</span><span class=\"big\">" + esc(crowd) +
"</span>" + bar + "<span class=\"sub\">" + esc(filling + "Heimspiel von " + match->at("home").at("name").get<std::string>()) + "</span></div>";
const auto weather = match->value("weather", Json());
if (!indoor && weather.is_object()) {
+5 -1
View File
@@ -87,7 +87,9 @@ std::string App::render_stadium() {
const bool outer=view=="panorama";
const auto ground=overview.at("name").get<std::string>();
page_title_=outer?"Peripherie – "+ground:ground+" – "+number(overview.at("capacity").get<int64_t>())+" Plätze";
page_hint_=view=="data"?"Stadiondaten":std::string(outer?"ein Gebäude anklicken":"ein Bauteil anklicken")+(future?(outer?" · Stand nach Fertigstellung":" · geplante Kapazität"):"");
const std::string naming_hint=engine_mode_&&overview.value("naming",Json()).is_object()?" · Namensrecht: "+overview.at("naming").value("sponsor",std::string())+", noch "+std::to_string(overview.at("naming").value("monthsLeft",0))+" Monate":std::string();
page_hint_=naming_hint.empty()?std::string():naming_hint.substr(4);
if(naming_hint.empty())page_hint_=view=="data"?"Stadiondaten":std::string(outer?"ein Gebäude anklicken":"ein Bauteil anklicken")+(future?(outer?" · Stand nach Fertigstellung":" · geplante Kapazität"):"");
if(view=="data"){stadium_seen_="data";stadium_flying_=false;return render_stadium_data()+render_stadium_dialog();}
// over the gate stands the first word of the ground's name
auto sign=pg_upper(ground.substr(0,ground.find_first_of(" -")));
@@ -203,6 +205,8 @@ std::string App::render_stadium() {
out+=btn("stadium-future","<span>"+std::string(i?"Zukunft":"Aktuell")+"</span>",std::string(i?"":"first ")+(on?"on":""),on?std::string("style=\"pointer-events:none;\" aria-pressed=\"true\""):std::string("id=\"stadium-future\" aria-pressed=\"false\""));
}
out+="</div>"+pg_button("stadium-data","Stadion-Daten","","id=\"stadium-data\"");
// the name is the manager's to choose until he sells it to a sponsor
if(engine_mode_)out+=pg_button("stadium-rename","Stadion umbenennen","","id=\"stadium-rename\" "+std::string(overview.value("name_editable",false)?"":"disabled=\"disabled\" title=\"Der Name ist an einen Sponsor verkauft\""));
}
out+=pg_button("stadium-reset","Ansicht zurücksetzen","","id=\"stadium-reset\"")+"<span class=\"pg-sp\"></span>"+pg_status("Mausrad zoomt · Ziehen verschiebt die Ansicht");
return out+"</nav></section>"+render_stadium_dialog();