Toto as a page of the notebook: our slip in the dress of the other pages

The matches as a panel on the left, the printed slip with its six columns filling
the right, the actions and the status in the foot, the receipts as notes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Fable 5.2 committed 2026-11-15 21:37:01 +01:00
1 parent 66905ef04f
commit 2b0d528ec7
4 files changed
+126 -154

No files matched your search

+1 -1
View File
@@ -5,7 +5,7 @@
// The menus that are laid out as a page of the notebook. Every other career menu is still a
// sheet of the old format, shown scaled inside the book.
bool App::page_native() const {
static const std::set<std::string> native{"settings", "save", "load", "stadium", "statistics", "news", "transfer", "training", "almanac", "tactics", "achievements", "highscore", "balance", "contracts", "environment", "tables", "league", "other", "strengths", "fairplay", "indoor", "scorers"};
static const std::set<std::string> native{"toto", "settings", "save", "load", "stadium", "statistics", "news", "transfer", "training", "almanac", "tactics", "achievements", "highscore", "balance", "contracts", "environment", "tables", "league", "other", "strengths", "fairplay", "indoor", "scorers"};
if (menu_ == "calendar" || menu_ == "postpone" || menu_ == "lineup") return notebook_page() && engine_mode_;
// a national coach arranges friendlies on the older sheet
if (menu_ == "friendlies") return notebook_page() && engine_mode_ && engine_data_.contains("desktop") && engine_data_.at("desktop").at("meta").at("scope").at("role") == "club";
+72 -51
View File
@@ -4,6 +4,9 @@ std::string toto_pick_id(int col, int row, int pick) {
return "toto-pick-" + std::to_string(col) + "-" + std::to_string(row) + "-" + std::to_string(pick);
}
}
// Finanzen > Toto as a page of the notebook: the eleven matches on the left, the printed slip
// with its six columns on the right, and in the foot what one does with the slip. The slip
// keeps its own red print; everything around it follows the notes of the other pages.
std::string App::render_toto() {
const auto t=toto_value();
const auto toto_cash=[&](int64_t value){return engine_mode_?money(value,{{"code","EUR"},{"minor_units",2}}):cash(value);};
@@ -11,87 +14,105 @@ std::string App::render_toto() {
const bool available = programme.at("complete").get<bool>();
const auto &games = programme.at("rows");
const std::array<int, 3> picks{1, 0, 2};
std::string out = "<div id=\"toto-underlay\" class=\"toto-native\"><section class=\"toto-program\">"
"<header><p>Die Begegnungen</p><h2>Spielprogramm</h2><span>"+esc(programme.value("caption",std::string("Spielrunde 27")))+" · Saison " + esc(programme.at("season").get<std::string>()) +
"</span></header><div class=\"toto-program-head\"><span>Nr.</span><span>Heim – Gast</span><span>Liga</span></div>";
page_hint_ = "11 Spiele · 6 Tipp-Spalten";
std::string out = "<section class=\"pg-page\" id=\"toto-underlay\"><div class=\"pg-row pg-grow\" style=\"align-items:stretch;\"><div class=\"pg-panel pg-col tt-programme\"><div>" + pg_kicker("Die Begegnungen") +
"<h3 class=\"pg-h\" style=\"font-size:" + pg(20) + ";line-height:" + pg(26) + ";\">" + esc(programme.value("caption",std::string("Spielrunde 27"))) + " · Saison " + esc(programme.at("season").get<std::string>()) +
"</h3></div><div class=\"tt-table\" role=\"table\"><div class=\"tt-row head\" role=\"row\"><span class=\"tt-no\">NR.</span><span class=\"tt-teams\">HEIM – GAST</span><span class=\"tt-league\">LIGA</span></div>";
const auto club_name = [&](const Json *club, bool home,const Json &reference) {
const auto label=reference.is_object()?reference.at("name").get<std::string>():club?world_->name(*club):std::string("—");
const auto name = "<span class=\"toto-club-name\">" + esc(label) + "</span>", logo = crest(club, 34);
return "<span class=\"toto-club-label\" title=\"" + esc(label) + "\">" +
(home ? name + logo : logo + name) + "</span>";
const auto name = "<span class=\"tt-club-name\">" + esc(label) + "</span>", logo = crest(club, 45);
return "<div class=\"tt-club" + std::string(home ? " home" : "") + "\" title=\"" + esc(label) + "\">" + (home ? name + logo : logo + name) + "</div>";
};
for (int r = 0; r < 11; ++r) {
const bool has = size_t(r) < games.size();
const auto *home = has ? world_->find("clubs", games[size_t(r)].at("home")) : nullptr;
const auto *away = has ? world_->find("clubs", games[size_t(r)].at("away")) : nullptr;
out += "<div class=\"toto-match-row" + std::string(r % 2 == 0 ? " striped" : "") + "\" style=\"top:" + scalar(298 + r * 82) + "dp;\">"
"<span class=\"toto-match-number\">" + std::to_string(r + 1) + "</span><div class=\"toto-match-teams\"><div class=\"toto-home\">" +
club_name(home,true,has?games[size_t(r)].value("home_ref",Json()):Json()) + "</div><span class=\"toto-versus\">–</span><div class=\"toto-away\">" + club_name(away,false,has?games[size_t(r)].value("away_ref",Json()):Json()) +
"</div></div><span class=\"toto-match-league\">" + (has ? games[size_t(r)].value("league_label",std::to_string(games[size_t(r)].value("tier",0))+". BL") : "—") + "</span></div>";
out += "<div class=\"tt-row\" role=\"row\"><span class=\"tt-no\">" + std::to_string(r + 1) + "</span><div class=\"tt-teams\">" +
club_name(home,true,has?games[size_t(r)].value("home_ref",Json()):Json()) + "<span class=\"tt-versus\">–</span>" + club_name(away,false,has?games[size_t(r)].value("away_ref",Json()):Json()) +
"</div><span class=\"tt-league\">" + (has ? esc(games[size_t(r)].value("league_label",std::to_string(games[size_t(r)].value("tier",0))+". BL")) : std::string("—")) + "</span></div>";
}
out += "<p class=\"toto-program-note\">" + std::string(available ? "Heim links · Gast rechts<br/>Die Spielnummer steht in jeder Tipp-Spalte."
: "Das Spielprogramm ist unvollständig.<br/>Ein Schein kann derzeit nicht vorgemerkt werden.") + "</p></section>"
"<article class=\"toto-coupon\"><span class=\"toto-print-mark top\"></span><span class=\"toto-print-mark bottom\"></span>"
"<header class=\"toto-paper-heading\"><div class=\"toto-paper-brand\"><strong>TOTO</strong><h2>ELFERWETTE</h2></div>"
"<div class=\"toto-paper-caption\"><strong>Spielschein</strong><span>11 Spiele · 6 Tipp-Spalten</span><small>"+esc(programme.value("print_caption",std::string("Spielprogramm 27")))+"</small></div></header>";
out += "</div><span class=\"pg-sp\"></span><span class=\"pg-mut tt-note\">" + std::string(available ? "Heim links · Gast rechts. Die Spielnummer steht in jeder Tipp-Spalte."
: "Das Spielprogramm ist unvollständig. Ein Schein kann derzeit nicht vorgemerkt werden.") + "</span></div>"
"<article class=\"tt-coupon\"><header class=\"tt-heading\"><div class=\"tt-brand\"><strong>TOTO</strong><span>ELFERWETTE</span></div>"
"<div class=\"tt-caption\"><strong>Spielschein</strong><span>11 Spiele · 6 Tipp-Spalten</span><small>"+esc(programme.value("print_caption",std::string("Spielprogramm 27")))+"</small></div></header><div class=\"tt-fields\">";
const auto cross = renderer_.diagram("toto-ink-cross", "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"60\" height=\"80\" viewBox=\"0 0 60 80\"><path d=\"M10 14L49 66M48 12L12 69\" fill=\"none\" stroke=\"#253e62\" stroke-width=\"5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>", 160);
constexpr double col_width = 221.619792, gap = 14, pick_width = (col_width - 43) / 3;
// the slip's own measures, in dp: six columns across the sheet, eleven rows down
constexpr double col_width = 268, number_width = 34, pick_gap = 6, pick_width = (col_width - number_width - 3 * pick_gap) / 3, pick_height = 70;
for (int c = 0; c < 6; ++c) {
const auto count = summary.at("counts")[size_t(c)].get<int>();
out += "<section class=\"toto-field" + std::string(c == toto_column_ ? " selected-column" : "") + "\" style=\"left:" + scalar(28 + c * (col_width + gap)) +
"dp;\" aria-label=\"Tipp-Spalte " + std::to_string(c + 1) + "\">" +
btn("toto-column", "<span>Spalte</span><strong>" + std::to_string(c + 1) + "</strong>", "toto-column-heading",
out += "<section class=\"tt-field" + std::string(c == toto_column_ ? " selected-column" : "") + "\" aria-label=\"Tipp-Spalte " + std::to_string(c + 1) + "\">" +
btn("toto-column", "<span>Spalte</span><strong>" + std::to_string(c + 1) + "</strong>", "tt-column",
"id=\"toto-column-" + std::to_string(c) + "\" data-column=\"" + std::to_string(c) + "\" aria-pressed=\"" + (c == toto_column_ ? "true" : "false") + "\"") +
"<div class=\"toto-pick-head\"><span style=\"left:0;width:28dp;\">Nr.</span>";
for (int p = 0; p < 3; ++p)
out += "<span style=\"left:" + scalar(33 + p * (pick_width + 5)) + "dp;width:" + scalar(pick_width) + "dp;\">" + std::to_string(picks[size_t(p)]) + "</span>";
"<div class=\"tt-pick-head\"><span style=\"width:" + scalar(number_width) + "dp;font-size:17dp;\">Nr.</span>";
for (int p = 0; p < 3; ++p) out += "<span style=\"width:" + scalar(pick_width) + "dp;margin-left:" + scalar(pick_gap) + "dp;\">" + std::to_string(picks[size_t(p)]) + "</span>";
out += "</div>";
for (int r = 0; r < 11; ++r) {
out += "<div class=\"toto-pick-row\" style=\"top:" + std::to_string(116 + r * 82) + "dp;\"><span class=\"toto-row-number\">" + std::to_string(r + 1) + "</span>";
out += "<div class=\"tt-pick-row\"><span class=\"tt-row-number\" style=\"width:" + scalar(number_width) + "dp;\">" + std::to_string(r + 1) + "</span>";
for (int p = 0; p < 3; ++p) {
const auto pick = picks[size_t(p)]; const bool chosen = t.at("columns")[size_t(c)][size_t(r)] == pick;
const bool tabstop = toto_focus_[size_t(c)] == std::pair(r, pick);
out += btn("toto-pick", "<span class=\"toto-pick-value\">" + std::to_string(pick) + "</span>" + (chosen ?
"<span class=\"toto-cross\" style=\"transform:rotate(" + std::to_string(((c + r) % 3 - 1) * 3) + "deg);\">" + picture(cross, pick_width, 64) + "</span>" : ""),
out += btn("toto-pick", "<span class=\"tt-pick-value\">" + std::to_string(pick) + "</span>" + (chosen ?
"<span class=\"tt-cross\" style=\"transform:rotate(" + std::to_string(((c + r) % 3 - 1) * 3) + "deg);\">" + picture(cross, pick_width, pick_height) + "</span>" : ""),
"toto-pick", "id=\"" + toto_pick_id(c, r, pick) + "\" data-column=\"" + std::to_string(c) + "\" data-row=\"" + std::to_string(r) +
"\" data-pick=\"" + std::to_string(pick) + "\" aria-pressed=\"" + (chosen ? "true" : "false") + "\" aria-label=\"Spalte " + std::to_string(c + 1) +
", Spiel " + std::to_string(r + 1) + ", " + (pick == 1 ? "Heimsieg" : pick == 0 ? "Unentschieden" : "Auswärtssieg") +
"\" style=\"left:" + scalar(33 + p * (pick_width + 5)) + "dp;width:" + scalar(pick_width) + "dp;tab-index:" + (tabstop ? "auto" : "none") + ";\" data-tabstop=\"" + (tabstop ? "true" : "false") + "\"");
"\" style=\"width:" + scalar(pick_width) + "dp;margin-left:" + scalar(pick_gap) + "dp;tab-index:" + (tabstop ? "auto" : "none") + ";\" data-tabstop=\"" + (tabstop ? "true" : "false") + "\"");
}
out += "</div>";
}
out += "<p class=\"toto-field-progress\">" + (count == 0 ? "Leer" : count == 11 ? "Vollständig" : std::to_string(count) + " / 11") + "</p></section>";
out += "<span class=\"tt-progress" + std::string(count == 11 ? " full" : "") + "\">" + (count == 0 ? "Leer" : count == 11 ? "Vollständig" : std::to_string(count) + " / 11") + "</span></section>";
}
out += "<footer class=\"toto-paper-footer\"><p><strong>1</strong> Heimsieg <b>·</b> <strong>0</strong> Unentschieden <b>·</b> <strong>2</strong> Auswärtssieg</p>"
"<span>Pro Spiel und Spalte ein Kreuz. Leere Spalten bleiben unberücksichtigt.</span><small>"+std::string(engine_mode_?"Dreierpack · Digitaler Tippschein":"OpenBMH · Musterschein · Grafik-POC")+"</small></footer></article>";
out += "</div><footer class=\"tt-footer\"><span><strong>1</strong> = Heimsieg · <strong>0</strong> = Unentschieden · <strong>2</strong> = Auswärtssieg · pro Spiel und Spalte ein Kreuz</span><span>" +
std::string(engine_mode_?"Einsatz je Spalte":"Einsatz gesamt") + " <strong>" + esc(toto_cash(t.at("stake"))) + "</strong></span></footer></article></div>";
const int complete = summary.at("complete"), partial = summary.at("partial");
out += "<div class=\"toto-status\"><div><strong>" + std::to_string(complete) + (complete == 1 ? " vollständige Spalte" : " vollständige Spalten") +
"</strong><span id=\"toto-engine-feedback\">" + (engine_mode_&&!engine_toto_feedback_.empty()?esc(engine_toto_feedback_):partial ? std::to_string(partial) + (partial == 1 ? " Spalte noch unvollständig" : " Spalten noch unvollständig") :
"Spalte " + std::to_string(toto_column_ + 1) + " für Tippvorschlag und Leeren ausgewählt") + "</span></div><p>"+std::string(engine_mode_?"Einsatz je Spalte":"Einsatz gesamt")+" <strong>" + esc(toto_cash(t.at("stake"))) + "</strong></p></div>";
out += "<nav class=\"toto-nav\">" + btn("toto-stake", "Einsatz", "toto-control", "id=\"toto-stake\"") +
btn("toto-auto", "Tippvorschlag", "toto-control", "id=\"toto-auto\"") +
btn("toto-clear", "Spalte leeren", "toto-control", "id=\"toto-clear\" " + std::string(summary.at("counts")[size_t(toto_column_)] == 0 ? "disabled" : "")) +
btn("toto-submit", "Übernehmen", "toto-control", "id=\"toto-submit\" " + std::string(available && summary.at("can_submit").get<bool>() ? "" : "disabled")) +
btn("toto-last", engine_mode_&&t.at("coupon").is_null()?"Letzte Abrechnung":"Letzter Schein", "toto-control", "id=\"toto-last\" " + std::string(t.at("coupon").is_null()&&(!engine_mode_||engine_toto_value_.at("last").at("paid").get<int64_t>()==0) ? "disabled" : "")) + "</nav></div>";
const auto feedback = engine_mode_&&!engine_toto_feedback_.empty()?engine_toto_feedback_:partial ? std::to_string(partial) + (partial == 1 ? " Spalte noch unvollständig" : " Spalten noch unvollständig") :
"Spalte " + std::to_string(toto_column_ + 1) + " für Tippvorschlag und Leeren ausgewählt";
const bool can_submit = available && summary.at("can_submit").get<bool>();
out += "<nav class=\"pg-foot\">" + pg_button("toto-stake", "Einsatz", "", "id=\"toto-stake\"") + pg_button("toto-auto", "Tippvorschlag", "", "id=\"toto-auto\"") +
pg_button("toto-clear", "Spalte leeren", "", "id=\"toto-clear\" " + std::string(summary.at("counts")[size_t(toto_column_)] == 0 ? "disabled=\"disabled\"" : "")) +
pg_button("toto-submit", "Übernehmen", "primary", "id=\"toto-submit\" " + std::string(can_submit ? "" : "disabled=\"disabled\"")) +
pg_button("toto-last", engine_mode_&&t.at("coupon").is_null()?"Letzte Abrechnung":"Letzter Schein", "", "id=\"toto-last\" " + std::string(t.at("coupon").is_null()&&(!engine_mode_||engine_toto_value_.at("last").at("paid").get<int64_t>()==0) ? "disabled=\"disabled\"" : "")) +
"<span class=\"pg-sp\"></span><span class=\"pg-status\" id=\"toto-engine-feedback\" role=\"status\">" + esc(std::to_string(complete) + (complete == 1 ? " vollständige Spalte" : " vollständige Spalten") + " · " + feedback) + "</span></nav></section>";
if (toto_dialog_.empty()) return out;
if(engine_mode_&&toto_dialog_=="settlement") {const auto &last=engine_toto_value_.at("last");std::string detail="<div id=\"toto-layer\" class=\"toto-layer\"><section class=\"toto-dialog receipt settlement\" role=\"dialog\" aria-modal=\"true\"><h2>Letzte Toto-Abrechnung</h2><div class=\"toto-receipt\"><div class=\"toto-receipt-row head\"><span style=\"width:50%;\">Spalte</span><span style=\"width:50%;\">Treffer</span></div>";size_t n=0;for(const auto &hit:last.at("hits"))detail+="<div class=\"toto-receipt-row\"><span style=\"width:50%;\">Spalte "+std::to_string(++n)+"</span><span style=\"width:50%;\">"+std::to_string(hit.get<int>())+" Richtige</span></div>";return out+detail+"</div><p class=\"toto-receipt-total\">Bezahlt "+esc(toto_cash(last.at("paid")))+" · Gewonnen "+esc(toto_cash(last.at("won")))+"</p><nav class=\"toto-dialog-actions\">"+btn("toto-dialog-close","Schließen","toto-control","id=\"toto-dialog-close\"")+"</nav></section></div>";}
const auto close = [&](const std::string &label) { return pg_button("toto-dialog-close", label, "primary", "id=\"toto-dialog-close\""); };
const auto dialog = [&](const std::string &title, const std::string &body, const std::string &label, double width) {
return "<div id=\"toto-layer\" class=\"pg-ov\"><section class=\"pg-dlg\" role=\"dialog\" aria-modal=\"true\" aria-labelledby=\"toto-dialog-title\" style=\"width:" + pg(width) + ";\"><div><h2 id=\"toto-dialog-title\">" + esc(title) +
"</h2></div>" + body + "<nav class=\"pg-dlg-act\">" + close(label) + "</nav></section></div>";
};
const auto cell = [](const std::string &text, const std::string &css = std::string()) { return "<span class=\"tt-cell " + css + "\">" + text + "</span>"; };
if(engine_mode_&&toto_dialog_=="settlement") {
// what the last slip brought: the hits of every column, what was paid and what was won
const auto &last=engine_toto_value_.at("last");
std::string rows="<div class=\"pg-panel tt-receipt\"><div class=\"tt-receipt-row head\">"+cell("SPALTE","first")+cell("RICHTIGE")+"</div>";size_t n=0;
for(const auto &hit:last.at("hits"))rows+="<div class=\"tt-receipt-row\">"+cell("Spalte "+std::to_string(++n),"first")+cell("<strong>"+std::to_string(hit.get<int>())+" Richtige</strong>")+"</div>";
return out+dialog("Letzte Toto-Abrechnung",rows+"</div><span class=\"pg-mut\" style=\"display:block;\">Bezahlt "+esc(toto_cash(last.at("paid")))+" · Gewonnen "+esc(toto_cash(last.at("won")))+"</span>","Schließen",480);
}
const auto &coupon = t.at("coupon");
if (coupon.is_null()) { toto_dialog_.clear(); return out; }
std::vector<int> active;
for (int c = 0; c < 6; ++c) if (coupon.at("columns")[size_t(c)][0] != -1) active.push_back(c);
out += "<div id=\"toto-layer\" class=\"toto-layer\"><section class=\"toto-dialog " + toto_dialog_ + "\" role=\"dialog\" aria-modal=\"true\" aria-labelledby=\"toto-dialog-title\">"
"<h2 id=\"toto-dialog-title\">" + std::string(toto_dialog_ == "receipt" ? engine_mode_?"Aktuell vorgemerkter Schein":"Letzter vorgemerkter Schein" : "Tippschein vorgemerkt") + "</h2>";
const auto caption = std::to_string(active.size()) + (active.size() == 1 ? " Spalte" : " Spalten");
if (toto_dialog_ == "receipt") {
out += "<div class=\"toto-receipt\">";
for (int row = -1; row < 11; ++row) {
out += "<div class=\"toto-receipt-row " + std::string(row == -1 ? "head" : row % 2 == 0 ? "striped" : "") + "\"><span style=\"width:16%;\">" + (row == -1 ? "Spiel" : std::to_string(row + 1)) + "</span>";
for (const auto c : active) out += "<span style=\"width:" + scalar(84.0 / active.size()) + "%;\">" +
(row == -1 ? "Spalte " + std::to_string(c + 1) : std::to_string(coupon.at("columns")[size_t(c)][size_t(row)].get<int>())) + "</span>";
out += "</div>";
const auto total = "<div class=\"pg-row\" style=\"justify-content:space-between;\"><span>Gesamteinsatz</span><strong class=\"pg-h\">" + esc(toto_cash(coupon.at("stake"))) + "</strong></div>";
if (toto_dialog_ != "receipt")
return out + dialog("Tippschein vorgemerkt", "<p>" + esc(caption + " · " + std::to_string(active.size() * 11) + " Tipps") + "</p>" + total, "Verstanden", 480);
// the slip that waits for the matchday: every match with the tip of each column
std::string rows = "<div class=\"pg-panel tt-receipt\"><div class=\"tt-receipt-row head\">" + cell("SPIEL", "first");
for (const auto c : active) rows += cell("SP. " + std::to_string(c + 1));
rows += "</div>";
for (int row = 0; row < 11; ++row) {
std::string match = std::to_string(row + 1) + ".";
if (size_t(row) < games.size()) {
const auto side = [&](const char *key, const char *reference) {
const auto &game = games[size_t(row)];
if (game.value(reference, Json()).is_object()) return game.at(reference).at("name").get<std::string>();
const auto *club = world_->find("clubs", game.at(key));
return club ? world_->name(*club) : std::string("—");
};
match += " " + side("home", "home_ref") + " – " + side("away", "away_ref");
}
out += "</div><p class=\"toto-receipt-total\">" + caption + " · Einsatz gesamt " + esc(toto_cash(coupon.at("stake"))) + "</p>";
} else out += "<p class=\"toto-notice\">" + caption + " · " + std::to_string(active.size() * 11) + " Tipps · Einsatz gesamt " + esc(toto_cash(coupon.at("stake"))) + "</p>";
out += "<nav class=\"toto-dialog-actions\">" + btn("toto-dialog-close", toto_dialog_ == "receipt" ? "Schließen" : "Verstanden", "toto-control", "id=\"toto-dialog-close\"") + "</nav></section></div>";
return out;
rows += "<div class=\"tt-receipt-row\">" + cell(esc(match), "first");
for (const auto c : active) rows += cell("<strong>" + std::to_string(coupon.at("columns")[size_t(c)][size_t(row)].get<int>()) + "</strong>");
rows += "</div>";
}
return out + dialog(engine_mode_?"Aktuell vorgemerkter Schein":"Letzter vorgemerkter Schein", rows + "</div>" + total, "Schließen", 620);
}