Contracts, surroundings and balance sheet as pages of the notebook

Contracts: club and wage bill, the squad as a table, the negotiation as a note on
the dimmed book. Surroundings: six cards with their stars, pictures and costs, the
monthly sum in the page's title. Balance: figures, income against costs, the plan
for the coming year, and the what-if calculation in the notebook's inks.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Fable 5.2 committed 2026-11-15 17:34:15 +01:00
1 parent ac455eabfe
commit 1a1f43ddf7
9 files changed
+204 -454

No files matched your search

+28 -46
View File
@@ -1,64 +1,46 @@
// SPDX-License-Identifier: GPL-3.0-only
// The club's surroundings: three youth teams and three members of staff, six cards in two
// rows. Each card carries its monthly budget as a row of stars, its picture and its cost.
std::string App::render_environment() {
const auto snapshot = engine_mode_ ? Snapshot{input_revision(), world_, Json::object()} : snap();
if (!snapshot.world) return "<p class=\"environment-unavailable\">Die Umfeldvorschau ist derzeit nicht verfügbar.</p>";
const std::string unavailable = "<div class=\"pg-page\"><div class=\"pg-empty\">Die Umfeldvorschau ist derzeit nicht verfügbar.</div></div>";
if (!snapshot.world) return unavailable;
const auto view = engine_mode_ ? engine_environment_projection(engine_data_) : demo_environment_rows(snapshot.state, *snapshot.world);
if (!view.value("ok", false)) return "<p class=\"environment-unavailable\">Die Umfeldvorschau ist derzeit nicht verfügbar.</p>";
const auto funded = theme_ == "silver" ? "#805b18" : theme_ == "matchday" ? "#e1c68b" : "#e5cd8c";
const auto unfunded = theme_ == "silver" ? "#526779" : theme_ == "matchday" ? "#b7b4b9" : "#6f8595";
if (!view.value("ok", false)) return unavailable;
const auto currency = engine_mode_ ? Json{{"code", "EUR"}, {"minor_units", 2}} : snapshot.world->manifest().value("currency", Json::object());
const auto star = [&](bool active) {
const auto color = active ? funded : unfunded;
const std::string colour = active ? (theme_ == "silver" ? "#b2622d" : theme_ == "matchday" ? "#3f7a3a" : "#e0a25f") : (theme_ == "silver" ? "#c0b6a5" : theme_ == "matchday" ? "#afc09a" : "#525966");
const std::string svg = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"48\" height=\"48\" viewBox=\"0 0 48 48\">"
"<path fill=\"" + std::string(color) + "\" d=\"m24 3 6 13 15 2-11 11 3 15-13-7-13 7 3-15L3 18l15-2Z\"/></svg>";
return picture(renderer_.diagram("environment-star-" + theme_ + (active ? "-funded" : "-unfunded"), svg, 96), 40, 40);
"<path fill=\"" + colour + "\" d=\"m24 3 6 13 15 2-11 11 3 15-13-7-13 7 3-15L3 18l15-2Z\"/></svg>";
return picture(renderer_.diagram("environment-star-" + theme_ + (active ? "-funded" : "-unfunded"), svg, 96), 46, 46);
};
struct Panel { double x, y, w, h, image_h; };
const std::array<Panel, 6> panels{{
{1912,970,600,623.328125,374.78125}, {1056,1060,500,556.40625,307.859375},
{100,970,600,623.328125,374.78125}, {100,160,600,694.375,460.375},
{1056,0,500,612.171875,378.171875}, {1912,160,600,694.375,460.375}}};
std::string out = "<div class=\"environment-ring\" id=\"environment-ring\">";
const auto &rows = view.at("rows");
int64_t total = 0;
for (const auto &row : rows) total += row.at("cost").get<int64_t>();
page_title_ = "Umfeld – " + money(total, currency) + " pro Monat";
// a card is a third of the page wide; its picture takes the height that is left
const double card_width = (2799 - 2 * 31.5) / 3, picture_width = card_width - 2 * 36 - 4, picture_height = 396;
std::string out = "<div class=\"pg-page\" id=\"environment-ring\"><div class=\"env-grid\">";
for (size_t i = 0; i < rows.size(); ++i) {
const auto &row = rows[i];
const auto &panel = panels[i];
const auto name = row.at("name").get<std::string>(), id = row.at("id").get<std::string>();
const auto level = row.at("level").get<int>();
const auto inner = panel.w - 40;
out += "<section class=\"environment-card " + id + "\" style=\"" + rect(panel.x, panel.y, panel.w, panel.h) +
"\" aria-labelledby=\"environment-title-" + std::to_string(i) + "\"><h2 id=\"environment-title-" +
std::to_string(i) + "\">" + esc(name) + "</h2><div class=\"environment-stars\" role=\"group\" aria-label=\"" +
esc(name + " Budget") + "\">";
out += "<section class=\"pg-panel pg-col env-card " + id + "\" style=\"width:" + scalar(card_width) + "dp;\" aria-labelledby=\"environment-title-" + std::to_string(i) +
"\"><div class=\"pg-row\" style=\"justify-content:space-between;\"><h2 class=\"pg-h\" id=\"environment-title-" + std::to_string(i) + "\">" + esc(name) + "</h2>" +
(i < 3 ? "<span class=\"pg-tag sage environment-standing\" title=\"Tabellenplatz der Jugendmannschaft\">Platz " + std::to_string(row.at("rank").get<int>()) + " · " + std::to_string(row.at("league").get<int>()) + ". Liga</span>" : std::string()) +
"</div><div class=\"env-stars\" role=\"group\" aria-label=\"" + esc(name + " Budget") + "\">";
for (int value = 0; value <= 6; ++value) {
const bool selected = value == level;
const auto label = value ? "<span class=\"environment-level-icon\">" + star(value <= level) + "</span>"
: std::string("<span class=\"environment-zero-label\">×</span>");
out += btn("environment-level", label + (selected ? "<span class=\"environment-selection-line\"></span>" : ""),
"environment-level " + std::string(value == 0 ? "zero " : "") + (selected ? "selected" : ""),
"id=\"environment-level-" + std::to_string(i) + "-" + std::to_string(value) +
"\" data-index=\"" + std::to_string(i) + "\" data-id=\"" + std::to_string(value) +
"\" aria-pressed=\"" + (selected ? "true" : "false") + "\" aria-label=\"" +
esc(name + ": " + std::to_string(value) + (value == 1 ? " Stern" : " Sterne")) +
out += btn("environment-level", value ? star(value <= level) : std::string("<span class=\"env-zero\">×</span>"),
"env-level " + std::string(value == 0 ? "zero " : "") + (selected ? "selected" : ""),
"id=\"environment-level-" + std::to_string(i) + "-" + std::to_string(value) + "\" data-index=\"" + std::to_string(i) + "\" data-id=\"" + std::to_string(value) +
"\" aria-pressed=\"" + (selected ? "true" : "false") + "\" aria-label=\"" + esc(name + ": " + std::to_string(value) + (value == 1 ? " Stern" : " Sterne")) +
"\" " + std::string(engine_mode_ && value > row.at("max").get<int>() ? "disabled " : "") + "title=\"" + (value ? std::to_string(value) + (value == 1 ? " Stern" : " Sterne") : "Budget auf null setzen") + "\"");
}
out += "</div><div class=\"environment-picture\" style=\"" + rect(18, 138, inner, panel.image_h) + "\">" +
img("environment." + row.at("image").get<std::string>() + "." + std::to_string(row.at("cell").get<int>()),
inner, panel.image_h, false, false, 1024) +
"</div><div class=\"environment-caption\" style=\"top:" + scalar(152 + panel.image_h) + "dp;height:" +
scalar(i < 3 ? 74.546875 : 60) + "dp;\"><span class=\"environment-cost\" id=\"environment-cost-" + std::to_string(i) +
"\" aria-label=\"" + esc(name + " Monatskosten") + "\">" +
esc(money(row.at("cost").get<int64_t>(), engine_mode_ ? Json{{"code", "EUR"}, {"minor_units", 2}} : snapshot.world->manifest().value("currency", Json::object())) + " / Monat") + "</span>";
if (i < 3)
out += "<span class=\"environment-standing\">" + std::to_string(row.at("rank").get<int>()) + ". / " +
std::to_string(row.at("league").get<int>()) + ". Liga</span>";
out += "</div></section>";
out += "</div><div class=\"env-picture\" style=\"height:" + scalar(picture_height) + "dp;\">" +
img("environment." + row.at("image").get<std::string>() + "." + std::to_string(row.at("cell").get<int>()), picture_width, picture_height, false, true, 1024) +
"</div><div class=\"pg-row\" style=\"justify-content:space-between;\"><span class=\"pg-mut\">Monatskosten</span><strong class=\"pg-num environment-cost\" id=\"environment-cost-" + std::to_string(i) +
"\" aria-label=\"" + esc(name + " Monatskosten") + "\">" + esc(money(row.at("cost").get<int64_t>(), currency) + " / Monat") + "</strong></div></section>";
}
out += "<div class=\"environment-emblem\"><div class=\"environment-ball\">" +
img("art.environment-ball-v1.png", 400, 400, false, false, 640) + "</div>";
const bool demo_manager = !engine_mode_ && snapshot.state.at("managers").is_array() && !snapshot.state.at("managers").empty();
const auto managed = engine_mode_ ? engine_data_.at("desktop").at("meta").at("scope").at("teamId").get<std::string>() : demo_manager ? demo_career_manager(snapshot.state).value("club", "") : "";
const auto *club = snapshot.world->find("clubs", managed);
out += "<div class=\"environment-crest\" aria-label=\"" + esc(club ? snapshot.world->name(*club) : "Vereinswappen nicht verfügbar") + "\">" +
(club ? img(club->value("crest", ""), 162, 162, true) : "<span>—</span>") + "</div></div></div>";
return out;
return out + "</div><nav class=\"pg-foot\">" + pg_status(engine_mode_ && engine_busy_ ? engine_operation_ : engine_mode_ && !engine_notice_.empty() ? engine_notice_ : std::string("Eine Stufe anklicken, um das Monatsbudget zu ändern.")) + "</nav></div>";
}