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:
1 parent
11264ccdb5
commit
92555b9ba0
9 files changed
+116
-3
No files matched your search
@@ -1044,3 +1044,6 @@ body.midnight .cp-map-name,body.matchday .cp-map-name {color:#f0ece2;font-effect
|
||||
.sd-axis-item span {display:block;white-space:nowrap;}
|
||||
/* line-up: a small photo before the name */
|
||||
.lp-face {display:block;flex:none;width:46dp;height:46dp;margin-right:14dp;border-radius:23dp;overflow:hidden;background-color:var(--p-n3);}
|
||||
/* line-up: the takers of the set pieces */
|
||||
.pg-card.lp-piece,.pg-card.lp-piece:hover {flex:1;gap:4dp;padding:18dp 27dp;border-radius:36dp;min-width:0;}
|
||||
.lp-piece strong {display:block;font-family:Display;font-weight:normal;font-size:38dp;line-height:46dp;}
|
||||
@@ -105,6 +105,7 @@ Die UI ruft diese über `DataSource::read_almanac` und `read_statistics` direkt
|
||||
| `balance.commit` | view future, nichtleere edits wie im Read, acceptWarning bei Bilanzwarnung | übernimmt die mit vorhandenen Core-Funktionen rekonstruierte Zukunftsplanung; keine unmittelbare Cash-Buchung. Fehler invalid_payload, confirmation_required, balance_refused; veraltete Karriere/Manager/Revision wie üblich. |
|
||||
| `news.update` | `messageId`, `action` `read`/`unread`/`archive`/`trash`/`restore` | eine Nachricht des eigenen Postfachs: gelesen und Papierkorb sind Markierungen der Oberfläche (im Spielstand, `news_marks` je Manager; die Nachricht bleibt im Postfach des Originals, `restore` holt sie zurück), `archive` ist das „Behalten“ des Originals (eine behaltene Nachricht wird bei vollem Postfach nicht verdrängt), `restore` gibt sie wieder frei. Endgültiges Löschen bietet die Schnittstelle nicht an. Unverändert: `no_change`; Fehler `unknown_message` |
|
||||
| `lineup.commit` | `order`: Spieler-IDs in der gewünschten Reihenfolge | öffnet die Aufstellung wie am Schreibtisch und tauscht die Zeilen; Fehler `unknown_player`, `lineup_refused` (z. B. Verletzte, Ausländerregel) |
|
||||
| `lineup.setPiece` | `piece` `freeKick`/`penalty`/`corner` und `playerId`, oder `auto: true` | trägt einen Schützen ein (aufgestellt oder auf der Bank, einsatzfähig) bzw. gibt alle drei an den Assistenten zurück; der Read `lineup` nennt sie unter `setPieces` (`null` = Assistent); Fehler `invalid_payload`, `unknown_player`, `lineup_refused` |
|
||||
| `tactics.commit` | `values`: die acht Werte | jede geänderte Einstellung über die Prüfung der Taktiktafel (eine gesetzte Grundausrichtung beendet die Steuerung durch den Assistenten); Fehler `invalid_tactic` |
|
||||
| `training.commit` | optional `types` (4), `areas` (9), `players [{playerId, intensity}]` | richtet das Training bei Bedarf ein, setzt erst die Senkungen, dann die Erhöhungen (jeder Zwischenstand bleibt in den Grenzen); Fehler `training_unavailable`, `unknown_player` und die Gründe der Engine |
|
||||
|
||||
|
||||
@@ -9245,8 +9245,22 @@ cli::Json ModernSession::ui_read(const cli::Json& request, uint64_t revision) co
|
||||
{"partnerId", partner >= 0 ? cli::Json(row_ids[size_t(partner)]) : cli::Json(nullptr)}});
|
||||
}
|
||||
}
|
||||
// the takers of free kicks, penalties and corners (manager record +0xafc, +0xafe, +0xb08:
|
||||
// the player's index + 1, zero the assistant's choice; valid once +0xb0a carries 0x3253)
|
||||
const size_t taker_rec = size_t(manager) * 0xb0c;
|
||||
const bool takers_set = taker_rec + 0xb0b < g_.manager_records.size() &&
|
||||
uint16_t(g_.manager_records[taker_rec + 0xb0a] | uint16_t(g_.manager_records[taker_rec + 0xb0b]) << 8) == 0x3253;
|
||||
const auto taker = [&](size_t offset) -> cli::Json {
|
||||
if (!takers_set) return nullptr;
|
||||
const uint16_t stored = uint16_t(g_.manager_records[taker_rec + offset] | uint16_t(g_.manager_records[taker_rec + offset + 1]) << 8);
|
||||
if (!stored || stored > 0x0fff) return nullptr;
|
||||
for (size_t row = 0; row < range.count; ++row)
|
||||
if ((g_.squad_slots[range.first + row] & 0x0fff) == stored - 1) return row_ids[row];
|
||||
return nullptr;
|
||||
};
|
||||
return modern::ui_snapshot(g_, context, request_id,
|
||||
O{{"kind", "lineup"}, {"teamId", modern::ui_team_id(g_, team)}, {"formationId", nullptr}, {"order", std::move(order)},
|
||||
{"setPieces", O{{"freeKick", taker(0xafc)}, {"penalty", taker(0xafe)}, {"corner", taker(0xb08)}}},
|
||||
{"surface", g_.indoor ? "indoor" : "outdoor"}, {"durationMinutes", g_.indoor ? 40 : 90}, {"starterCount", 11},
|
||||
{"pairs", std::move(pairs)},
|
||||
{"rows", std::move(rows)}, {"positions", std::move(positions)}, {"depthMax", 19}, {"laneMax", 8},
|
||||
@@ -10953,6 +10967,35 @@ cli::Json ModernSession::ui_command(const cli::Json& request, uint64_t& revision
|
||||
if (!ok) { restore(); return refuse(error == "unknown_player" ? "unknown_player" : "lineup_refused", error); }
|
||||
revision = previous + 1;
|
||||
answer = modern::ui_command_result(request_id, previous, revision, {"lineup", "squad"}, "Aufstellung übernommen.");
|
||||
} else if (kind == "lineup.setPiece") {
|
||||
// payload {piece: "freeKick" | "penalty" | "corner", playerId} names one taker;
|
||||
// {auto: true} hands all three back to the assistant (the original's AUTO)
|
||||
const int team = g_.manager_teams[size_t(manager)];
|
||||
const SquadRange range = squad_range(team);
|
||||
if (!initialize_pitch_set_piece_source(g_, manager, team)) { restore(); return refuse("lineup_refused", "Schützen sind hier nicht verfügbar."); }
|
||||
const size_t rec = size_t(manager) * 0xb0c;
|
||||
static constexpr size_t offsets[] = {0xafc, 0xafe, 0xb08};
|
||||
std::array<uint16_t, 3> current{};
|
||||
for (size_t i = 0; i < 3; ++i) current[i] = uint16_t(g_.manager_records[rec + offsets[i]] | uint16_t(g_.manager_records[rec + offsets[i] + 1]) << 8);
|
||||
bool ok = false;
|
||||
if (const cli::Json* automatic = ui_field(*payload, "auto"); automatic && automatic->boolean() && *automatic->boolean()) {
|
||||
ok = auto_pitch_set_piece_takers_source(g_, manager, team, current);
|
||||
} else {
|
||||
const std::string piece = ui_text(*payload, "piece"), id = ui_text(*payload, "playerId");
|
||||
const int selector = piece == "freeKick" ? 2 : piece == "penalty" ? 3 : piece == "corner" ? 4 : 0;
|
||||
if (!selector || id.empty()) { restore(); return refuse("invalid_payload", "piece ist freeKick, penalty oder corner; playerId nennt den Schützen."); }
|
||||
size_t at = range.count;
|
||||
for (size_t row = 0; row < range.count; ++row) {
|
||||
const int p = g_.squad_slots[range.first + row] & 0x0fff;
|
||||
if (p != 0x0fff && modern::ui_player_id(g_, p) == id) at = row;
|
||||
}
|
||||
if (at == range.count) { restore(); return refuse("unknown_player", "Dieser Spieler gehört nicht zum Kader."); }
|
||||
const uint16_t slot = g_.squad_slots[range.first + at];
|
||||
ok = set_pitch_set_piece_taker_source(g_, manager, team, selector, int(at), slot & 0x0fff, slot, current[size_t(selector - 2)]);
|
||||
}
|
||||
if (!ok) { restore(); return refuse("lineup_refused", "Schütze kann nur sein, wer aufgestellt oder auf der Bank und einsatzfähig ist."); }
|
||||
revision = previous + 1;
|
||||
answer = modern::ui_command_result(request_id, previous, revision, {"lineup"}, "Schützen übernommen.");
|
||||
} else {
|
||||
return refuse("unknown_command", "Unbekannter Befehl: " + kind);
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ A allowed_commands(const ModernState& g, const UiContext& c) {
|
||||
const int team = team_of(g, c.manager);
|
||||
const bool national = team == no_team();
|
||||
static constexpr const char* kAll[] = {
|
||||
"session.advance", "lineup.commit", "tactics.commit", "friendly.book", "manager.resign.commit",
|
||||
"session.advance", "lineup.commit", "lineup.setPiece", "tactics.commit", "friendly.book", "manager.resign.commit",
|
||||
"training.commit", "camp.book", "bank.commit", "toto.submit", "quote.request", "contract.offer",
|
||||
"stadium.commit", "advertising.accept", "budget.commit", "ticket.commit", "transfer.submit",
|
||||
"sponsor.answer", "environment.commit", "fixture.reschedule", "contract.cancel", "news.update", "balance.commit", "settings.commit", "manager.join.commit"};
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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_;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
Reference in new issue
Block a user