Bind the six-column Toto coupon to reviewed engine costs and settlement (by Codex)

This commit is contained in:
Codex committed 2026-10-29 04:44:07 +01:00
1 parent eb140cdb1c
commit dfb972abbd
27 files changed
+368 -53

No files matched your search

+19 -18
View File
@@ -5,19 +5,19 @@ std::string toto_pick_id(int col, int row, int pick) {
}
}
std::string App::render_toto() {
const auto state = snap().state;
const auto &t = state.at("toto");
const auto summary = demo_toto_summary(state, *world_), programme = demo_toto_programme(*world_);
const auto t=toto_value();
const auto toto_cash=[&](int64_t value){return engine_mode_?money(value,{{"code","EUR"},{"minor_units",2}}):cash(value);};
const auto summary=toto_summary(),programme=toto_programme();
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>Spielrunde 27 · Saison " + esc(programme.at("season").get<std::string>()) +
"<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>";
const auto club_name = [&](const Json *club, bool home) {
if (!club) return std::string("<span class=\"toto-club-name\">—</span>");
const auto name = "<span class=\"toto-club-name\">" + esc(world_->name(*club)) + "</span>", logo = crest(club, 34);
return "<span class=\"toto-club-label\" title=\"" + esc(world_->name(*club)) + "\">" +
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>";
};
for (int r = 0; r < 11; ++r) {
@@ -26,14 +26,14 @@ std::string App::render_toto() {
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) + "</div><span class=\"toto-versus\">–</span><div class=\"toto-away\">" + club_name(away, false) +
"</div></div><span class=\"toto-match-league\">" + (has ? std::to_string(games[size_t(r)].at("tier").get<int>()) + ". BL" : "—") + "</span></div>";
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 += "<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>Spielprogramm 27</small></div></header>";
"<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>";
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;
for (int c = 0; c < 6; ++c) {
@@ -63,23 +63,24 @@ std::string App::render_toto() {
out += "<p class=\"toto-field-progress\">" + (count == 0 ? "Leer" : count == 11 ? "Vollständig" : std::to_string(count) + " / 11") + "</p></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>OpenBMH · Musterschein · Grafik-POC</small></footer></article>";
"<span>Pro Spiel und Spalte ein Kreuz. Leere Spalten bleiben unberücksichtigt.</span><small>"+std::string(engine_mode_?"OpenBMH · Digitaler Tippschein":"OpenBMH · Musterschein · Grafik-POC")+"</small></footer></article>";
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>" + (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>Einsatz gesamt <strong>" + esc(cash(t.at("stake"))) + "</strong></p></div>";
"</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", "Letzter Schein", "toto-control", "id=\"toto-last\" " + std::string(t.at("coupon").is_null() ? "disabled" : "")) + "</nav></div>";
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>";
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 &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" ? "Letzter vorgemerkter Schein" : "Tippschein vorgemerkt") + "</h2>";
"<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\">";
@@ -89,8 +90,8 @@ std::string App::render_toto() {
(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>";
}
out += "</div><p class=\"toto-receipt-total\">" + caption + " · Einsatz gesamt " + esc(cash(coupon.at("stake"))) + "</p>";
} else out += "<p class=\"toto-notice\">" + caption + " · " + std::to_string(active.size() * 11) + " Tipps · Einsatz gesamt " + esc(cash(coupon.at("stake"))) + "</p>";
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;
}