The four instructions of a starter can be set in the line-up
The read lineup states the instructions of every starter (board bytes +2..+5) and lineup.setOrder sets one through set_player_order_source. Anweis. in the line-up shows them for the chosen starter with the original's four arrows; each is moved in steps of 1 or 5. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
3330dfb69c
commit
a2790751a6
8 files changed
+101
-8
No files matched your search
@@ -1054,3 +1054,9 @@ body.midnight .cp-map-name,body.matchday .cp-map-name {color:#f0ece2;font-effect
|
||||
.po-text {display:block;flex:1;min-width:0;}
|
||||
.po-text strong {display:block;font-size:32dp;line-height:40dp;}
|
||||
.po-text span {display:block;font-size:27dp;line-height:36dp;}
|
||||
/* line-up: the four instructions of a starter */
|
||||
.lp-order {flex:none;gap:14dp;height:70dp;}
|
||||
.lp-order-icon {display:block;flex:none;width:50dp;height:50dp;}
|
||||
.lp-order .pg-bar {flex:1;}
|
||||
.lp-order-value {display:block;flex:none;width:60dp;text-align:center;font-family:Display;font-weight:normal;font-size:38dp;line-height:46dp;}
|
||||
.pg-root .pg-btn.lp-step {flex:none;width:58dp;height:58dp;padding:0;font-size:30dp;}
|
||||
@@ -106,6 +106,7 @@ Die UI ruft diese über `DataSource::read_almanac` und `read_statistics` direkt
|
||||
| `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) |
|
||||
| `session.advance` (Zusatz) | `transferOffers {playerId: {accept: 0–3} \| {action: "decline"}}` | die Antwort des Verkäufers auf die Gebote für einen Spieler, den er auf die Transferliste gesetzt hat (Stichtag der Woche). Gefragt wird nur, wer das Feld sendet (auch leer); ohne das Feld läuft der Anstoß wie bisher und alle Gebote an menschliche Verkäufer verfallen. Ohne Antwort wird der Lauf zurückgenommen und `decision_pending` mit `args {decision: "transfer_offers", playerId, name, sellerManagerId, askingFee, offers [{index, teamId, fee, monthlySalary, months, loan, eligible}]}` gemeldet; die Oberfläche fragt und sendet den Anstoß erneut |
|
||||
| `lineup.setOrder` | `playerId`, `aspect` 0–3, `value` 2–40 | eine der vier Anweisungen eines aufgestellten Spielers (die vier Pfeile der Originalansicht; der Read `lineup` nennt sie je Feldspieler unter `positions[].orders`); Fehler `invalid_payload`, `unknown_player`, `lineup_refused` |
|
||||
| `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 |
|
||||
|
||||
@@ -9240,8 +9240,11 @@ cli::Json ModernSession::ui_read(const cli::Json& request, uint64_t revision) co
|
||||
const size_t at = size_t(manager) * 0x840 + row * 0x58;
|
||||
if (row < 11 && at + 0x43 <= g_.tactics.size()) {
|
||||
const int partner = partner_of(row);
|
||||
// "orders": the four instructions of a starter (board bytes +2..+5, each 2-40), which
|
||||
// the original's ORDER view sets with its four arrows
|
||||
positions.push_back(O{{"playerId", id}, {"depth", int(int8_t(g_.tactics[at + 0x41]))},
|
||||
{"lane", int(int8_t(g_.tactics[at + 0x42]))},
|
||||
{"orders", A{int(g_.tactics[at + 2]), int(g_.tactics[at + 3]), int(g_.tactics[at + 4]), int(g_.tactics[at + 5])}},
|
||||
{"partnerId", partner >= 0 ? cli::Json(row_ids[size_t(partner)]) : cli::Json(nullptr)}});
|
||||
}
|
||||
}
|
||||
@@ -11032,6 +11035,28 @@ 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.setOrder") {
|
||||
// payload {playerId, aspect 0-3, value 2-40}: one instruction of a starter (set_player_order_source)
|
||||
const int team = g_.manager_teams[size_t(manager)];
|
||||
const SquadRange range = squad_range(team);
|
||||
const std::string id = ui_text(*payload, "playerId");
|
||||
const cli::Json* aspect = ui_field(*payload, "aspect");
|
||||
const cli::Json* value = ui_field(*payload, "value");
|
||||
if (id.empty() || !aspect || !aspect->integer() || *aspect->integer() < 0 || *aspect->integer() > 3 || !value || !value->integer() ||
|
||||
*value->integer() < kOrderMin || *value->integer() > kOrderMax)
|
||||
return refuse("invalid_payload", "playerId, aspect 0-3 und value 2-40 nötig.");
|
||||
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) return refuse("unknown_player", "Dieser Spieler gehört nicht zum Kader.");
|
||||
if (!set_player_order_source(g_, manager, team, int(at), g_.squad_slots[range.first + at] & 0x0fff, int(*aspect->integer()), int(*value->integer()))) {
|
||||
restore();
|
||||
return refuse("lineup_refused", "Anweisungen bekommt nur, wer aufgestellt ist.");
|
||||
}
|
||||
revision = previous + 1;
|
||||
answer = modern::ui_command_result(request_id, previous, revision, {"lineup"}, "Anweisung ü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)
|
||||
|
||||
@@ -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", "lineup.setPiece", "tactics.commit", "friendly.book", "manager.resign.commit",
|
||||
"session.advance", "lineup.commit", "lineup.setPiece", "lineup.setOrder", "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_order_command(const Json &bundle, const std::string &player, int aspect, int value, 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);
|
||||
|
||||
@@ -131,7 +131,14 @@ Json engine_lineup_projection(const Json &bundle) {
|
||||
const auto depth_max = lineup.at("depthMax").get<int>(), lane_max = lineup.at("laneMax").get<int>();
|
||||
require(depth_max > 0 && lane_max > 0, "Ungültige Spielfeldkoordinaten.");
|
||||
const auto surface = lineup_surface_context(lineup, positions);
|
||||
Json rows = Json::array(), points = Json::array(); std::set<std::string> ids;
|
||||
Json rows = Json::array(), points = Json::array(), orders = Json::object(); std::set<std::string> ids;
|
||||
// the four instructions of every starter, where the backend states them
|
||||
for (const auto &[id, point] : positions)
|
||||
if (point.contains("orders") && point.at("orders").is_array() && point.at("orders").size() == 4) {
|
||||
Json four = Json::array();
|
||||
for (const auto &value : point.at("orders")) { require(value.is_number_integer() && value.get<int>() >= 0 && value.get<int>() <= 255, "Ungültige Anweisung."); four.push_back(value.get<int>()); }
|
||||
orders[id] = four;
|
||||
}
|
||||
for (const auto &value : lineup.at("order")) {
|
||||
const auto id = value.get<std::string>();
|
||||
require(members.contains(id) && roles.contains(id) && ids.insert(id).second, "Aufstellung enthält fremde oder doppelte Spieler.");
|
||||
@@ -173,11 +180,16 @@ Json engine_lineup_projection(const Json &bundle) {
|
||||
set_pieces[key] = taker;
|
||||
}
|
||||
}
|
||||
return {{"ok", true}, {"rows", rows}, {"field_count", points.size()}, {"set_pieces", set_pieces},
|
||||
return {{"ok", true}, {"rows", rows}, {"field_count", points.size()}, {"set_pieces", set_pieces}, {"orders", orders},
|
||||
{"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_order_command(const Json &bundle, const std::string &player, int aspect, int value, const std::string &request_id) {
|
||||
const auto projection = engine_lineup_projection(bundle);
|
||||
require(projection.at("orders").contains(player) && aspect >= 0 && aspect <= 3 && value >= 2 && value <= 40, "Ungültige Anweisung.");
|
||||
return sports_command(bundle, "lineup.setOrder", {{"playerId", player}, {"aspect", aspect}, {"value", value}}, request_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.");
|
||||
|
||||
@@ -67,8 +67,8 @@ bool App::engine_lineup_action(const std::string &action, const std::string &id,
|
||||
}
|
||||
// "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;
|
||||
lineup_side_ = (id == "takers" || id == "orders") && lineup_side_ != id ? id : "formations";
|
||||
lineup_selected_.clear(); focus_after_render_ = "lineup-side-" + id; refresh(); return true;
|
||||
}
|
||||
if (action == "lineup-piece") {
|
||||
if (id == "freeKick" || id == "penalty" || id == "corner") lineup_piece_ = id;
|
||||
@@ -87,8 +87,31 @@ bool App::engine_lineup_action(const std::string &action, const std::string &id,
|
||||
} catch (const std::exception &e) { message(e.what()); }
|
||||
};
|
||||
if (action == "lineup-piece-auto") { send_takers({{"auto", true}}, "lineup-piece-auto"); return true; }
|
||||
// "Anweis.": the four instructions of the chosen starter, each moved by a step
|
||||
if (action == "lineup-order") {
|
||||
if (!engine_fresh_ || engine_busy_ || lineup_selected_.empty() || !target) return true;
|
||||
try {
|
||||
const auto orders = engine_lineup_projection(engine_data_).at("orders");
|
||||
const int aspect = target->GetAttribute<int>("data-id", -1), step = target->GetAttribute<int>("data-step", 0);
|
||||
if (!orders.contains(lineup_selected_) || aspect < 0 || aspect > 3 || !step) return true;
|
||||
const int value = std::clamp(orders.at(lineup_selected_)[size_t(aspect)].get<int>() + step, 2, 40);
|
||||
const auto command = engine_order_command(engine_data_, lineup_selected_, aspect, value, editor::new_id("request:ui-"));
|
||||
focus_after_render_ = target->GetId();
|
||||
auto link = engine_link_;
|
||||
engine_start("Anweisung wird übernommen …", [link, command] {
|
||||
auto response = link->command(command);
|
||||
return EngineReply{link, link->snapshot(), response, nullptr};
|
||||
}, true);
|
||||
} catch (const std::exception &e) { message(e.what()); }
|
||||
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_ == "orders") {
|
||||
// a click chooses whose instructions are shown; nobody is swapped here
|
||||
lineup_selected_ = lineup_selected_ == id ? "" : id;
|
||||
focus_after_render_ = target->GetId(); refresh(); return true;
|
||||
}
|
||||
if (action == "lineup-player" && lineup_side_ == "takers" && projection.at("set_pieces").is_object()) {
|
||||
send_takers({{"piece", lineup_piece_}, {"playerId", id}}, target->GetId());
|
||||
return true;
|
||||
|
||||
@@ -128,7 +128,31 @@ std::string App::render_lineup_page() {
|
||||
out += "</div>";
|
||||
}
|
||||
const bool takers = lineup_side_ == "takers" && projection.at("set_pieces").is_object();
|
||||
if (takers) {
|
||||
const bool ordering = lineup_side_ == "orders" && projection.at("orders").is_object() && !projection.at("orders").empty();
|
||||
if (ordering) {
|
||||
// the four instructions of the chosen starter: how far he goes forward and back, how wide he plays, how much he covers
|
||||
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\">Anweisungen</strong><span class=\"pg-mut\">";
|
||||
std::string who;
|
||||
for (const auto &row : rows) if (row.at("id") == lineup_selected_) who = row.at("name").get<std::string>();
|
||||
const bool starter = !lineup_selected_.empty() && projection.at("orders").contains(lineup_selected_);
|
||||
out += esc(starter ? who : lineup_selected_.empty() ? std::string("Einen Feldspieler anklicken.") : who + " ist nicht aufgestellt.") + "</span></div>";
|
||||
if (starter) {
|
||||
static constexpr std::array<const char *, 4> paths{"M8 34L34 8M14 8H34V28", "M8 34L34 8M8 14V34H28", "M4 22H40M13 13L4 22L13 31M31 13L40 22L31 31", "M22 4V40M13 13L22 4L31 13M13 31L22 40L31 31"};
|
||||
static constexpr std::array<const char *, 4> spoken{"nach vorn", "nach hinten", "in die Breite", "in die Tiefe"};
|
||||
const std::string ink = theme_ == "silver" ? "#8c491a" : theme_ == "matchday" ? "#2f602c" : "#ebb87f";
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
const int value = projection.at("orders").at(lineup_selected_)[size_t(i)].get<int>();
|
||||
const auto step = [&](int by, const char *label) {
|
||||
return pg_button("lineup-order", label, "round lp-step", attr("id", "lineup-order-" + std::to_string(i) + (by < 0 ? "-less" : "-more") + (std::abs(by) > 1 ? "-far" : "")) + attr("data-id", std::to_string(i)) + attr("data-step", std::to_string(by)) +
|
||||
attr("aria-label", std::string("Anweisung ") + spoken[size_t(i)] + (by < 0 ? " verringern" : " erhöhen")) + ((by < 0 && value <= 2) || (by > 0 && value >= 40) ? " disabled=\"disabled\"" : ""));
|
||||
};
|
||||
out += "<div class=\"pg-row lp-order\"><span class=\"lp-order-icon\" title=\"" + std::string(spoken[size_t(i)]) + "\">" +
|
||||
picture(renderer_.diagram("lineup-order-" + std::to_string(i) + "-" + theme_, "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 44 44\"><path d=\"" + std::string(paths[size_t(i)]) + "\" fill=\"none\" stroke=\"" + ink + "\" stroke-width=\"3\"/></svg>", 96), 50, 50) +
|
||||
"</span>" + step(-5, "«") + step(-1, "−") + pg_bar((value - 2) * 100.0 / 38, i < 2 ? "accent" : "sage") + "<strong class=\"lp-order-value\">" + std::to_string(value) + "</strong>" + step(1, "+") + step(5, "»") + "</div>";
|
||||
}
|
||||
}
|
||||
out += "</div></div></div>";
|
||||
} else 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;") + "\">";
|
||||
@@ -173,11 +197,12 @@ std::string App::render_lineup_page() {
|
||||
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 (ordering && !engine_busy_) status = lineup_selected_.empty() ? "Anweisungen: einen Feldspieler anklicken." : "Anweisungen in Schritten von 1 oder 5 ändern.";
|
||||
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(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 += btn("lineup-side", "<span>" + std::string(label) + "</span>", std::string(std::string(side) == "formations" ? "first" : "") + ((std::string(side) == "takers" && takers) || (std::string(side) == "orders" && ordering) ? " on" : ""),
|
||||
attr("id", "lineup-side-" + std::string(side)) + attr("data-id", side) + ((std::string(side) == "takers" && projection.at("set_pieces").is_object()) || (std::string(side) == "orders" && projection.at("orders").is_object() && !projection.at("orders").empty()) ? attr("aria-pressed", (std::string(side) == "takers" ? takers : ordering) ? "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