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
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user