Line-up and training as pages; the friendlies' opponents as tiles
The line-up of the real game is the squad as a grouped table and the eleven as shirts on a pitch seen from behind the own goal, or the whole squad as shirts. Training keeps the game's own arrangement and pictures in the page's size and inks. The opponents of a friendly are tiles in four columns with both crests. The demo keeps the older line-up sheet. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
9faf0acf81
commit
c7d23185ec
7 files changed
+268
-109
No files matched your search
@@ -22,89 +22,41 @@ std::string App::training_balls(const std::string &group, int index, int value,
|
||||
"dp;\" " + (automatic ? "disabled" : ""));
|
||||
return body + "</div>";
|
||||
}
|
||||
// Training as a page of the notebook, in the game's own arrangement and pictures: the nine
|
||||
// areas with their marks at the left, under them the pitch with the four kinds of session and
|
||||
// the automatic switches; at the right every player with his focus and intensity.
|
||||
std::string App::render_training() {
|
||||
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"};
|
||||
const std::vector<std::pair<std::string, std::string>> focuses = {
|
||||
{"0", "Allgemein"}, {"1", "Eckball"}, {"2", "Freistoß"},
|
||||
{"3", "Zweikampf"}, {"4", "Pass"}, {"5", "Schuss"},
|
||||
{"6", "Schnelligkeit"}, {"7", "Teamplay"}};
|
||||
const std::array<const char *, 9> skills = {"Kondition", "Technik", "Eckball", "Freistoß", "Zweikampf", "Pass", "Schuss", "Schnelligkeit", "Teamplay"};
|
||||
const std::vector<std::pair<std::string, std::string>> focuses = {{"0", "Allgemein"}, {"1", "Eckball"}, {"2", "Freistoß"}, {"3", "Zweikampf"}, {"4", "Pass"}, {"5", "Schuss"}, {"6", "Schnelligkeit"}, {"7", "Teamplay"}};
|
||||
int skill_total = 0, type_total = 0;
|
||||
for (size_t i = 2; i < 9; ++i)
|
||||
skill_total += t["areas"][i].get<int>();
|
||||
for (const auto &v : t["types"])
|
||||
type_total += v.get<int>();
|
||||
std::string body = "<div class=\"training-skills\">";
|
||||
for (size_t i = 2; i < 9; ++i) skill_total += t["areas"][i].get<int>();
|
||||
for (const auto &v : t["types"]) type_total += v.get<int>();
|
||||
// the areas
|
||||
std::string body = "<div class=\"pg-page\"><div class=\"pg-body\"><div class=\"pg-col\" style=\"width:" + pg(470) + ";\"><div class=\"pg-panel pg-col\" style=\"" + pg_css("gap:0px;padding:6px 16px;") + "\">";
|
||||
for (size_t i = 0; i < 9; ++i)
|
||||
body +=
|
||||
"<div class=\"training-skill\"><div style=\"width:86dp;\">" +
|
||||
img("training.skill." + std::to_string(i), 80, 80, false, false, 160) +
|
||||
"</div><span style=\"width:677dp;\">" + skills[i] +
|
||||
"</span><span style=\"width:35dp;\">:</span><div "
|
||||
"style=\"width:220dp;\">" +
|
||||
training_balls("area", int(i), t["areas"][i].get<int>(),
|
||||
!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)
|
||||
body += "<div style=\"position:absolute;left:0;right:0;top:" +
|
||||
std::to_string(i * 43) + "dp;height:43dp;background-color:" +
|
||||
std::string(i % 2 ? "#306b4c" : "#2d6447") + ";\"></div>";
|
||||
body += "<div class=\"training-midline\"></div><div "
|
||||
"class=\"training-circle\"></div><div class=\"training-box "
|
||||
"left-box\"></div><div class=\"training-box right-box\"></div>";
|
||||
body += "<div class=\"tr-skill\">" + img("training.skill." + std::to_string(i), 72, 72, false, false, 160) + "<span class=\"pg-grow\" style=\"display:block;font-weight:bold;\">" + skills[i] + "</span>" +
|
||||
training_balls("area", int(i), t["areas"][i].get<int>(), !engine_mode_ && automatic[i < 2 ? 1 : 2].get<bool>(), {}, 54, 10, !engine_mode_ && i >= 2 && skill_total > 14) + "</div>";
|
||||
// the pitch with the four kinds of session, the budget and the switches beside it
|
||||
body += "</div><div class=\"pg-row pg-grow\" style=\"" + pg_css("gap:12px;") + "align-items:stretch;\"><div class=\"tr-pitch\">";
|
||||
for (int i = 0; i < 10; ++i) body += "<div class=\"tr-stripe\" style=\"left:" + std::to_string(i * 54) + "dp;background-color:" + std::string(i % 2 ? "#b6cf97" : "#a9c489") + ";\"></div>";
|
||||
body += "<div class=\"tr-line mid\"></div><div class=\"tr-line circle\"></div><div class=\"tr-line box left\"></div><div class=\"tr-line box right\"></div>";
|
||||
for (int i = 0; i < 4; ++i)
|
||||
body += "<div class=\"training-type-cell\" style=\"left:" +
|
||||
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>(),
|
||||
!engine_mode_ && automatic[0].get<bool>(), {}, 48, 5) +
|
||||
"</div>";
|
||||
body += "</div>";
|
||||
const std::array<const char *, 4> auto_names = {
|
||||
"AUTO · Arten", "AUTO · Kondition", "AUTO · Fertigkeiten",
|
||||
"AUTO · Spieler"};
|
||||
const std::array<std::array<int, 4>, 4> auto_boxes = {
|
||||
{{0, 1456, 570, 76},
|
||||
{604, 1040, 440, 76},
|
||||
{604, 1136, 440, 76},
|
||||
{2312, 1803, 300, 61}}};
|
||||
for (size_t i = 0; i < 4; ++i) {
|
||||
const auto a = auto_boxes[i];
|
||||
body += btn(
|
||||
"training-auto", auto_names[i],
|
||||
std::string(i == 3 ? "training-auto auto-players " : "training-auto ") +
|
||||
(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]) + "\" " + (engine_mode_ ? "disabled" : ""));
|
||||
}
|
||||
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) + "\" " + (engine_mode_ ? "disabled" : ""));
|
||||
body += "<p class=\"training-budget\">Arten: " + std::to_string(type_total) +
|
||||
" / " + 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>()) +
|
||||
" / " + 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\">";
|
||||
const std::array<const char *, 5> headings = {"Pos.", "Spieler", "Stärke",
|
||||
"Schwerpunkt", "Intensität"};
|
||||
const std::array<int, 5> widths = {90, 760, 95, 330, 217};
|
||||
for (size_t i = 0; i < 5; ++i)
|
||||
body += "<div class=\"" + std::string(i == 1 ? "training-player-heading" : "") +
|
||||
"\" style=\"width:" + std::to_string(widths[i]) + "dp;\">" +
|
||||
headings[i] + "</div>";
|
||||
body += "</div>";
|
||||
body += "<div class=\"tr-type\" style=\"left:" + std::to_string(26 + (i % 2) * 270) + "dp;top:" + std::to_string(70 + (i / 2) * 170) + "dp;\">" +
|
||||
training_balls("type", i, t["types"][size_t(i)].get<int>(), !engine_mode_ && automatic[0].get<bool>(), {}, 52, 6) + "</div>";
|
||||
body += "</div><div class=\"pg-col pg-grow\" style=\"" + pg_css("gap:6px;") + "\"><div class=\"pg-panel\" style=\"" + pg_css("padding:8px 12px;") + "\">" + pg_kicker("Ballbudget") +
|
||||
"<div class=\"pg-kv\"><span>Arten</span><strong>" + std::to_string(type_total) + " / " + std::to_string(engine_mode_ ? t.at("limits").at("types").get<int>() : 8) + "</strong></div><div class=\"pg-kv\"><span>Kondition/Technik</span><strong>" +
|
||||
std::to_string(t["areas"][0].get<int>() + t["areas"][1].get<int>()) + " / " + std::to_string(engine_mode_ ? t.at("limits").at("fitnessAndSkill").get<int>() : 4) + "</strong></div><div class=\"pg-kv\"><span>Fertigkeiten</span><strong>" +
|
||||
std::to_string(skill_total) + " / " + std::to_string(engine_mode_ ? t.at("limits").at("otherAreas").get<int>() : 18) + (!engine_mode_ && skill_total > 14 ? " · hohe Belastung" : "") + "</strong></div></div>";
|
||||
const std::array<const char *, 4> auto_names = {"AUTO · Arten", "AUTO · Kondition", "AUTO · Fertigkeiten", "AUTO · Spieler"};
|
||||
for (size_t i = 0; i < 4; ++i)
|
||||
body += pg_button("training-auto", auto_names[i], std::string("block tr-auto ") + (automatic[i].get<bool>() ? "on" : ""), "id=\"training-auto-" + std::to_string(i) + "\" data-id=\"" + std::to_string(i) + "\" " + (engine_mode_ ? "disabled" : ""));
|
||||
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 += pg_button("training-auto-all", "Automatisch", std::string("block tr-auto ") + (all_auto ? "on" : ""), "id=\"training-auto-all\" " + std::string(engine_mode_ ? "disabled" : "")) + "</div></div></div>";
|
||||
// the players
|
||||
body += "<div class=\"pg-panel pg-col pg-grow\" style=\"" + pg_css("gap:0px;padding:4px 12px;") + "\"><div class=\"pg-t\" role=\"table\"><div class=\"pg-thead\">" + pg_th("Pos.", 56) + pg_th("Spieler", 0) + pg_th("Stärke", 70, "r") + pg_th("Schwerpunkt", 170) +
|
||||
pg_th("Intensität", 100) + "</div><div id=\"training-roster\" class=\"pg-tbody\">";
|
||||
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", ""));
|
||||
@@ -113,31 +65,15 @@ std::string App::render_training() {
|
||||
const auto id = p->value("id", "");
|
||||
const auto &row = t["players"].at(id);
|
||||
const auto position = p->value("positions", Json::array());
|
||||
const auto pos = position.empty() ? "" : position[0].get<std::string>();
|
||||
body +=
|
||||
"<div class=\"training-row " + std::string(i % 2 ? "striped" : "") +
|
||||
"\"><div class=\"training-position\" style=\"width:90dp;\">" +
|
||||
std::string(pos == "gk" ? "TW"
|
||||
: pos == "def" ? "ABW"
|
||||
: pos == "mid" ? "MIT"
|
||||
: pos == "fwd" ? "STU"
|
||||
: pos) +
|
||||
"</div><div class=\"training-name\" style=\"width:760dp;\"><span "
|
||||
"class=\"training-name-text\" title=\"" +
|
||||
esc(world_->name(*p)) + "\">" + esc(world_->name(*p)) +
|
||||
"</span></div><div style=\"width:95dp;\">" +
|
||||
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) + "\" " +
|
||||
(engine_mode_ || automatic[3] == true ? "disabled" : ""));
|
||||
body += selector + "</div><div style=\"width:217dp;\">" +
|
||||
training_balls("player", int(i), row.value("intensity", 0),
|
||||
!engine_mode_ && automatic[3].get<bool>(), id, 50, 9) +
|
||||
"</div></div>";
|
||||
const auto pos = position.empty() ? std::string() : position[0].get<std::string>();
|
||||
auto selector = select("training-focus-" + std::to_string(i), focuses, std::to_string(row.value("focus", 0)), "training-focus");
|
||||
selector.insert(selector.find('>'), " data-player=\"" + esc(id) + "\" " + (engine_mode_ || automatic[3] == true ? "disabled" : ""));
|
||||
body += "<div class=\"pg-tr tr-player\">" + pg_td(pg_pos(pos == "gk" ? "TW" : pos == "def" ? "ABW" : pos == "mid" ? "MIT" : pos == "fwd" ? "STU" : pos), 56, "", true) +
|
||||
pg_td("<strong title=\"" + esc(world_->name(*p)) + "\">" + esc(world_->name(*p)) + "</strong>", 0) + pg_td("<strong>" + sports_number(p->value("attributes", Json::object()).value("strength", Json())) + "</strong>", 70, "r") +
|
||||
pg_td(selector, 170, "", true) + pg_td(training_balls("player", int(i), row.value("intensity", 0), !engine_mode_ && automatic[3].get<bool>(), id, 50, 8), 100, "", true) + "</div>";
|
||||
}
|
||||
return body + "</div>" + (engine_mode_ ? engine_sports_footer() : "");
|
||||
body += "</div></div></div></div><nav class=\"pg-foot\">";
|
||||
if (engine_mode_) body += pg_button("sports-reset", "Zurücksetzen", "", "id=\"sports-reset\"") + pg_button("sports-apply", "Anwenden", "primary", "id=\"sports-apply\"") + "<span class=\"pg-sp\"></span><span id=\"sports-note\" class=\"pg-status\"></span>";
|
||||
else body += "<span class=\"pg-sp\"></span>" + pg_status("Jede Änderung gilt sofort.");
|
||||
return body + "</nav></div>";
|
||||
}
|
||||
Reference in new issue
Block a user