diff --git a/assets/modern/art/bank-home-5.png b/assets/modern/art/bank-home-5.png index 40be8a6..389d59f 100644 Binary files a/assets/modern/art/bank-home-5.png and b/assets/modern/art/bank-home-5.png differ diff --git a/assets/modern/art/bank-stocks.png b/assets/modern/art/bank-stocks.png deleted file mode 100644 index 271f2f9..0000000 Binary files a/assets/modern/art/bank-stocks.png and /dev/null differ diff --git a/assets/modern/art/gui-assets.json b/assets/modern/art/gui-assets.json index 03d5533..1f37240 100644 --- a/assets/modern/art/gui-assets.json +++ b/assets/modern/art/gui-assets.json @@ -182,16 +182,6 @@ 1 ] }, - "bank.scene.stocks": { - "file": "bank-stocks.png", - "sha256": "89eae73444c7c81d18b2158bdb5651ae379921c6569e7ddbbd6efa0a330cb0ad", - "crop": [ - 0, - 0, - 1, - 1 - ] - }, "bank.scene.overview": { "file": "bank-hall.png", "sha256": "99588ae770f38b758064572c47242c590e97dda3a8f382fcabf081cf32a3a942", @@ -264,7 +254,7 @@ }, "bank.home.5": { "file": "bank-home-5.png", - "sha256": "cd51afe7175a4d04f5757a95166bd31e44cce1bd065a1bf2860f8881e2ac7aaf", + "sha256": "f75a474a1562fde2a913a28f49e77d152c1c3192a97b33712b429a26201092e3", "crop": [ 0, 0, diff --git a/assets/modern/pages.rcss b/assets/modern/pages.rcss index abd0f45..d05a241 100644 --- a/assets/modern/pages.rcss +++ b/assets/modern/pages.rcss @@ -781,7 +781,7 @@ body.midnight .cp-map-name,body.matchday .cp-map-name {color:#f0ece2;font-effect .bk-banner-over strong {display:block;font-family:Display;font-weight:normal;font-size:56dp;line-height:64dp;white-space:nowrap;color:#f9f4ed;} .bk-banner-d {display:block;font-size:27dp;line-height:34dp;white-space:nowrap;color:#e6dccb;} .bk-reading {display:block;font-size:28dp;line-height:38dp;} -.bk-ring {display:block;flex:none;width:400dp;height:400dp;} +.bk-ring {display:block;flex:none;width:700dp;height:700dp;} .bk-part {display:block;margin-bottom:9dp;font-size:29dp;line-height:42dp;} .bk-part span {display:block;white-space:nowrap;} .bk-part strong {display:block;font-weight:bold;white-space:nowrap;} @@ -804,6 +804,8 @@ body.midnight .cp-map-name,body.matchday .cp-map-name {color:#f0ece2;font-effect .bk-passbook-line {display:flex;align-items:flex-end;justify-content:space-between;height:92dp;border-bottom:2dp #9fb7c4;font-size:30dp;} .bk-passbook-line span {display:block;padding-bottom:9dp;color:#645c50;} .bk-passbook-line strong {display:block;font-family:Pencil;font-weight:bold;font-size:58dp;line-height:70dp;white-space:nowrap;color:#23415c;} +/* the note of today's interest under the passbook */ +.ad-memo.bk-rates {margin:40dp 60dp 0 27dp;padding:50dp 40dp 30dp;transform:rotate(1.2deg);} .bk-passbook-note {display:block;margin-top:27dp;font-family:Pencil;font-size:42dp;line-height:52dp;color:#8c491a;transform:rotate(-1deg);} /* the board of the estate agent */ .bk-board {display:flex;flex:none;flex-wrap:wrap;gap:22dp 24dp;padding:36dp 30dp 22dp;border:5dp #8a6a44;border-radius:27dp;background-color:#cfa877;} @@ -822,7 +824,7 @@ body.midnight .cp-map-name,body.matchday .cp-map-name {color:#f0ece2;font-effect .bk-stamp span {display:block;font-family:Display;font-size:44dp;line-height:52dp;letter-spacing:4dp;color:#a8452f;} .bk-stamp small {display:block;font-family:Modern;font-size:24dp;line-height:30dp;font-weight:bold;letter-spacing:2dp;color:#a8452f;} /* the list of the stocks */ -.bk-row,.bk-row:hover,.bk-row:focus {display:flex;flex:none;align-items:center;gap:18dp;width:100%;height:92dp;padding:0 14dp;margin:0;border:0dp;border-top:2dp var(--p-row);border-radius:0dp;background-color:transparent;decorator:none;font-family:Modern;font-size:30dp;color:var(--p-text);text-align:left;} +.bk-row,.bk-row:hover,.bk-row:focus {display:flex;flex:none;align-items:center;gap:18dp;width:100%;height:108dp;padding:0 14dp;margin:0;border:0dp;border-top:2dp var(--p-row);border-radius:0dp;background-color:transparent;decorator:none;font-family:Modern;font-size:30dp;color:var(--p-text);text-align:left;} .bk-row:hover {background-color:var(--p-n2);} .bk-row.sel,.bk-row.sel:hover {background-color:var(--p-a1);} .bk-row.head {height:62dp;border-top-width:0dp;font-size:23dp;font-weight:bold;letter-spacing:1dp;color:var(--p-n7);} @@ -836,3 +838,5 @@ body.midnight .cp-map-name,body.matchday .cp-map-name {color:#f0ece2;font-effect .bk-move.up {color:var(--p-s8);} .bk-move.down {color:var(--p-a8);} .bk-move.flat {color:var(--p-n7);font-weight:normal;} +.ad-memo.bk-rates strong {font-size:62dp;line-height:72dp;} +.ad-memo.bk-rates span {font-size:50dp;line-height:66dp;} diff --git a/src/modern/app/modern_session.cpp b/src/modern/app/modern_session.cpp index c8cac39..d19cf7b 100644 --- a/src/modern/app/modern_session.cpp +++ b/src/modern/app/modern_session.cpp @@ -9508,8 +9508,16 @@ cli::Json ModernSession::ui_read(const cli::Json& request, uint64_t revision) co funds.push_back(O{{"id", "fund:" + std::to_string(i)}, {"name", property}, {"price", modern::ui_money(f.price)}, {"owned", int(f.owned)}, {"paid", modern::ui_money(f.paid)}, {"maxToBuy", f.max_to_buy}}); } + // the interest of a year in hundredths of a percent, read off the rule that books it + // every day: what one day costs or earns on a sum of 36.5 million + constexpr int32_t probe = 36500000; + const auto per_year = [](int32_t a_day) { return int(std::abs(int64_t(a_day)) * 365 * 10000 / probe); }; + const O interest{{"cash", per_year(daily_interest_amounts(probe, 0, 0).cash_and_deposit)}, + {"deposit", per_year(daily_interest_amounts(0, probe, 0).cash_and_deposit)}, + {"overdraft", per_year(daily_interest_amounts(-probe, 0, probe).borrowing)}, + {"beyondLine", per_year(daily_interest_amounts(-probe, 0, 0).borrowing)}}; return modern::ui_snapshot(g_, context, request_id, - O{{"kind", "bank"}, {"teamId", modern::ui_team_id(g_, team)}, + O{{"kind", "bank"}, {"teamId", modern::ui_team_id(g_, team)}, {"interest", interest}, {"accounts", O{{"cash", modern::ui_money(b.balance)}, {"deposit", modern::ui_money(b.deposit)}, {"creditLine", modern::ui_money(b.credit_line)}, {"investments", modern::ui_money(b.investment_balance)}}}, {"stocks", std::move(stocks)}, {"funds", std::move(funds)}, diff --git a/src/modern/ui/bank_screens.inc b/src/modern/ui/bank_screens.inc index 03580c3..9bc5794 100644 --- a/src/modern/ui/bank_screens.inc +++ b/src/modern/ui/bank_screens.inc @@ -88,10 +88,37 @@ std::string App::render_bank() { const auto deposit = snapshot.state.at("deposit").get(); out += "
" + banner("bank.scene.savings", 640, 648, "Guthaben auf dem Sparbuch", bank_money(deposit), share(in_deposit) + " des Vermögens") + "
Waldpark Bank · Sparbuch"; + // the interest of a year in hundredths of a percent, as the rules of this game state it + const auto rate = [&](int64_t hundredths) { + auto text = one(double(hundredths) / 100); + if (text.ends_with(",0")) text.resize(text.size() - 2); + return text + " %"; + }; + std::vector rates; + int64_t on_deposit = 0; + if (engine_mode_ && summary.contains("interest")) { + const auto &interest = summary.at("interest"); + on_deposit = interest.at("deposit").get(); + rates.push_back("Sparbuch: " + rate(on_deposit) + " im Jahr"); + rates.push_back("Konto im Plus: " + rate(interest.at("cash").get())); + rates.push_back("Konto im Minus: " + rate(interest.at("overdraft").get()) + " Sollzins"); + rates.push_back("Über der Kreditlinie: " + rate(interest.at("beyondLine").get())); + } else if (!engine_mode_) { + on_deposit = std::llround(summary.at("savings_rate").get() * 100); + rates.push_back("Sparbuch: " + rate(on_deposit) + " im Jahr"); + rates.push_back("Kredit: " + rate(std::llround(summary.at("credit_rate").get() * 100)) + " im Jahr"); + } + if (on_deposit > 0 && deposit > 0) rates.push_back("Macht rund " + bank_money(deposit * on_deposit / 10000) + " im Jahr."); // the page of the passbook: what is written in it today for (const auto &[label, value] : std::array, 4>{{{"Guthaben", bank_money(deposit)}, {"Auf dem Konto", bank_money(in_cash)}, {"Vermögen gesamt", bank_money(wealth)}, {"Anteil Sparbuch", share(in_deposit)}}}) out += "
" + std::string(label) + "" + esc(value) + "
"; - out += "" + std::string(deposit > 0 ? "Liegt sicher. Rest bleibt auf dem Konto." : in_cash > 0 ? "Noch nichts zurückgelegt!" : "Erst muss Geld aufs Konto.") + "
" + + out += "" + std::string(deposit > 0 ? "Liegt sicher. Rest bleibt auf dem Konto." : in_cash > 0 ? "Noch nichts zurückgelegt!" : "Erst muss Geld aufs Konto.") + "
"; + if (!rates.empty()) { + out += "
Zinsen zurzeit"; + for (const auto &text : rates) out += "" + esc(text) + ""; + out += "
"; + } + out += "" + std::string(engine_mode_ ? "Einzahlungen und Abhebungen werden nach Bestätigung im Spielstand verbucht." : "Einzahlungen und Abhebungen werden hier als fiktive Vorschau verbucht.") + "
" + calc("Einzahlen", "deposit", "primary block") + calc("Abheben", "withdraw", "block") + "
"; } else if (bank_view_ == "properties") { @@ -131,9 +158,8 @@ std::string App::render_bank() { int held_papers = 0; for (const auto &held : finance.at("stocks")) if (held.get() > 0) ++held_papers; page_title_ = "Aktien"; - page_hint_ = "Depotwert " + bank_money(in_stock); - out += "
" + banner("bank.scene.stocks", 700, 96, "Depot", bank_money(in_stock), std::to_string(held_papers) + " von " + std::to_string(stock_count) + " Papieren im Bestand") + - "
WERT30 TAGEKURSZUM VORTAGBESTAND
"; + page_hint_ = "Depotwert " + bank_money(in_stock) + " · " + std::to_string(held_papers) + " von " + std::to_string(stock_count) + " Papieren im Bestand"; + out += "
" + "
WERT30 TAGEKURSZUM VORTAGBESTAND
"; for (int i = 0; i < stock_count; ++i) { const auto &s = assets.at("stocks")[size_t(i)]; const auto history = course(i); @@ -222,22 +248,30 @@ std::string App::render_bank() { const double around = 2 * 3.14159265358979 * 300; std::string ring = ""; double turned = 0; + std::string marks; for (const auto &part : parts) { if (wealth <= 0 || part.value <= 0) continue; const double length = around * double(part.value) / double(wealth); + // a share wide enough to hold it is written into its piece of the ring + if (length >= around * .06) { + const double angle = (turned + length / 2) / 300 - 3.14159265358979 / 2; + marks += "" + + std::to_string(int(std::lround(double(part.value) * 100 / double(wealth)))) + " %"; + } if (part.value == wealth) { ring += ""; break; } ring += ""; turned += length; } - ring += ""; - out += "
" + banner("bank.scene.overview", 590, 196, "Vermögen", bank_money(wealth), "Konto, Sparbuch, Immobilien und Aktien") + - "
" + picture(renderer_.diagram("bank-ring-" + theme_, ring, 900), 400, 400) + "
"; + ring += marks + "VERMÖGEN 16 ? "42" : "52") + "\" font-weight=\"bold\" font-family=\"Arial, Liberation Sans, sans-serif\">" + esc(bank_money(wealth)) + ""; + out += "
" + banner("bank.scene.overview", 590, 170, "Vermögen", bank_money(wealth), "Konto, Sparbuch, Immobilien und Aktien") + + "
" + picture(renderer_.diagram("bank-ring-" + theme_, ring, 1400), 700, 700) + "
"; const Part *largest = &parts[0]; for (const auto &part : parts) { if (part.value > largest->value) largest = ∂ const double width = wealth > 0 ? std::max(0, part.value) * 100.0 / wealth : 0; out += "
" + part.label + "" + - esc(bank_money(std::string(part.label) == "Konto" ? in_cash : part.value)) + "" + share(part.value) + "
"; + esc(bank_money(std::string(part.label) == "Konto" ? in_cash : part.value)) + "
"; } out += engine_mode_ ? kv("Kreditlinie", esc(bank_money(summary.at("credit_line").get()))) : kv("Kredit", "−" + esc(bank_money(summary.at("debt").get()))) + kv("Saldo", esc(bank_money(summary.at("net").get()))); out += "
"; diff --git a/src/modern/ui/engine_dto.cpp b/src/modern/ui/engine_dto.cpp index 677552f..cd81148 100644 --- a/src/modern/ui/engine_dto.cpp +++ b/src/modern/ui/engine_dto.cpp @@ -350,9 +350,15 @@ Json engine_bank_projection(const Json &bundle) { assets[dest].push_back(item); finance[dest].push_back(owned); } } - return {{"assets", assets}, {"state", {{"deposit", deposit}, {"finance", finance}}}, - {"summary", {{"ok", true}, {"cash", cash}, {"deposit", deposit}, {"properties", properties}, {"stocks", stocks}, - {"credit_line", engine_money_minor(accounts.at("creditLine"))}}}}; + Json summary = {{"ok", true}, {"cash", cash}, {"deposit", deposit}, {"properties", properties}, {"stocks", stocks}, + {"credit_line", engine_money_minor(accounts.at("creditLine"))}}; + // the interest of a year in hundredths of a percent; an older backend does not state it + if (data.contains("interest")) { + Json interest = Json::object(); + for (const auto *key : {"cash", "deposit", "overdraft", "beyondLine"}) interest[key] = whole_in_range(data.at("interest").at(key), 0, 100000); + summary["interest"] = interest; + } + return {{"assets", assets}, {"state", {{"deposit", deposit}, {"finance", finance}}}, {"summary", summary}}; } Json engine_bank_command(const Json &bundle, const Json &payload, const std::string &request_id) { const auto projection = engine_bank_projection(bundle);