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 <noreply@anthropic.com>
This commit is contained in:
1 parent
205e98973b
commit
11264ccdb5
9 files changed
+67
-7
No files matched your search
@@ -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);}
|
||||
@@ -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<int, std::vector<std::pair<int, int>>> standings;
|
||||
const auto standing = [&](int t) -> std::pair<int, int> {
|
||||
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<std::pair<int, int>> 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<int, int>{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);
|
||||
|
||||
@@ -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")},
|
||||
|
||||
@@ -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<std::string>();require(!id.empty()&&booked.insert(id).second,"Doppelte Freundschaftsbuchung.");
|
||||
|
||||
@@ -21,8 +21,18 @@ std::string App::render_balance() {
|
||||
std::string(engine_mode_&&row.at("editable")!=true?"disabled":"")) + "</div>";
|
||||
++i;
|
||||
}
|
||||
out += "</div></section><div class=\"pg-col\" style=\"width:" + pg(400) + ";\"><div style=\"display:flex;\">" + pg_stat("Geplante Ausgaben", esc(balance_cash(rows.at("plan_total").get<int64_t>())), "Summe für zwölf Monate") +
|
||||
"</div><div style=\"display:flex;\">" + pg_stat("Kontostand", esc(balance_cash(rows.at("cash").get<int64_t>())), "heute") + "</div></div></div>";
|
||||
out += "</div></section><div class=\"pg-col\" style=\"width:" + pg(460) + ";" + pg_css("gap:8px;") + "\"><div style=\"display:flex;\">" + pg_stat("Geplante Ausgaben", esc(balance_cash(rows.at("plan_total").get<int64_t>())), "Summe für zwölf Monate") + "</div>";
|
||||
// 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<int64_t>();
|
||||
out += "<div style=\"display:flex;\">" + pg_stat("Erwartete Einnahmen", esc(balance_cash(rows.at("income_total").get<int64_t>())), "Summe für zwölf Monate") + "</div><div style=\"display:flex;\">" +
|
||||
pg_stat("Ergebnis der Planung", "<span class=\"" + std::string(net < 0 ? "balance-loss" : "balance-gain") + "\">" + esc(balance_cash(net)) + "</span>", net < 0 ? "Die Planung schließt im Minus" : "Einnahmen abzüglich Ausgaben") +
|
||||
"</div><section class=\"pg-panel pg-col pg-grow\" style=\"" + pg_css("gap:0px;padding:10px 16px;") + "\">" + pg_kicker("Erwartete Einnahmen");
|
||||
for (const auto &row : rows.at("income"))
|
||||
out += "<div class=\"pg-kv\"><span>" + esc(row.at("name").get<std::string>()) + "</span><strong>" + esc(balance_cash(row.at("amount").get<int64_t>())) + "</strong></div>";
|
||||
out += "</section>";
|
||||
}
|
||||
out += "<div style=\"display:flex;\">" + pg_stat("Kontostand", esc(balance_cash(rows.at("cash").get<int64_t>())), "heute") + "</div></div></div>";
|
||||
status = "Planung für zwölf Monate.";
|
||||
} else {
|
||||
int64_t sums[2] = {0, 0};
|
||||
|
||||
@@ -57,7 +57,8 @@ std::string App::render_lineup_page() {
|
||||
if (std::string(column.label) == "Name") {
|
||||
auto name = esc(row.at("name").get<std::string>());
|
||||
if (row.at("pair_number").is_number_integer()) name += "</span><span class=\"pg-tag sage\" style=\"margin-left:" + pg(6) + ";\">P" + std::to_string(row.at("pair_number").get<int>());
|
||||
out += pg_td(btn("lineup-player", "<span>" + name + "</span>", "pg-link", player_attrs(row, "lineup-name-")), 0, "", true);
|
||||
// the player's photo heads his name
|
||||
out += pg_td("<span class=\"lp-face\">" + img("asset:player/" + (id.starts_with("player:") ? id.substr(7) : id) + "/photo", 46, 46 * 4.0 / 3.0, true, true, 128) + "</span>" + btn("lineup-player", "<span>" + name + "</span>", "pg-link", player_attrs(row, "lineup-name-")), 0, "", true);
|
||||
continue;
|
||||
}
|
||||
std::string value;
|
||||
|
||||
@@ -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 = "<span class=\"news-art-pair\">" + crest(own, size * .46) + crest(other, size * .46) + "</span>";
|
||||
}
|
||||
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);
|
||||
|
||||
@@ -90,7 +90,7 @@ std::string App::engine_friendlies_view() {
|
||||
out+="<div id=\"friendly-opponents\" class=\"pg-tbody fr-tiles\">";
|
||||
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<std::string>();
|
||||
out+=btn("friendly-opponent",crest(own_club,84)+"<span class=\"fr-versus\">–</span>"+crest(world_->find("clubs",id),84)+"<span class=\"fr-tile-text\"><strong>"+esc(engine_text(team.at("name")))+"</strong><small>Stärke</small></span><span class=\"pg-num\">"+
|
||||
out+=btn("friendly-opponent",crest(own_club,84)+"<span class=\"fr-versus\">–</span>"+crest(world_->find("clubs",id),84)+"<span class=\"fr-tile-text\"><strong>"+esc(engine_text(team.at("name")))+"</strong><small>"+(r.at("rank").is_number_integer()?"Platz "+std::to_string(r.at("rank").get<int>())+" · "+std::to_string(r.at("games").get<int>())+(r.at("games").get<int>()==1?" Spiel":" Spiele")+" · Stärke":std::string("Stärke"))+"</small></span><span class=\"pg-num\">"+
|
||||
(r.at("strength").is_number_integer()?number(r.at("strength")):std::string("—"))+"</span>",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")+"\"");
|
||||
}
|
||||
|
||||
@@ -217,6 +217,8 @@ std::string App::render_stadium_data() {
|
||||
std::vector<std::pair<std::string,std::vector<std::array<double,2>>>> series;
|
||||
std::vector<std::array<std::string,4>> 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<double>()-13.)/298.,(point[1].get<double>()-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<double>()));if(first||n<least)least=n;if(first||n>most)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+="<span class=\"sd-axis-item\"><span class=\"sd-mark\" style=\"background-color:"+colours[i]+";\"></span><span>"+esc(names[i])+": "+number(least)+" bis "+number(most)+unit+" · zuletzt "+number(last)+unit+"</span></span>";}
|
||||
}
|
||||
}
|
||||
static constexpr std::array<const char*,5> 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","<span class=\"sd-mark\" style=\"background-color:"+colours[i]+";\"></span><span>"+esc(names[i])+"</span>",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+="<span class=\"pg-sp\"></span><div class=\"pg-seg\">";
|
||||
for(int i=0;i<2;++i)out+=btn("stadium-scale","<span>"+std::string(i?"Relativ":"Absolut")+"</span>",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+="</div></div>"+(series.empty()?std::string("<div class=\"pg-empty\"><span>Keine Kurve eingeblendet.</span></div>"):"<div class=\"sd-chart\" role=\"img\" aria-label=\"Stadiondaten der Heimspiele\">"+picture(renderer_.diagram("stadium-chart-"+theme_,stadium_chart_svg(series,theme_),2700),1800,1030)+"</div>")+"</div>";
|
||||
out+="</div></div>"+(series.empty()?std::string("<div class=\"pg-empty\"><span>Keine Kurve eingeblendet.</span></div>"):"<div class=\"sd-chart\" role=\"img\" aria-label=\"Stadiondaten der Heimspiele\">"+picture(renderer_.diagram("stadium-chart-"+theme_,stadium_chart_svg(series,theme_),2700),1800,1030)+"</div>"+(axis.empty()?std::string():"<div class=\"sd-axis\"><span class=\"pg-mut\">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.")+"</span>"+axis+"</div>"))+"</div>";
|
||||
// the ticket price: a button for every price the game allows
|
||||
out+="<div class=\"pg-panel\"><div class=\"pg-row\" style=\"margin-bottom:"+pg(8)+";"+pg_css("gap:10px;")+"\">"+pg_kicker("Eintritt:")+"<strong class=\"pg-h\">"+std::to_string(ticket)+" "+esc(unit)+"</strong><span class=\"pg-mut\" id=\"stadium-required\">Benötigter Zuschauerschnitt bei "+std::to_string(ticket)+" "+esc(unit)+" Eintritt: <strong>"+esc(needed)+"</strong></span></div><div class=\"sd-prices\">";
|
||||
for(int price=low;price<=high;++price)
|
||||
|
||||
Reference in new issue
Block a user