Players wear shirt numbers the manager can change

Every player keeps a number from 1 to 99, unique within his squad. The
line-up shows it and changes it by a click; the tactics sketch and the
match sheet wear it too.

Engine: shirt_numbers.hpp, squad read player.shirtNumber, command
lineup.setNumber; saved in state/modern.json.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Fable 5.2 committed 2026-11-17 16:58:34 +01:00
1 parent 7b3f52d809
commit 72e06aabdb
20 files changed
+304 -8

No files matched your search

+15
View File
@@ -255,3 +255,18 @@ void App::engine_assembly_choose(const std::string &team) {
popup_title_ = "Vereinswechsel";
popup_accept_ = "Wechseln";
}
// Shirt numbers: what the squad read says a player wears.
std::string App::engine_shirt(const std::string &player, size_t fallback) const {
if (engine_mode_) try {
for (const auto &row : engine_data_.at("squad").at("data").at("players"))
if (row.at("player").at("id") == player && row.at("player").at("shirtNumber").is_number_integer()) return std::to_string(row.at("player").at("shirtNumber").get<int>());
} catch (const std::exception &) {}
return std::to_string(fallback);
}
std::string App::engine_shirt_at(size_t place) const {
if (engine_mode_) try {
const auto &rows = engine_data_.at("squad").at("data").at("players");
if (place < rows.size() && rows[place].at("player").at("shirtNumber").is_number_integer()) return std::to_string(rows[place].at("player").at("shirtNumber").get<int>());
} catch (const std::exception &) {}
return std::to_string(place + 1);
}
+2
View File
@@ -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);
// A player of the squad gets the shirt number 1-99.
Json engine_shirt_number_command(const Json &bundle, const std::string &player, int number, 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").
+18 -1
View File
@@ -521,7 +521,24 @@ void App::engine_event(Rml::Event &event) {
if (action == "popup-confirm") { auto callback=std::move(confirm_);auto text_callback=std::move(text_accept_);const auto text=field("popup-text");popup_.clear();reset_popup();dirty_=true;if(text_callback)text_callback(text);else if(callback)callback(); }
return;
}
if (engine_assembly_open_) { engine_assembly_action(action, id); return; } // the sheet of the interested clubs lies over everything
if (engine_assembly_open_) { engine_assembly_action(action, id); return; }
if (action == "lineup-number" && engine_fresh_ && !engine_busy_ && menu_ == "lineup") {
// a new shirt number for the player; whoever wears it takes his
const std::string player = id;
const auto meta = engine_data_.at("desktop").at("meta");
AmountRequest request;
request.title = "Rückennummer";
request.review_text = [](int64_t) { return "Trägt schon ein anderer Spieler die Nummer, tauschen die beiden."; };
request.unit = "";
try { request.value = std::stoll(engine_shirt(player, 1)); } catch (const std::exception &) { request.value = 1; }
request.min = 1; request.max = 99; request.step = 1; request.suggestion_step = 1; request.review = false;
request.accept = [this, meta, player](int64_t value) {
if (engine_busy_ || !engine_fresh_ || meta != engine_data_.at("desktop").at("meta")) return false;
try { engine_finance_submit(engine_shirt_number_command(engine_data_, player, int(value), editor::new_id("request:ui-"))); } catch (const std::exception &) { return false; }
return true;
};
open_amount(std::move(request)); return;
} // the sheet of the interested clubs lies over everything
if (action == "engine-widget-warning" && menu_.empty() && !engine_busy_) {
const auto rows = engine_widgets_projection(engine_data_).at("warnings");
std::string text;
+3
View File
@@ -513,6 +513,9 @@ Json engine_environment_projection(const Json &bundle) {
}
return {{"ok", true}, {"rows", rows}};
}
Json engine_shirt_number_command(const Json &bundle, const std::string &player, int number, const std::string &request_id) {
return sports_command(bundle, "lineup.setNumber", {{"playerId", player}, {"number", number}}, request_id);
}
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);
}
+7 -2
View File
@@ -53,7 +53,12 @@ std::string App::render_lineup_page() {
size_t field = 0;
for (const auto &column : columns) {
const std::string key = column.key;
if (std::string(column.label) == "Nr.") { out += pg_td(slot < field_count ? std::to_string(slot + 1) : std::string("–"), column.width, "r"); continue; }
if (std::string(column.label) == "Nr.") {
// the shirt number; with the engine it can be changed by a click
if (engine_mode_) out += pg_td(btn("lineup-number", "<span>" + engine_shirt(id, size_t(slot + 1)) + "</span>", "pg-link", "id=\"lineup-number-" + esc(id) + "\" data-id=\"" + esc(id) + "\" title=\"Rückennummer ändern\""), column.width, "r", true);
else out += pg_td(slot < field_count ? std::to_string(slot + 1) : std::string("–"), column.width, "r");
continue;
}
if (std::string(column.label) == "Name") {
auto name = esc(row.at("name").get<std::string>());
if (row.at("pair_number").is_number_integer()) name += "</span><span class=\"pg-tag sage\" style=\"margin-left:" + pg(6) + ";\">P" + std::to_string(row.at("pair_number").get<int>());
@@ -91,7 +96,7 @@ std::string App::render_lineup_page() {
const bool selected = lineup_selected_ == row.at("id").get<std::string>();
const std::string level = condition.is_number_integer() ? (condition.get<int>() >= 85 ? "a" : condition.get<int>() >= 70 ? "b" : "c") : "n";
return btn("lineup-player", "<span class=\"lp-shirt-art\">" + picture(renderer_.diagram("lineup-shirt-" + shirt_colour + (selected ? "-s-" : "-n-") + level, lineup_shirt(shirt_colour, selected, condition), 160), shirt_size, shirt_size) +
"<span class=\"lp-num\">" + (index < size_t(field_count) ? std::to_string(index + 1) : std::string()) + "</span></span><span class=\"lp-name\">" + esc(last_name(row.at("name").get<std::string>())) + "</span>",
"<span class=\"lp-num\">" + (engine_mode_ ? engine_shirt(row.at("id").get<std::string>(), index + 1) : index < size_t(field_count) ? std::to_string(index + 1) : std::string()) + "</span></span><span class=\"lp-name\">" + esc(last_name(row.at("name").get<std::string>())) + "</span>",
std::string("lp-shirt") + (selected ? " sel" : ""), player_attrs(row, "lineup-player-") + (style.empty() ? std::string() : " style=\"" + style + "\""));
};
const double side_width = 900, pitch_height = 1512 - 27 - (indoor ? 420 : 250);
+2 -2
View File
@@ -204,7 +204,7 @@ std::string App::live_roster(const Json &owner) {
last = "<div class=\"mv-ko\"><span class=\"bar\"><div style=\"width:" + std::to_string(value) + "%;background-color:" +
(value > 70 ? "#56874a" : value > 50 ? "#d9a441" : "#c8372d") + ";\"></div></span><span>" + std::to_string(value) + "</span></div>";
}
out += "<div class=\"mv-tr\" data-live-player=\"" + esc(id) + "\">" + cell(std::to_string(i + 1), "w1") +
out += "<div class=\"mv-tr\" data-live-player=\"" + esc(id) + "\">" + cell(engine_shirt(id, i + 1), "w1") +
cell(live_position_text(row.value("position", Json())), "w2 l pos") +
"<span class=\"nm\"><span class=\"t\">" + esc(row.at("name").get<std::string>()) + "</span>" + badges + "</span>" +
cell(lineup_value(row.at(national ? "caps" : "strength")), "w3") + last + "</div>";
@@ -328,7 +328,7 @@ std::string App::live_dialog_markup(const Json &owner) {
if (chosen) names[bench] = rows[i].at("name").get<std::string>();
const std::string strength = lineup_value(rows[i].value("strength", Json())), condition = lineup_value(rows[i].value("condition", Json()));
lists[bench] += btn(bench ? "live-pick-in" : "live-pick-out",
"<span class=\"nr\">" + std::to_string(i + 1) + "</span><span class=\"ps\">" + esc(live_position_text(rows[i].value("position", Json()))) + "</span><span class=\"nm\">" +
"<span class=\"nr\">" + engine_shirt(id, i + 1) + "</span><span class=\"ps\">" + esc(live_position_text(rows[i].value("position", Json()))) + "</span><span class=\"nm\">" +
esc(rows[i].at("name").get<std::string>()) + "</span><span class=\"vl\">" + esc(strength + " · " + condition) + "</span>",
std::string("mv-pick") + (chosen ? " selected" : ""),
"id=\"live-pick-" + std::to_string(i) + "\" data-id=\"" + esc(id) + "\" aria-pressed=\"" + (chosen ? "true" : "false") + "\"");
+4
View File
@@ -53,6 +53,10 @@
void engine_assembly_ask(const Json &args);
void engine_assembly_clubs(bool forced);
void engine_assembly_choose(const std::string &team);
// The shirt number of a player of the squad at the desk, or of its n-th player; the fallback
// (the place on the board) where the engine gives none.
std::string engine_shirt(const std::string &player, size_t fallback) const;
std::string engine_shirt_at(size_t place) const;
// The big sheet of the interested clubs: open or not, the club whose details are shown, and
// where its list was scrolled to before the sheet was drawn again.
bool engine_assembly_open_ = false;
+1 -1
View File
@@ -119,7 +119,7 @@ std::string App::render_tactics() {
for (size_t i = 0; i < 11; ++i) {
const auto &[x, y, side] = players[i];
lines += "<circle cx=\"" + scalar(x) + "\" cy=\"" + scalar(y) + "\" r=\"17\" fill=\"" + paper + "\" fill-opacity=\".85\" stroke=\"" + ink + "\" stroke-width=\"2.6\"/>";
over += "<span class=\"tk-text tk-number\" style=\"" + at(x - 25, y - 14, 50, 28) + "font-size:" + scalar(23 * tactics_unit) + "dp;line-height:" + scalar(28 * tactics_unit) + "dp;color:" + ink + ";\">" + std::to_string(i + 1) + "</span>";
over += "<span class=\"tk-text tk-number\" style=\"" + at(x - 25, y - 14, 50, 28) + "font-size:" + scalar(23 * tactics_unit) + "dp;line-height:" + scalar(28 * tactics_unit) + "dp;color:" + ink + ";\">" + engine_shirt_at(i) + "</span>";
if (side != 0) over += "<div class=\"tk-drag\" data-tactic-drag=\"wings\" data-side=\"" + std::to_string(int(side)) + "\" title=\"Nach außen oder innen ziehen\" style=\"" + at(x - 25, y - 25, 50, 50) + "\"></div>";
}
// the three knobs: head of the pass, its arc, head of the goal kick