Bind tactics and training drafts to confirmed engine commits (by Codex)
This commit is contained in:
1 parent
7d3b3f1101
commit
f75e0f8e49
18 files changed
+398
-43
No files matched your search
@@ -1,4 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
namespace {
|
||||
std::string sports_number(const Json &v) { return v.is_number_integer() ? number(v.get<int64_t>()) : "—"; }
|
||||
}
|
||||
std::string App::training_balls(const std::string &group, int index, int value,
|
||||
bool automatic, const std::string &player,
|
||||
int size, int gap, bool overtraining) {
|
||||
@@ -20,8 +23,8 @@ std::string App::training_balls(const std::string &group, int index, int value,
|
||||
return body + "</div>";
|
||||
}
|
||||
std::string App::render_training() {
|
||||
const auto s = snap();
|
||||
const auto &t = s.state.at("training"), &automatic = t.at("autos");
|
||||
const auto t = engine_mode_ ? engine_training_draft_ : snap().state.at("training");
|
||||
const auto &automatic = t.at("autos");
|
||||
const std::array<const char *, 9> skills = {
|
||||
"Kondition", "Technik", "Eckball", "Freistoß", "Zweikampf",
|
||||
"Pass", "Schuss", "Schnelligkeit", "Teamplay"};
|
||||
@@ -43,8 +46,8 @@ std::string App::render_training() {
|
||||
"</span><span style=\"width:35dp;\">:</span><div "
|
||||
"style=\"width:220dp;\">" +
|
||||
training_balls("area", int(i), t["areas"][i].get<int>(),
|
||||
automatic[i < 2 ? 1 : 2].get<bool>(), {}, 56, 10,
|
||||
i >= 2 && skill_total > 14) +
|
||||
!engine_mode_ && automatic[i < 2 ? 1 : 2].get<bool>(), {}, 56, 10,
|
||||
!engine_mode_ && i >= 2 && skill_total > 14) +
|
||||
"</div></div>";
|
||||
body += "</div><div class=\"training-pitch\">";
|
||||
for (int i = 0; i < 10; ++i)
|
||||
@@ -59,7 +62,7 @@ std::string App::render_training() {
|
||||
std::to_string(30 + (i % 2) * 277) +
|
||||
"dp;top:" + std::to_string(26 + (i / 2) * 176) + "dp;\">" +
|
||||
training_balls("type", i, t["types"][size_t(i)].get<int>(),
|
||||
automatic[0].get<bool>(), {}, 48, 5) +
|
||||
!engine_mode_ && automatic[0].get<bool>(), {}, 48, 5) +
|
||||
"</div>";
|
||||
body += "</div>";
|
||||
const std::array<const char *, 4> auto_names = {
|
||||
@@ -78,19 +81,19 @@ std::string App::render_training() {
|
||||
(automatic[i].get<bool>() ? "primary" : ""),
|
||||
"id=\"training-auto-" + std::to_string(i) + "\" data-id=\"" +
|
||||
std::to_string(i) + "\" style=\"position:absolute;" +
|
||||
rect(a[0], a[1], a[2], a[3]) + "\"");
|
||||
rect(a[0], a[1], a[2], a[3]) + "\" " + (engine_mode_ ? "disabled" : ""));
|
||||
}
|
||||
const bool all_auto = std::all_of(automatic.begin(), automatic.end(),
|
||||
const bool all_auto = engine_mode_ ? t.at("master_auto").get<bool>() : std::all_of(automatic.begin(), automatic.end(),
|
||||
[](const auto &v) { return v == true; });
|
||||
body += btn("training-auto-all", "Automatisch",
|
||||
std::string("training-auto ") + (all_auto ? "primary" : ""),
|
||||
"id=\"training-auto-all\" style=\"position:absolute;" +
|
||||
rect(604, 1232, 440, 76) + "\"");
|
||||
rect(604, 1232, 440, 76) + "\" " + (engine_mode_ ? "disabled" : ""));
|
||||
body += "<p class=\"training-budget\">Arten: " + std::to_string(type_total) +
|
||||
" / 8 Bälle ·<br/>Kondition/Technik: " +
|
||||
" / " + std::to_string(engine_mode_ ? t.at("limits").at("types").get<int>() : 8) + " Bälle ·<br/>Kondition/Technik: " +
|
||||
std::to_string(t["areas"][0].get<int>() + t["areas"][1].get<int>()) +
|
||||
" / 4 ·<br/>Fertigkeiten: " + std::to_string(skill_total) + " / 18" +
|
||||
(skill_total > 14 ? " · hohe<br/>Belastung" : "") +
|
||||
" / " + std::to_string(engine_mode_ ? t.at("limits").at("fitnessAndSkill").get<int>() : 4) + " ·<br/>Fertigkeiten: " + std::to_string(skill_total) + " / " + std::to_string(engine_mode_ ? t.at("limits").at("otherAreas").get<int>() : 18) +
|
||||
(!engine_mode_ && skill_total > 14 ? " · hohe<br/>Belastung" : "") +
|
||||
"</p><div id=\"training-roster\" class=\"training-roster\"><div "
|
||||
"class=\"training-row "
|
||||
"training-header\">";
|
||||
@@ -102,7 +105,9 @@ std::string App::render_training() {
|
||||
"\" style=\"width:" + std::to_string(widths[i]) + "dp;\">" +
|
||||
headings[i] + "</div>";
|
||||
body += "</div>";
|
||||
const auto players = world_->squad(t.value("club", ""));
|
||||
std::vector<const Json *> players;
|
||||
if (engine_mode_) { for (const auto &p : t.at("roster")) players.push_back(&p); }
|
||||
else players = world_->squad(t.value("club", ""));
|
||||
for (size_t i = 0; i < players.size(); ++i) {
|
||||
const auto *p = players[i];
|
||||
const auto id = p->value("id", "");
|
||||
@@ -121,30 +126,29 @@ std::string App::render_training() {
|
||||
"class=\"training-name-text\" title=\"" +
|
||||
esc(world_->name(*p)) + "\">" + esc(world_->name(*p)) +
|
||||
"</span></div><div style=\"width:95dp;\">" +
|
||||
std::to_string(
|
||||
p->value("attributes", Json::object()).value("strength", 0)) +
|
||||
sports_number(p->value("attributes", Json::object()).value("strength", Json())) +
|
||||
"</div><div style=\"width:330dp;\">";
|
||||
auto selector =
|
||||
select("training-focus-" + std::to_string(i), focuses,
|
||||
std::to_string(row.value("focus", 0)), "training-focus");
|
||||
const auto end = selector.find('>');
|
||||
selector.insert(end, " data-player=\"" + esc(id) + "\" " +
|
||||
(automatic[3] == true ? "disabled" : ""));
|
||||
(engine_mode_ || automatic[3] == true ? "disabled" : ""));
|
||||
body += selector + "</div><div style=\"width:217dp;\">" +
|
||||
training_balls("player", int(i), row.value("intensity", 0),
|
||||
automatic[3].get<bool>(), id, 50, 9) +
|
||||
!engine_mode_ && automatic[3].get<bool>(), id, 50, 9) +
|
||||
"</div></div>";
|
||||
}
|
||||
return body + "</div>";
|
||||
return body + "</div>" + (engine_mode_ ? engine_sports_footer() : "");
|
||||
}
|
||||
std::string App::render_tactics() {
|
||||
const auto t = snap().state.at("tactics");
|
||||
const std::array<const char *, 8> names = {
|
||||
const auto t = engine_mode_ ? engine_tactics_draft_ : snap().state.at("tactics");
|
||||
const std::array<std::string, 8> names = engine_mode_ ? t.at("labels").get<std::array<std::string, 8>>() : std::array<std::string, 8>{
|
||||
"Defensiv / offensiv", "Pass-/Schussbild unten",
|
||||
"Pass-/Schussbild Mitte", "Pass-/Schussbild links",
|
||||
"Flache / hohe Bälle", "Flügelbild links",
|
||||
"Flügelbild rechts", "Einsatz"};
|
||||
const std::array<int, 8> limits = {3, 3, 3, 3, 1, 1, 1, 11};
|
||||
const std::array<int, 8> limits = engine_mode_ ? t.at("limits").get<std::array<int, 8>>() : std::array<int, 8>{3, 3, 3, 3, 1, 1, 1, 11};
|
||||
const std::array<std::array<int, 4>, 7> areas = {{{19, 9, 104, 62},
|
||||
{61, 108, 50, 34},
|
||||
{63, 84, 54, 30},
|
||||
@@ -154,7 +158,7 @@ std::string App::render_tactics() {
|
||||
{205, 10, 58, 37}}};
|
||||
std::string body =
|
||||
"<div class=\"tactics-board\"><div class=\"tactics-surface\"></div>" +
|
||||
picture(renderer_.diagram("tactics", tactics_diagram(t, theme_, snap().state.value("lineup", Json::object()).value("points", Json()))), 2300,
|
||||
picture(renderer_.diagram("tactics", tactics_diagram(t, theme_, engine_mode_ ? t.at("board").at("points") : snap().state.value("lineup", Json::object()).value("points", Json()), engine_mode_ ? t.at("board").at("depth_max").get<int>() : 18, engine_mode_ ? t.at("board").at("lane_max").get<int>() : 8)), 2300,
|
||||
1864);
|
||||
for (size_t i = 0; i < 7; ++i) {
|
||||
const auto a = areas[i];
|
||||
@@ -173,11 +177,11 @@ std::string App::render_tactics() {
|
||||
"id=\"tactic-effort-value\" class=\"tactic-effort-marks\">" +
|
||||
std::string(size_t(effort), '!') +
|
||||
"</span></div><input type=\"range\" id=\"tactic-effort\" "
|
||||
"data-input=\"tactic-effort\" min=\"0\" max=\"11\" step=\"1\" value=\"" +
|
||||
"data-input=\"tactic-effort\" min=\"" + std::to_string(engine_mode_ ? t.at("minima")[7].get<int>() : 0) + "\" max=\"" + std::to_string(limits[7]) + "\" step=\"1\" value=\"" +
|
||||
std::to_string(effort) +
|
||||
"\"/></div><p id=\"tactic-hint\" class=\"tactic-hint\">" +
|
||||
esc(names[size_t(last_tactic_)]) + ": " +
|
||||
std::to_string(t["values"][size_t(last_tactic_)].get<int>()) + " / " +
|
||||
std::to_string(limits[size_t(last_tactic_)]) + "</p></div>";
|
||||
return body;
|
||||
return body + (engine_mode_ ? engine_sports_footer() : "");
|
||||
}
|
||||
Reference in new issue
Block a user