From 11264ccdb5731444620df07ca8e4a325bd4f0ef6 Mon Sep 17 00:00:00 2001 From: Weyoune Date: Mon, 16 Nov 2026 13:41:30 +0100 Subject: [PATCH] What the game already states is shown: planned income, both clubs of a report, photos in the line-up, an opponent's place Bilanz > Zukunft shows the expected income and the result of the plan beside the planned costs. A match report in the inbox carries the crests of both clubs. The line-up's rows begin with the player's photo. The stadium's curves name their lowest, highest and latest figure. The friendly plan states the place in the table and the games played of every league club, and the opponent's tile shows them. Co-Authored-By: Claude Fable 5.2 --- assets/modern/pages.rcss | 10 ++++++++++ src/modern/content/ui_contract.cpp | 22 +++++++++++++++++++++- src/modern/ui/engine_balance.cpp | 1 + src/modern/ui/engine_dto.cpp | 3 ++- src/modern/ui/finance_screens.inc | 14 ++++++++++++-- src/modern/ui/lineup_page.inc | 3 ++- src/modern/ui/news_screens.inc | 8 ++++++++ src/modern/ui/planning_page.inc | 2 +- src/modern/ui/stadium_screens.inc | 11 ++++++++++- 9 files changed, 67 insertions(+), 7 deletions(-) diff --git a/assets/modern/pages.rcss b/assets/modern/pages.rcss index dd597f1..4ebec59 100644 --- a/assets/modern/pages.rcss +++ b/assets/modern/pages.rcss @@ -1034,3 +1034,13 @@ body.midnight .cp-map-name,body.matchday .cp-map-name {color:#f0ece2;font-effect /* bank > players: a fellow manager as the lender */ .pg-card.bk-lender,.pg-card.bk-lender:hover {flex:none;flex-direction:row;align-items:center;gap:27dp;width:100%;padding:18dp 27dp;border-radius:36dp;} .bk-lender strong,.bk-lender span {display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;} + +/* inbox: the two clubs of a match report */ +.news-art-pair {display:flex;align-items:center;justify-content:center;gap:4dp;} +/* stadium data: what the curves measure */ +.sd-axis {display:flex;flex:none;flex-wrap:wrap;gap:4dp 36dp;font-size:26dp;line-height:36dp;} +.sd-axis>.pg-mut {display:block;width:100%;} +.sd-axis-item {display:flex;align-items:center;gap:11dp;} +.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);} diff --git a/src/modern/content/ui_contract.cpp b/src/modern/content/ui_contract.cpp index f33ed87..f207e36 100644 --- a/src/modern/content/ui_contract.cpp +++ b/src/modern/content/ui_contract.cpp @@ -613,13 +613,33 @@ cli::Json ui_read(const ModernState& g, const UiContext& c, const cli::Json& req !g.memory.has(layout::FriendlyTeams + entries * 4 - 1)) return failure(request_id, "friendly_plan_unavailable", "Der Spielplan ist unvollständig.", c.state_revision); A opponents, bookings; + // a club of the leagues comes with its place in the table and the games it has played + std::map>> standings; + const auto standing = [&](int t) -> std::pair { + const int league = team_league(t); + if (t >= league_clubs() || league < 0 || size_t(league) >= std::size(kLeagueSizes)) return {0, -1}; + auto found = standings.find(league); + if (found == standings.end()) { + const int count = kLeagueSizes[league], played = size_t(league) < g.league_rounds.size() ? g.league_rounds[size_t(league)] : 0; + auto table = compute_league_table(g, league, 0, played, 7, 1); + bool any = false; for (int i = 0; i < count; ++i) any |= table.games(i) > 0; + if (!any) sort_table(table, 0); + std::vector> rows; + for (int i = 0; i < count; ++i) rows.emplace_back(table.rank(i) + 1, table.games(i)); + found = standings.emplace(league, std::move(rows)).first; + } + const int index = t - league_first_team(league); + return index >= 0 && size_t(index) < found->second.size() ? found->second[size_t(index)] : std::pair{0, -1}; + }; for (int t = national ? no_team() + 1 : 0; t < (national ? world_layout().total_teams() : first_foreign_cup()); ++t) { if (t == own) continue; const int league = team_league(t); const std::string league_id = league >= 0 && size_t(league) < g.world_league_id.size() ? g.world_league_id[size_t(league)] : std::string{}; opponents.push_back(O{{"team", team_ref(g, t, today)}, {"competitionId", league_id.empty() ? J(nullptr) : J(league_id)}, - {"strength", t < league_clubs() ? J(team_average(g, t, 0xff).value) : J(nullptr)}}); + {"strength", t < league_clubs() ? J(team_average(g, t, 0xff).value) : J(nullptr)}, + {"rank", standing(t).second >= 0 ? J(standing(t).first) : J(nullptr)}, + {"played", standing(t).second >= 0 ? J(standing(t).second) : J(nullptr)}}); } for (uint32_t i = 0; i < entries; ++i) { const int day = g.memory.u16(layout::FriendlyDays + i * 2); diff --git a/src/modern/ui/engine_balance.cpp b/src/modern/ui/engine_balance.cpp index 02a009c..ead75a9 100644 --- a/src/modern/ui/engine_balance.cpp +++ b/src/modern/ui/engine_balance.cpp @@ -66,6 +66,7 @@ Json engine_balance_projection(const Json &b, const Json &r) { {"costs", costs}, {"plan", plan}, {"plan_total", engine_money_minor(d.at("costs"))}, + {"income_total", engine_money_minor(d.at("income"))}, {"league_home_games", s[0].at("value")}, {"other_home_games", s[1].at("value")}, {"attendance_average", s[4].at("value")}, diff --git a/src/modern/ui/engine_dto.cpp b/src/modern/ui/engine_dto.cpp index f349fc3..3683e7d 100644 --- a/src/modern/ui/engine_dto.cpp +++ b/src/modern/ui/engine_dto.cpp @@ -715,7 +715,8 @@ Json engine_friendly_plan(const Json &bundle) { require(r.at("competitionId").is_null()||r.at("competitionId").is_string(),"Unbekannte Gegnerliga."); if (national) require(team.at("kind")=="national" && r.at("competitionId").is_null() && r.at("strength").is_null(),"Ungültiger Nationalgegner oder vorweggenommene Angebotsstärke."); if(!r.at("strength").is_null())(void)whole_in_range(r.at("strength"),0,100000); - auto row=r;row["rank"]=nullptr;row["games"]=nullptr;opponents.push_back(row); + // place and games of a league club, where the backend states them + auto row=r;row["rank"]=r.contains("rank")&&r.at("rank").is_number_integer()?Json(whole_in_range(r.at("rank"),1,99)):Json();row["games"]=r.contains("played")&&r.at("played").is_number_integer()?Json(whole_in_range(r.at("played"),0,99)):Json();opponents.push_back(row); } for(const auto &r:data.at("bookings")) { const auto id=r.at("id").get();require(!id.empty()&&booked.insert(id).second,"Doppelte Freundschaftsbuchung."); diff --git a/src/modern/ui/finance_screens.inc b/src/modern/ui/finance_screens.inc index 2f3078b..545f5dd 100644 --- a/src/modern/ui/finance_screens.inc +++ b/src/modern/ui/finance_screens.inc @@ -21,8 +21,18 @@ std::string App::render_balance() { std::string(engine_mode_&&row.at("editable")!=true?"disabled":"")) + ""; ++i; } - out += "
" + pg_stat("Geplante Ausgaben", esc(balance_cash(rows.at("plan_total").get())), "Summe für zwölf Monate") + - "
" + pg_stat("Kontostand", esc(balance_cash(rows.at("cash").get())), "heute") + "
"; + out += "
" + pg_stat("Geplante Ausgaben", esc(balance_cash(rows.at("plan_total").get())), "Summe für zwölf Monate") + "
"; + // what the plan expects to come in, and what is left of it: the game states both + if (rows.contains("income_total")) { + const int64_t net = rows.at("balance").get(); + out += "
" + pg_stat("Erwartete Einnahmen", esc(balance_cash(rows.at("income_total").get())), "Summe für zwölf Monate") + "
" + + pg_stat("Ergebnis der Planung", "" + esc(balance_cash(net)) + "", net < 0 ? "Die Planung schließt im Minus" : "Einnahmen abzüglich Ausgaben") + + "
" + pg_kicker("Erwartete Einnahmen"); + for (const auto &row : rows.at("income")) + out += "
" + esc(row.at("name").get()) + "" + esc(balance_cash(row.at("amount").get())) + "
"; + out += "
"; + } + out += "
" + pg_stat("Kontostand", esc(balance_cash(rows.at("cash").get())), "heute") + "
"; status = "Planung für zwölf Monate."; } else { int64_t sums[2] = {0, 0}; diff --git a/src/modern/ui/lineup_page.inc b/src/modern/ui/lineup_page.inc index afa6e60..d36e233 100644 --- a/src/modern/ui/lineup_page.inc +++ b/src/modern/ui/lineup_page.inc @@ -57,7 +57,8 @@ std::string App::render_lineup_page() { if (std::string(column.label) == "Name") { auto name = esc(row.at("name").get()); if (row.at("pair_number").is_number_integer()) name += "P" + std::to_string(row.at("pair_number").get()); - out += pg_td(btn("lineup-player", "" + name + "", "pg-link", player_attrs(row, "lineup-name-")), 0, "", true); + // the player's photo heads his name + out += pg_td("" + img("asset:player/" + (id.starts_with("player:") ? id.substr(7) : id) + "/photo", 46, 46 * 4.0 / 3.0, true, true, 128) + "" + btn("lineup-player", "" + name + "", "pg-link", player_attrs(row, "lineup-name-")), 0, "", true); continue; } std::string value; diff --git a/src/modern/ui/news_screens.inc b/src/modern/ui/news_screens.inc index 31cacdf..770e9e0 100644 --- a/src/modern/ui/news_screens.inc +++ b/src/modern/ui/news_screens.inc @@ -20,6 +20,14 @@ std::string App::render_news_art(const Json &message, double size) { art = picture(renderer_.diagram("news-national-flag", ui_nation_flag_svg("de"), 176), size * .69, size * .46); else if (kind == "club" || kind == "career") art = crest(world_->find("clubs", message.value("scope", Json::object()).value("id", std::string())), size * .69); + // a report of a match shows both clubs: the one the report is about and its opponent + if (kind == "fixture" && message.contains("scope") && message.contains("article")) { + const auto &article = message.at("article"); + const Json *data = article.is_object() && article.contains("event") && article.at("event").is_object() && article.at("event").contains("data") ? &article.at("event").at("data") : nullptr; + const auto *own = world_->find("clubs", message.at("scope").value("id", std::string())); + const auto *other = data && data->is_object() && data->contains("opponent") && data->at("opponent").is_object() ? world_->find("clubs", data->at("opponent").value("id", std::string())) : nullptr; + if (own && other) art = "" + crest(own, size * .46) + crest(other, size * .46) + ""; + } if (art.empty()) { // what a letter is about decides its sign: an injury, money, a report of a match if (has({"verletz", "Verletz", "fällt", "Arzt", "Prellung", "prellung", "Zerrung", "riss"})) art = sign("doctor", doctor); diff --git a/src/modern/ui/planning_page.inc b/src/modern/ui/planning_page.inc index 42aa1c3..22de51c 100644 --- a/src/modern/ui/planning_page.inc +++ b/src/modern/ui/planning_page.inc @@ -90,7 +90,7 @@ std::string App::engine_friendlies_view() { out+="
"; for(const auto &r:plan.at("opponents"))if(friendly_league_key(r)==engine_friendly_league_) { const auto &team=r.at("team");const auto id=team.at("id").get(); - out+=btn("friendly-opponent",crest(own_club,84)+"–"+crest(world_->find("clubs",id),84)+""+esc(engine_text(team.at("name")))+"Stärke"+ + out+=btn("friendly-opponent",crest(own_club,84)+"–"+crest(world_->find("clubs",id),84)+""+esc(engine_text(team.at("name")))+""+(r.at("rank").is_number_integer()?"Platz "+std::to_string(r.at("rank").get())+" · "+std::to_string(r.at("games").get())+(r.at("games").get()==1?" Spiel":" Spiele")+" · Stärke":std::string("Stärke"))+""+ (r.at("strength").is_number_integer()?number(r.at("strength")):std::string("—"))+"",std::string("fr-tile ")+(id==engine_friendly_opponent_?"sel":""), "id=\"friendly-opponent-"+esc(id)+"\" data-id=\""+esc(id)+"\" aria-pressed=\""+(id==engine_friendly_opponent_?"true":"false")+"\""); } diff --git a/src/modern/ui/stadium_screens.inc b/src/modern/ui/stadium_screens.inc index 8a9a28c..6fd299a 100644 --- a/src/modern/ui/stadium_screens.inc +++ b/src/modern/ui/stadium_screens.inc @@ -217,6 +217,8 @@ std::string App::render_stadium_data() { std::vector>>> series; std::vector> rows; int ticket=0,low=0,high=25;std::string needed; + // what the curves measure: for every curve shown its lowest, highest and latest figure, and how many home games it spans + std::string axis;size_t samples=0; const Snapshot snapshot=engine_mode_?Snapshot{}:snap(); if(engine_mode_) { const auto &data=engine_data_.at("stadium").at("data"); @@ -227,6 +229,13 @@ std::string App::render_stadium_data() { // the game's own sheet runs from 13 to 311 across and from 18 to 101 down for(const auto &point:data.at("history")[i].at(relative?"relative":"absolute"))points.push_back({(point[0].get()-13.)/298.,(point[1].get()-18.)/83.}); series.emplace_back(colours[i],std::move(points)); + if(const auto &raw=data.at("history")[i];raw.contains("values")&&raw.at("values").is_array()&&!raw.at("values").empty()) { + int64_t least=0,most=0,last=0;bool first=true; + for(const auto &value:raw.at("values")){if(!value.is_number())continue;const auto n=int64_t(std::llround(value.get()));if(first||nmost)most=n;last=n;first=false;} + if(!first){samples=std::max(samples,raw.at("values").size());// a figure in money says so; what the game counts in another unit stays a bare number + const bool cash=names[i].find("Einn")!=std::string::npos||names[i].find("Eintritt")!=std::string::npos||names[i].find("Kosten")!=std::string::npos;const std::string unit=cash?" €":""; + axis+=""+esc(names[i])+": "+number(least)+" bis "+number(most)+unit+" · zuletzt "+number(last)+unit+"";} + } } static constexpr std::array labels{"Max. Zuschauer","Max. Einnahmen (€)","Heimspiele","Ø Zuschauer","Ges. Einnahmen (€)"}; for(size_t row=0;row<5;++row) { @@ -275,7 +284,7 @@ std::string App::render_stadium_data() { out+=pg_button("stadium-curve",""+esc(names[i])+"",std::string("sd-curve")+(stadium_view_.at("curves")[i]==true?" on":""),"id=\"stadium-curve-"+std::to_string(i)+"\" data-id=\""+std::to_string(i)+"\" aria-pressed=\""+(stadium_view_.at("curves")[i]==true?"true":"false")+"\""); out+="
"; for(int i=0;i<2;++i)out+=btn("stadium-scale",""+std::string(i?"Relativ":"Absolut")+"",std::string(i?"":"first ")+(relative==bool(i)?"on":""),"id=\"stadium-scale-"+std::to_string(i)+"\" data-id=\""+std::to_string(i)+"\" aria-pressed=\""+(relative==bool(i)?"true":"false")+"\""); - out+="
"+(series.empty()?std::string("
Keine Kurve eingeblendet.
"):"
"+picture(renderer_.diagram("stadium-chart-"+theme_,stadium_chart_svg(series,theme_),2700),1800,1030)+"
")+""; + out+=""+(series.empty()?std::string("
Keine Kurve eingeblendet.
"):"
"+picture(renderer_.diagram("stadium-chart-"+theme_,stadium_chart_svg(series,theme_),2700),1800,1030)+"
"+(axis.empty()?std::string():"
Von links nach rechts: vom ältesten zum jüngsten Wert."+std::string(relative?" Relativ: jede Kurve füllt die ganze Höhe.":" Absolut: alle Kurven teilen sich einen Maßstab.")+""+axis+"
"))+""; // the ticket price: a button for every price the game allows out+="
"+pg_kicker("Eintritt:")+""+std::to_string(ticket)+" "+esc(unit)+"Benötigter Zuschauerschnitt bei "+std::to_string(ticket)+" "+esc(unit)+" Eintritt: "+esc(needed)+"
"; for(int price=low;price<=high;++price)