The takers of free kicks, penalties and corners can be named in the line-up

The read lineup states the three takers (setPieces; null is the assistant's
choice) and the new command lineup.setPiece names one or hands all three
back, through the game's own set_pitch_set_piece_taker_source and
auto_pitch_set_piece_takers_source. In the line-up, Schütze opens the three
cards; a card is chosen and the next click on a player names him.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Fable 5.2 committed 2026-11-16 14:25:04 +01:00
1 parent 11264ccdb5
commit 92555b9ba0
9 files changed
+116 -3

No files matched your search

+1
View File
@@ -21,6 +21,7 @@ Json engine_training_command(const Json &bundle, const Json &draft,
const std::string &request_id);
Json engine_bank_projection(const Json &bundle);
Json engine_bank_command(const Json &bundle, const Json &payload, const std::string &request_id);
Json engine_set_piece_command(const Json &bundle, const Json &payload, const std::string &request_id);
Json engine_credit_projection(const Json &bundle, const Json &read);
Json engine_credit_command(const Json &bundle, const Json &read, const Json &edits, const std::string &request_id);
Json engine_ticket_projection(const Json &bundle);
+21 -1
View File
@@ -163,10 +163,30 @@ Json engine_lineup_projection(const Json &bundle) {
}
}
require(ids.size() == members.size() && ids.size() == roles.size(), "Aufstellung enthält nicht den vollständigen Kader.");
return {{"ok", true}, {"rows", rows}, {"field_count", points.size()},
// who takes free kicks, penalties and corners (null: the assistant decides); an older backend states none
Json set_pieces;
if (lineup.contains("setPieces")) {
set_pieces = Json::object();
for (const auto *key : {"freeKick", "penalty", "corner"}) {
const auto &taker = lineup.at("setPieces").at(key);
require(taker.is_null() || (taker.is_string() && members.contains(taker.get<std::string>())), "Unbekannter Schütze.");
set_pieces[key] = taker;
}
}
return {{"ok", true}, {"rows", rows}, {"field_count", points.size()}, {"set_pieces", set_pieces},
{"surface", surface.at("surface")}, {"duration", surface.at("duration")}, {"pairs", surface.at("pairs")},
{"board", {{"order", lineup.at("order")}, {"points", points}, {"depth_max", depth_max}, {"lane_max", lane_max}}}};
}
namespace { Json sports_command(const Json &bundle, const char *kind, const Json &payload, const std::string &id); }
Json engine_set_piece_command(const Json &bundle, const Json &payload, const std::string &request_id) {
const auto projection = engine_lineup_projection(bundle);
require(projection.at("set_pieces").is_object(), "Schützen sind in diesem Kontext nicht verfügbar.");
if (payload.value("auto", false) != true) {
const auto piece = payload.at("piece").get<std::string>();
require(payload.size() == 2 && (piece == "freeKick" || piece == "penalty" || piece == "corner") && payload.at("playerId").is_string(), "Ungültiger Schützenauftrag.");
} else require(payload.size() == 1, "Ungültiger Schützenauftrag.");
return sports_command(bundle, "lineup.setPiece", payload, request_id);
}
Json engine_lineup_command(const Json &bundle, const Json &order, const std::string &request_id) {
const auto projection = engine_lineup_projection(bundle);
const auto &meta = bundle.at("desktop").at("meta");
+26
View File
@@ -65,8 +65,34 @@ bool App::engine_lineup_action(const std::string &action, const std::string &id,
else { lineup_pitch_ = !lineup_pitch_; lineup_reset_scroll_ = true; }
focus_after_render_ = target->GetId(); refresh(); return true;
}
// "Schütze": the side panel names the takers of the set pieces; a click on a player then names him
if (action == "lineup-side") {
lineup_side_ = id == "takers" && lineup_side_ != "takers" ? "takers" : "formations";
lineup_selected_.clear(); focus_after_render_ = "lineup-side-takers"; refresh(); return true;
}
if (action == "lineup-piece") {
if (id == "freeKick" || id == "penalty" || id == "corner") lineup_piece_ = id;
focus_after_render_ = target->GetId(); refresh(); return true;
}
const auto send_takers = [this](const Json &payload, const std::string &focus) {
if (!engine_fresh_ || engine_busy_) return;
try {
const auto command = engine_set_piece_command(engine_data_, payload, editor::new_id("request:ui-"));
focus_after_render_ = focus;
auto link = engine_link_;
engine_start("Schütze wird eingetragen …", [link, command] {
auto response = link->command(command);
return EngineReply{link, link->snapshot(), response, nullptr};
}, true);
} catch (const std::exception &e) { message(e.what()); }
};
if (action == "lineup-piece-auto") { send_takers({{"auto", true}}, "lineup-piece-auto"); return true; }
if (action != "lineup-player" && action != "player-detail") return action.starts_with("lineup-");
const auto projection = engine_lineup_projection(engine_data_);
if (action == "lineup-player" && lineup_side_ == "takers" && projection.at("set_pieces").is_object()) {
send_takers({{"piece", lineup_piece_}, {"playerId", id}}, target->GetId());
return true;
}
auto order = projection.at("board").at("order");
auto chosen = std::find(order.begin(), order.end(), Json(id));
if (chosen == order.end()) return true;
+1
View File
@@ -5,6 +5,7 @@
Json engine_data_, engine_response_, engine_focus_, engine_training_draft_, engine_tactics_draft_;
std::string engine_camp_, engine_operation_, engine_notice_, engine_player_;
Json engine_credit_, engine_credit_edits_ = Json::array();
std::string lineup_piece_ = "freeKick"; // the set piece whose taker the next click on a player names
// whose loan engine_credit_ shows ("bank" or a manager's id), the fellow manager chosen on the page
// "Spieler", and a lender whose loan could not be read (not asked again until something changes)
std::string engine_credit_lender_ = "bank", bank_lender_, engine_credit_refused_;
+19 -1
View File
@@ -127,6 +127,21 @@ std::string App::render_lineup_page() {
}
out += "</div>";
}
const bool takers = lineup_side_ == "takers" && projection.at("set_pieces").is_object();
if (takers) {
// who takes the set pieces: one of the three is chosen, the next click on a player names him
out += "<div class=\"pg-panel pg-col pg-grow\" style=\"" + pg_css("gap:6px;padding:10px 14px;") + "\"><div class=\"pg-row\" style=\"justify-content:space-between;\"><strong class=\"pg-h\">Standardschützen</strong>" +
pg_button("lineup-piece-auto", "Alle dem Co-Trainer", "", "id=\"lineup-piece-auto\"") + "</div><div class=\"pg-row\" style=\"align-items:stretch;" + pg_css("gap:8px;") + "\">";
for (const auto &[key, label] : std::array<std::pair<const char *, const char *>, 3>{{{"freeKick", "Freistoß"}, {"penalty", "Elfmeter"}, {"corner", "Eckball"}}}) {
const auto &taker = projection.at("set_pieces").at(key);
std::string name = "Co-Trainer";
if (taker.is_string()) for (const auto &row : rows) if (row.at("id") == taker) name = last_name(row.at("name").get<std::string>());
const bool chosen = lineup_piece_ == key;
out += btn("lineup-piece", "<span class=\"pg-k\">" + pg_upper(label) + "</span><strong class=\"pg-nowrap\">" + esc(name) + "</strong>", std::string("pg-card lp-piece") + (chosen ? " sel" : ""),
attr("id", std::string("lineup-piece-") + key) + attr("data-id", key) + attr("aria-pressed", chosen ? "true" : "false"));
}
out += "</div><span class=\"pg-mut\" style=\"display:block;font-size:" + pg(12.5) + ";\">Eine der drei Karten wählen, dann den Schützen in der Liste oder auf dem Feld anklicken. Möglich ist, wer aufgestellt ist oder auf der Bank sitzt.</span></div></div></div>";
} else {
out += "<div class=\"pg-panel pg-col pg-grow\" style=\"" + pg_css("gap:4px;padding:10px 14px;") + "\"><div class=\"pg-row\" style=\"justify-content:space-between;\"><strong class=\"pg-h\">Aufstellung</strong><span class=\"pg-legend\">"
"<span class=\"pg-legend-item\"><span class=\"pg-legend-mark lp-dot a\"></span><span>ab 85</span></span><span class=\"pg-legend-item\"><span class=\"pg-legend-mark lp-dot b\"></span><span>ab 70</span></span>"
"<span class=\"pg-legend-item\"><span class=\"pg-legend-mark lp-dot c\"></span><span>darunter</span></span></span></div><span style=\"display:block;\">Zwei Spieler zum Tauschen anklicken.</span>"
@@ -143,6 +158,7 @@ std::string App::render_lineup_page() {
out += "</div>";
}
out += "</div></div></div>";
}
// --- the foot ---
const auto pair_of = [&](const char *action, const char *id, const std::string &first, const std::string &second, bool second_on) {
@@ -156,10 +172,12 @@ std::string App::render_lineup_page() {
std::string status = engine_busy_ ? engine_operation_ : engine_notice_;
if (!lineup_selected_.empty())
for (const auto &row : rows) if (row.at("id") == lineup_selected_) status = row.at("name").get<std::string>() + " markiert · zweiten Spieler wählen.";
if (lineup_side_ == "takers" && projection.at("set_pieces").is_object() && !engine_busy_) status = "Schützen: Karte wählen, dann Spieler anklicken.";
if (status.empty()) status = "Kein Spieler markiert.";
out += "<nav class=\"pg-foot\">" + pair_of("lineup-data", "lineup-data", "Daten A", "Daten B", lineup_data_ == 1) + pair_of("lineup-view", "lineup-view", "Spielfeld", "Team", !lineup_pitch_) + "<div class=\"pg-seg\">";
for (const auto &[side, label] : std::array<std::pair<const char *, const char *>, 3>{{{"formations", "Aufst."}, {"orders", "Anweis."}, {"takers", "Schütze"}}})
out += btn("lineup-side", "<span>" + std::string(label) + "</span>", std::string(side) == "formations" ? "first" : "", attr("id", "lineup-side-" + std::string(side)) + attr("data-id", side) + " disabled title=\"Im Spiel nicht verfügbar\"");
out += btn("lineup-side", "<span>" + std::string(label) + "</span>", std::string(std::string(side) == "formations" ? "first" : "") + (std::string(side) == "takers" && takers ? " on" : ""),
attr("id", "lineup-side-" + std::string(side)) + attr("data-id", side) + (std::string(side) == "takers" && projection.at("set_pieces").is_object() ? attr("aria-pressed", takers ? "true" : "false") : std::string(" disabled title=\"Im Spiel nicht verfügbar\"")));
out += "</div><span class=\"pg-tag sage\">" + std::string(indoor ? "Halle · 40 Min." : "Rasen · 90 Min.") + "</span><span class=\"pg-sp\"></span>" + pg_status(status) + "</nav></div>";
return out + engine_player_profile(projection);
}