diff --git a/assets/modern/pages.rcss b/assets/modern/pages.rcss index 0b44c89..5b6bde6 100644 --- a/assets/modern/pages.rcss +++ b/assets/modern/pages.rcss @@ -1147,3 +1147,5 @@ body .popup-box p.as-verdict {margin:14dp 0 0;text-align:center;font-size:31dp;} .cs-sum.cs-age {width:230dp;} .cs-cash .cs-label {overflow:hidden;white-space:nowrap;text-overflow:ellipsis;} .pg-dlg.cs-sheet {height:1680dp;} +.sd-steps {display:block;flex:none;margin-top:9dp;padding-top:13dp;border-top:2dp var(--p-div);} +.sd-steps>* {margin-bottom:9dp;} diff --git a/docs/new_engine/ausbaustufen.md b/docs/new_engine/ausbaustufen.md index 0cc9e82..7133b9e 100644 --- a/docs/new_engine/ausbaustufen.md +++ b/docs/new_engine/ausbaustufen.md @@ -38,6 +38,14 @@ Read `stadium`: `expansions[]` mit `id` (`expansion:lounge`, `mall`, `clubhouse` `nextPrice`, `nextMonths`, `available`. Befehl `stadium.expand {expansionId, confirmed: true}` (Fehler `confirmation_required`, `unknown_expansion`, `expansion_refused`). +## Darstellung + +Das Kartonmodell des Stadions zeichnet die Stufe: Clubhaus und Einkaufszentrum je Stufe ein +Stockwerk höher, der Parkplatz in vier Schritten länger, das Restaurant in Stufe 2 mit zweitem +Stockwerk, die Lounge breiter und mit zweiter verglaster Reihe. Während des Baus steht ein +Kran; die Ansicht „Zukunft“ zeigt die Stufe als fertig. Die Karte eines Gebäudes nennt Stufe, +Ertrag, Preis und Bauzeit der nächsten Stufe und bietet den Ausbau an. + ## Prüfung `modern_expansion_tests` (ohne Spieldaten): Stufe 1 nur für Gebautes, Preis und Bauzeit, @@ -46,8 +54,6 @@ Fertigstellung, letzte Stufe, Einnahme nach Liga, Lounge im Bau zählt nicht als ## Offen -- Die Stufen sind auf der Stadionseite nur als Liste (Knopf „Ausbaustufen“) zu sehen, nicht - im Kartonmodell. - Die Wirkung der Lounge auf Zuschauer und Preise bleibt die des Originals; die weiteren Stufen bringen nur die monatliche Einnahme. - Einnahmen und Baukosten sind einfache Buchungen ohne eigenen Bilanzposten. diff --git a/src/modern/ui/engine_assembly.inc b/src/modern/ui/engine_assembly.inc index 802ac54..b97a4dc 100644 --- a/src/modern/ui/engine_assembly.inc +++ b/src/modern/ui/engine_assembly.inc @@ -270,3 +270,22 @@ std::string App::engine_shirt_at(size_t place) const { } catch (const std::exception &) {} return std::to_string(place + 1); } +// The next stage of the lounge or of a building of the periphery: what it costs, then the order. +void App::engine_expansion_ask(const std::string &expansion) { + std::string name, terms; + try { + for (const auto &row : engine_data_.at("stadium").at("data").at("expansions")) + if (row.value("id", std::string()) == expansion && !row.at("nextPrice").is_null() && row.value("available", false)) { + name = row.value("name", std::string()); + terms = engine_price(row.at("nextPrice")) + ", " + std::to_string(row.value("nextMonths", 0)) + " Monate Bauzeit"; + } + } catch (const std::exception &) {} + if (name.empty()) return; + confirmation(name + " um eine Stufe ausbauen? (" + terms + ")", [this, expansion] { + try { + engine_finance_submit(engine_expansion_command(engine_data_, expansion, editor::new_id("request:ui-"))); + } catch (const std::exception &e) { message(e.what()); } + }); + popup_title_ = "Ausbau"; + popup_accept_ = "Ausbauen"; +} diff --git a/src/modern/ui/engine_controls.inc b/src/modern/ui/engine_controls.inc index 68593ec..80f28c7 100644 --- a/src/modern/ui/engine_controls.inc +++ b/src/modern/ui/engine_controls.inc @@ -481,27 +481,7 @@ void App::engine_event(Rml::Event &event) { const auto action = node->GetAttribute("data-action", ""), id = node->GetAttribute("data-id", ""); if (!popup_.empty()) { if(action=="balance-discard"){engine_balance_action(action,node);return;} - if (action == "expansion-start") { - const std::string expansion = id; - std::string name, terms; - try { - for (const auto &row : engine_data_.at("stadium").at("data").at("expansions")) - if (row.value("id", std::string()) == expansion && !row.at("nextPrice").is_null()) { - name = row.value("name", std::string()); - terms = engine_price(row.at("nextPrice")) + ", " + std::to_string(row.value("nextMonths", 0)) + " Monate Bauzeit"; - } - } catch (const std::exception &) {} - popup_.clear(); reset_popup(); confirm_ = {}; dirty_ = true; - if (name.empty()) return; - confirmation(name + " um eine Stufe ausbauen? (" + terms + ")", [this, expansion] { - try { - engine_finance_submit(engine_expansion_command(engine_data_, expansion, editor::new_id("request:ui-"))); - } catch (const std::exception &e) { message(e.what()); } - }); - popup_title_ = "Ausbau"; - popup_accept_ = "Ausbauen"; - return; - } + if (action == "expansion-start") { const std::string expansion = id; popup_.clear(); reset_popup(); confirm_ = {}; dirty_ = true; engine_expansion_ask(expansion); return; } if (action == "naming-accept") { const std::string offer = id; std::string name, terms; @@ -543,6 +523,7 @@ void App::engine_event(Rml::Event &event) { return; } if (engine_assembly_open_) { engine_assembly_action(action, id); return; } + if (action == "expansion-start" && engine_fresh_ && !engine_busy_) { engine_expansion_ask(id); return; } // from the card of a building if (action == "lineup-number" && engine_fresh_ && !engine_busy_ && menu_ == "lineup") { // a new shirt number for the player; whoever wears it takes his const std::string player = id; diff --git a/src/modern/ui/engine_stadium.cpp b/src/modern/ui/engine_stadium.cpp index 2a1801e..3bceb8c 100644 --- a/src/modern/ui/engine_stadium.cpp +++ b/src/modern/ui/engine_stadium.cpp @@ -76,6 +76,20 @@ Json engine_stadium_projection(const Json &bundle, bool future) { super = super && (future ? target : current) == b.at("maxPlaces").get() && seats && roof; } + // the further stages of Modern (read stadium, expansions), by the object they belong to + const auto staged = [&](Json &row, const std::string &object) { + if (!d.contains("expansions")) return; + for (const auto &e : d.at("expansions")) { + if (e.value("objectId", std::string()) != object) continue; + const int left = e.value("monthsLeft", 0); + row["stage"] = e.value("stage", 0); + row["stages"] = e.value("maxStage", 1); + row["expanding"] = left > 0; + row["expansion"] = {{"id", e.value("id", std::string())}, {"months_left", left}, {"available", e.value("available", false)}, + {"income", engine_money_minor(e.at("monthlyIncome"))}, + {"price", e.at("nextPrice").is_null() ? Json() : Json(engine_money_minor(e.at("nextPrice")))}, {"months", e.value("nextMonths", Json())}}; + } + }; for (size_t i = 0; i < 8; ++i) { const auto &f = d.at("facilities")[i]; const int level = f.at("level"), weeks = f.at("constructionWeeks"), @@ -97,6 +111,7 @@ Json engine_stadium_projection(const Json &bundle, bool future) { {"building", weeks > 0}, {"available", f.at("upgradeAvailable")}, {"job", weeks > 0 ? Json{{"level", target}, {"weeks", weeks}} : Json()}}); + staged(facilities.back(), f.at("id").get()); } for (size_t i = 0; i < 14; ++i) { const auto &p = d.at("periphery")[i]; @@ -114,6 +129,7 @@ Json engine_stadium_projection(const Json &bundle, bool future) { {"display_level", future && busy ? target : level}, {"building", busy}, {"job", busy ? Json{{"level", target}, {"weeks", days}} : Json()}}); + staged(periphery.back(), p.at("id").get()); } return {{"ok", true}, {"club", d.at("teamId")}, diff --git a/src/modern/ui/live_state.inc b/src/modern/ui/live_state.inc index 44dfb1f..1888262 100644 --- a/src/modern/ui/live_state.inc +++ b/src/modern/ui/live_state.inc @@ -55,6 +55,7 @@ void engine_assembly_choose(const std::string &team); // The shirt number of a player of the squad at the desk, or of its n-th player; the fallback // (the place on the board) where the engine gives none. + void engine_expansion_ask(const std::string &expansion); // the next stage of a building: asked, then ordered std::string engine_shirt(const std::string &player, size_t fallback) const; std::string engine_shirt_at(size_t place) const; // The big sheet of the interested clubs: open or not, the club whose details are shown, and diff --git a/src/modern/ui/stadium_scene.hpp b/src/modern/ui/stadium_scene.hpp index b128dc9..9c677e9 100644 --- a/src/modern/ui/stadium_scene.hpp +++ b/src/modern/ui/stadium_scene.hpp @@ -198,9 +198,16 @@ inline Scene build(const Json &overview, bool future, const std::string &sign) { const auto around = [&](size_t i) -> const Json & { return i < periphery.size() ? periphery[i] : none; }; // levels count from 1; the model draws from 0 const auto grade = [&](size_t i) { const auto &f = facility(i); return std::clamp(f.value("display_level", f.value("level", 1)) - 1, 0, 3); }; - const auto level = [&](size_t i) { const auto &p = around(i); return std::max(0, p.value("display_level", p.value("level", 0))); }; - const auto most = [&](size_t i) { return std::max(1, around(i).value("max_level", 1)); }; - const auto busy = [&](const Json &row) { return !future && row.value("building", false); }; + // a building that Modern extends in stages (stage 1 = as built) is drawn by its stage; in the + // view of the future the stage under construction counts as finished + const auto stage_of = [&](const Json &row) { return row.contains("stage") ? row.value("stage", 0) + (future && row.value("expanding", false) && row.value("stage", 0) > 0 ? 1 : 0) : -1; }; + const auto level = [&](size_t i) { + const auto &p = around(i); + const int built = std::max(0, p.value("display_level", p.value("level", 0))); + return stage_of(p) >= 0 && built > 0 ? std::max(1, stage_of(p)) : built; + }; + const auto most = [&](size_t i) { return std::max(1, around(i).contains("stages") ? around(i).value("stages", 1) : around(i).value("max_level", 1)); }; + const auto busy = [&](const Json &row) { return !future && (row.value("building", false) || row.value("expanding", false)); }; // ---- the stands: the four with the most room are the long and short sides ---- constexpr double G = 40, G2 = 58.5, H0 = 1.6; @@ -345,10 +352,12 @@ inline Scene build(const Json &overview, bool future, const std::string &sign) { hot("facility:1", bx - 1, box_quads(bx - 2, -bw, bx, bw, bz, bz + bh * 1.6)); // the lounge in the main stand; where there is none, its place is only marked const bool lounge = facility(3).value("max_level", 2) > 2 || facility(3).value("display_level", facility(3).value("level", 1)) >= 2; + const int lounge_stage = lounge ? std::clamp(stage_of(facility(3)), 0, 4) : 0; // 0: not staged (the demo, an older engine) const int lounge_size = facility(3).value("max_level", 2) <= 2 ? 2 : grade(3); - const double north_tall = 2.5 + depth_north * .6, vw = std::array{10, 16, 24, 34, 34}[size_t(std::clamp(lounge_size, 0, 4))], vy = -G - depth_north * .62, vz = H0 + (north_tall - H0) * .62; - BoxLook glass; glass.deco_y = windows_y(vy, -vw, vw, vz + .4, vz + 3, int(std::lround(vw / 2.2)), "#bfe0ea", .1); glass.top = "#e9dfc9"; - items.push_back({-G - depth_north / 2 + .6, lounge ? paint(box(-vw, vy - 3.4, vw, vy, vz - .5, vz + 3.6, "#f6f0e2", glass)) + const double lounge_rise = lounge_stage > 1 ? (lounge_stage - 1) * 1.5 : 0; + const double north_tall = 2.5 + depth_north * .6, vw = lounge_stage ? std::array{24, 20, 25, 30, 35}[size_t(lounge_stage)] : std::array{10, 16, 24, 34, 34}[size_t(std::clamp(lounge_size, 0, 4))], vy = -G - depth_north * .62, vz = H0 + (north_tall - H0) * .62; + BoxLook glass; glass.deco_y = windows_y(vy, -vw, vw, vz + .4, vz + 3, int(std::lround(vw / 2.2)), "#bfe0ea", .1) + (lounge_rise > 0 ? windows_y(vy, -vw, vw, vz + 3.5, vz + 3.2 + lounge_rise, int(std::lround(vw / 2.2)), "#d7ecf2", .1) : std::string()); glass.top = "#e9dfc9"; + items.push_back({-G - depth_north / 2 + .6, lounge ? paint(box(-vw, vy - 3.4, vw, vy, vz - .5, vz + 3.6 + lounge_rise, "#f6f0e2", glass)) + (busy(facility(3)) && facility(3).value("expanding", false) ? crane(vw + 4, vy - 2, vz + 14) : std::string()) : poly({{-vw, vy, vz - .5}, {vw, vy, vz - .5}, {vw, vy, vz + 3.6}, {-vw, vy, vz + 3.6}}, "#ffffff", "fill-opacity=\".25\" stroke=\"#645c50\" stroke-width=\"1.1\" stroke-dasharray=\"4 3\"")}); hot("facility:3", -G - depth_north / 2 + .6, box_quads(-vw, vy - 3.4, vw, vy, vz - .5, vz + 3.6)); // three small houses in the corners of the forecourt: heating, comfort, upkeep @@ -479,14 +488,15 @@ inline Scene build(const Json &overview, bool future, const std::string &sign) { house(2, -46, -124, 44, -92, z, faces, ""); } { - BoxLook look; look.top = "#a8452f"; look.deco_y = windows_y(-96, 66, 100, 1.2, 5, 6, "#bfe0ea", .2) + sign_y(72, -96, 7.6, "RESTAURANT", 5.4); look.deco_x = windows_x(100, -122, -96, 1.2, 5, 4, "#bfe0ea", .2); + const double rz = level(5) >= 2 ? 12 : 7; // stage two adds a storey + BoxLook look; look.top = "#a8452f"; look.deco_y = windows_y(-96, 66, 100, 1.2, 5, 6, "#bfe0ea", .2) + (rz > 7 ? windows_y(-96, 66, 100, 6.4, 10.4, 6, "#bfe0ea", .2) : std::string()) + sign_y(72, -96, rz + .6, "RESTAURANT", 5.4); look.deco_x = windows_x(100, -122, -96, 1.2, 5, 4, "#bfe0ea", .2) + (rz > 7 ? windows_x(100, -122, -96, 6.4, 10.4, 4, "#bfe0ea", .2) : std::string()); // tables under parasols in front of it std::string terrace = paint(box(66, -96, 100, -86, 0, .6, "#d9b98a")); for (const double x : {70.0, 78.0, 86.0, 94.0}) { const auto q = project({x, -91, 3}); terrace += " 7 ? "#c8733c" : "#f6ecd8") + "\" stroke=\"" + ink + "\" stroke-width=\".6\"/>" + line({x, -91, .6}, {x, -91, 3}, ink, .7); } - house(5, 66, -122, 100, -96, 7, box(66, -122, 100, -96, 0, 7, "#f6f0e2", look), terrace); + house(5, 66, -122, 100, -96, rz, box(66, -122, 100, -96, 0, rz, "#f6f0e2", look), terrace); } { const auto stall = [&](size_t index, double x, double y) { diff --git a/src/modern/ui/stadium_screens.inc b/src/modern/ui/stadium_screens.inc index b6c413a..cda5425 100644 --- a/src/modern/ui/stadium_screens.inc +++ b/src/modern/ui/stadium_screens.inc @@ -185,15 +185,28 @@ std::string App::render_stadium() { for(int i=0;i1?std::to_string(level)+" von "+std::to_string(most):"gebaut")+(index==0&&!reach.empty()?stadium_kv("Anbindung",reach):std::string())+"
"+pg_dots(level,most)+"
"; full=row.at("level").get()>=most; + // a building Modern extends in stages: built is all the original says about it + if(engine_mode_&&row.contains("expansion")&&row.value("stage",0)>0)body=stadium_kv("Gebäude","gebaut"); } std::string job; if(busy) { const auto &work=row.at("job"); job="Im Bau"+(stadium_focus_.starts_with("block:")?" auf "+number(work.at("places").get())+" Plätze":std::string())+" · noch "+std::to_string(work.at("weeks").get())+(stadium_focus_.starts_with("periphery:")&&engine_mode_?" Tage":" Wochen")+""; } - out+=""; + // Modern's further stages of the lounge and four buildings of the periphery + std::string stages; + if(engine_mode_&&row.contains("expansion")&&row.value("stage",0)>0) { + const auto &x=row.at("expansion");const int stage=row.value("stage",0),all=row.value("stages",1),left=x.value("months_left",0); + stages="
"+stadium_kv("Ausbaustufe",std::to_string(stage)+" von "+std::to_string(all))+"
"+pg_dots(stage,all)+"
"+ + (x.value("income",int64_t(0))>0?stadium_kv("Bringt im Monat",esc(money(x.at("income").get(),{{"code","EUR"},{"minor_units",2}}))):std::string())+ + (left>0?"Stufe "+std::to_string(stage+1)+" im Bau · noch "+std::to_string(left)+(left==1?" Monat":" Monate")+"" + :x.at("price").is_null()?std::string("Alle Stufen sind gebaut.") + :stadium_kv("Nächste Stufe",esc(money(x.at("price").get(),{{"code","EUR"},{"minor_units",2}}))+" · "+std::to_string(x.value("months",0))+" Monate")+"
"+ + pg_button("expansion-start","Stufe ausbauen","","id=\"stadium-card-expand\" data-id=\""+esc(x.value("id",std::string()))+"\" "+(x.value("available",false)?"":"disabled=\"disabled\""))+"
")+"
"; + } + out+=""; } stadium_tip_=tip.empty()?std::string():stadium_tip_; out+="
"+tip+"