Bind squad and lineup views to confirmed engine player swaps (by Codex)
This commit is contained in:
1 parent
94dc5ecbc4
commit
7d3b3f1101
15 files changed
+340
-36
No files matched your search
@@ -151,18 +151,19 @@ std::string lineup_zone(const Json &l, const std::string &id) {
|
||||
} // namespace
|
||||
|
||||
std::string App::render_lineup() {
|
||||
const auto s = snap();
|
||||
const auto s = engine_mode_ ? Snapshot{0, world_, Json()} : snap();
|
||||
if (!s.world)
|
||||
return "<p class=\"lineup-empty\">Die Aufstellung ist derzeit nicht "
|
||||
"verfügbar.</p>";
|
||||
const auto projection =
|
||||
demo_lineup_rows(s.state, *s.world, lineup_managed(s));
|
||||
engine_mode_ ? engine_lineup_projection(engine_data_) : demo_lineup_rows(s.state, *s.world, lineup_managed(s));
|
||||
if (!projection.value("ok", false))
|
||||
return "<p class=\"lineup-empty\">Die Aufstellung ist derzeit nicht "
|
||||
"verfügbar.</p>";
|
||||
const auto &l = demo_lineup_visible(s.state), &rows = projection.at("rows");
|
||||
const int field_count = demo_career_field_count(s.state);
|
||||
const bool indoor = field_count == 6;
|
||||
const auto &l = engine_mode_ ? projection.at("board") : demo_lineup_visible(s.state);
|
||||
const auto &rows = projection.at("rows");
|
||||
const int field_count = engine_mode_ ? projection.at("field_count").get<int>() : demo_career_field_count(s.state);
|
||||
const bool indoor = !engine_mode_ && field_count == 6;
|
||||
if (lineup_slot(l, lineup_selected_) < 0)
|
||||
lineup_selected_.clear();
|
||||
lineup_data_ = lineup_data_ == 1 ? 1 : 0;
|
||||
@@ -217,7 +218,7 @@ std::string App::render_lineup() {
|
||||
lineup_value(row.at("technique")),
|
||||
lineup_value(row.at("form")),
|
||||
lineup_value(row.at("strength")),
|
||||
lineup_status(size_t(slot), indoor),
|
||||
engine_mode_ ? row.at("status").get<std::string>() : lineup_status(size_t(slot), indoor),
|
||||
row.at("nation").is_string()
|
||||
? row.at("nation").get<std::string>()
|
||||
: "—",
|
||||
@@ -296,23 +297,23 @@ std::string App::render_lineup() {
|
||||
"aria-label=\"Spielfeldvariante\">" +
|
||||
btn("lineup-surface", "Rasen · 11", indoor ? "" : "selected",
|
||||
"id=\"lineup-surface-outdoor\" data-id=\"outdoor\" aria-pressed=\"" +
|
||||
(indoor ? std::string("false") : "true") + "\"") +
|
||||
(indoor ? std::string("false") : "true") + "\" " + (engine_mode_ ? "disabled" : "")) +
|
||||
btn("lineup-surface", "Halle · 6", indoor ? "selected" : "",
|
||||
"id=\"lineup-surface-indoor\" data-id=\"indoor\" aria-pressed=\"" +
|
||||
(indoor ? std::string("true") : "false") + "\" " +
|
||||
(s.state.at("career").value("role", "club") == "national"
|
||||
(engine_mode_ || s.state.at("career").value("role", "club") == "national"
|
||||
? "disabled"
|
||||
: "")) +
|
||||
"</nav>";
|
||||
if (lineup_pitch_) {
|
||||
out += "<div id=\"lineup-pitch\" class=\"lineup-pitch\" role=\"group\" "
|
||||
"aria-label=\"Spielfeld, Spieler auswählen oder ziehen\"><div "
|
||||
"aria-label=\"" + std::string(engine_mode_ ? "Spielfeld, Spieler auswählen" : "Spielfeld, Spieler auswählen oder ziehen") + "\"><div "
|
||||
"class=\"lineup-field-art\">" +
|
||||
picture(renderer_.diagram("lineup-field", lineup_field(indoor),
|
||||
lineup_pitch_raster_px),
|
||||
lineup_art_width_dp, lineup_art_height_dp) +
|
||||
"</div>";
|
||||
if (lineup_side_ == "orders" && !lineup_selected_.empty()) {
|
||||
if (!engine_mode_ && lineup_side_ == "orders" && !lineup_selected_.empty()) {
|
||||
const auto zone = lineup_zone(l, lineup_selected_);
|
||||
if (!zone.empty())
|
||||
out += "<div id=\"lineup-zone\" class=\"lineup-order-zone\">" +
|
||||
@@ -323,12 +324,13 @@ std::string App::render_lineup() {
|
||||
}
|
||||
for (size_t i = 0; i < std::min(size_t(field_count), rows.size()); ++i) {
|
||||
const auto &row = rows[i], &point = l.at("points")[i];
|
||||
if (point.is_null()) continue;
|
||||
const bool selected = lineup_selected_ == row.at("id").get<std::string>();
|
||||
const auto x =
|
||||
(8 + point[0].get<int>() / 18.0 * 84) * lineup_art_width_dp / 100.0 -
|
||||
(8 + point[0].get<int>() / double(l.value("depth_max", 18)) * 84) * lineup_art_width_dp / 100.0 -
|
||||
lineup_player_anchor_x_dp;
|
||||
const auto y =
|
||||
(10 + point[1].get<int>() / 8.0 * 80) * lineup_art_height_dp / 100.0 -
|
||||
(10 + point[1].get<int>() / double(l.value("lane_max", 8)) * 80) * lineup_art_height_dp / 100.0 -
|
||||
lineup_player_anchor_y_dp;
|
||||
out +=
|
||||
btn("lineup-player",
|
||||
@@ -356,9 +358,10 @@ std::string App::render_lineup() {
|
||||
"lineup-side", label, "lineup-tab",
|
||||
attr("id", "lineup-side-" + std::string(side)) +
|
||||
attr("data-id", side) +
|
||||
attr("aria-pressed", lineup_side_ == side ? "true" : "false"));
|
||||
attr("aria-pressed", lineup_side_ == side ? "true" : "false") + (engine_mode_ ? " disabled" : ""));
|
||||
out += "</nav><div class=\"lineup-side\" id=\"lineup-side\">";
|
||||
if (lineup_side_ == "formations") {
|
||||
if (engine_mode_) out += engine_lineup_controls();
|
||||
else if (lineup_side_ == "formations") {
|
||||
for (int slot = 0; slot < 4; ++slot) {
|
||||
const int i = slot + lineup_page_ * 4;
|
||||
const auto point = i < 4 ? demo_lineup_formations(indoor)[size_t(i)]
|
||||
@@ -534,11 +537,11 @@ std::string App::render_lineup() {
|
||||
}
|
||||
out += "</div></aside>";
|
||||
} else {
|
||||
const auto bench = std::min(indoor ? size_t(5) : lineup_bench_limit,
|
||||
const auto bench = engine_mode_ ? size_t(std::count_if(rows.begin(), rows.end(), [](const auto &r) { return r.at("role") == "bench"; })) : std::min(indoor ? size_t(5) : lineup_bench_limit,
|
||||
rows.size() > size_t(field_count)
|
||||
? rows.size() - size_t(field_count)
|
||||
: 0);
|
||||
const auto reserves = rows.size() > size_t(field_count) + bench
|
||||
const auto reserves = engine_mode_ ? size_t(std::count_if(rows.begin(), rows.end(), [](const auto &r) { return r.at("role") == "reserve"; })) : rows.size() > size_t(field_count) + bench
|
||||
? rows.size() - size_t(field_count) - bench
|
||||
: 0;
|
||||
out += "<footer class=\"lineup-team-actions\">" + data_btn() + view_btn() +
|
||||
@@ -549,5 +552,5 @@ std::string App::render_lineup() {
|
||||
std::to_string(reserves) + " Reserve</span></footer>";
|
||||
}
|
||||
out += "</div>";
|
||||
return out + render_report_detail();
|
||||
return out + (engine_mode_ ? engine_player_profile(projection) : render_report_detail());
|
||||
}
|
||||
Reference in new issue
Block a user