Bank: a larger ring, the stocks without a picture, today's interest as a note
The ring of the bank page is drawn larger and carries the shares and the sum in its middle. The stocks page begins with its list. The passbook has a pencilled note of the interest of a year; the bank read states the rates, derived from the rule that books the interest each day. The office building has a picture of its own. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
964a4ae35d
commit
f25abc2e16
7 files changed
+67
-25
No files matched your search
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 1.3 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 3.5 MiB |
@@ -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,
|
||||
|
||||
@@ -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;}
|
||||
@@ -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)},
|
||||
|
||||
@@ -88,10 +88,37 @@ std::string App::render_bank() {
|
||||
const auto deposit = snapshot.state.at("deposit").get<int64_t>();
|
||||
out += "<div class=\"pg-row pg-grow\" style=\"align-items:stretch;\">" + banner("bank.scene.savings", 640, 648, "Guthaben auf dem Sparbuch", bank_money(deposit), share(in_deposit) + " des Vermögens") +
|
||||
"<div class=\"pg-col pg-grow\"><div class=\"bk-passbook\"><span class=\"bk-passbook-head\">Waldpark Bank · Sparbuch</span>";
|
||||
// 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<std::string> rates;
|
||||
int64_t on_deposit = 0;
|
||||
if (engine_mode_ && summary.contains("interest")) {
|
||||
const auto &interest = summary.at("interest");
|
||||
on_deposit = interest.at("deposit").get<int64_t>();
|
||||
rates.push_back("Sparbuch: " + rate(on_deposit) + " im Jahr");
|
||||
rates.push_back("Konto im Plus: " + rate(interest.at("cash").get<int64_t>()));
|
||||
rates.push_back("Konto im Minus: " + rate(interest.at("overdraft").get<int64_t>()) + " Sollzins");
|
||||
rates.push_back("Über der Kreditlinie: " + rate(interest.at("beyondLine").get<int64_t>()));
|
||||
} else if (!engine_mode_) {
|
||||
on_deposit = std::llround(summary.at("savings_rate").get<double>() * 100);
|
||||
rates.push_back("Sparbuch: " + rate(on_deposit) + " im Jahr");
|
||||
rates.push_back("Kredit: " + rate(std::llround(summary.at("credit_rate").get<double>() * 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<std::pair<const char *, std::string>, 4>{{{"Guthaben", bank_money(deposit)}, {"Auf dem Konto", bank_money(in_cash)}, {"Vermögen gesamt", bank_money(wealth)}, {"Anteil Sparbuch", share(in_deposit)}}})
|
||||
out += "<div class=\"bk-passbook-line\"><span>" + std::string(label) + "</span><strong>" + esc(value) + "</strong></div>";
|
||||
out += "<span class=\"bk-passbook-note\">" + std::string(deposit > 0 ? "Liegt sicher. Rest bleibt auf dem Konto." : in_cash > 0 ? "Noch nichts zurückgelegt!" : "Erst muss Geld aufs Konto.") + "</span></div><span class=\"pg-sp\"></span><span class=\"pg-mut\" style=\"display:block;\">" +
|
||||
out += "<span class=\"bk-passbook-note\">" + std::string(deposit > 0 ? "Liegt sicher. Rest bleibt auf dem Konto." : in_cash > 0 ? "Noch nichts zurückgelegt!" : "Erst muss Geld aufs Konto.") + "</span></div>";
|
||||
if (!rates.empty()) {
|
||||
out += "<div class=\"ad-memo bk-rates\"><span class=\"ad-memo-tape\"></span><strong>Zinsen zurzeit</strong>";
|
||||
for (const auto &text : rates) out += "<span>" + esc(text) + "</span>";
|
||||
out += "</div>";
|
||||
}
|
||||
out += "<span class=\"pg-sp\"></span><span class=\"pg-mut\" style=\"display:block;\">" +
|
||||
std::string(engine_mode_ ? "Einzahlungen und Abhebungen werden nach Bestätigung im Spielstand verbucht." : "Einzahlungen und Abhebungen werden hier als fiktive Vorschau verbucht.") + "</span><div class=\"pg-row\" style=\"" + pg_css("gap:8px;") + "\">" +
|
||||
calc("Einzahlen", "deposit", "primary block") + calc("Abheben", "withdraw", "block") + "</div></div></div>";
|
||||
} 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<int64_t>() > 0) ++held_papers;
|
||||
page_title_ = "Aktien";
|
||||
page_hint_ = "Depotwert " + bank_money(in_stock);
|
||||
out += "<div class=\"pg-row pg-grow\" style=\"align-items:stretch;\"><div class=\"pg-col pg-grow\" style=\"" + pg_css("gap:10px;") + "\">" + 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") +
|
||||
"<div class=\"pg-panel pg-col pg-grow\" style=\"" + pg_css("gap:0px;padding:4px 14px;") + "\"><div class=\"bk-row head\"><span class=\"bk-name\">WERT</span><span class=\"bk-spark\">30 TAGE</span><span class=\"bk-num\">KURS</span><span class=\"bk-num wide\">ZUM VORTAG</span><span class=\"bk-num\">BESTAND</span></div>";
|
||||
page_hint_ = "Depotwert " + bank_money(in_stock) + " · " + std::to_string(held_papers) + " von " + std::to_string(stock_count) + " Papieren im Bestand";
|
||||
out += "<div class=\"pg-row pg-grow\" style=\"align-items:stretch;\"><div class=\"pg-col pg-grow\" style=\"" + pg_css("gap:10px;") + "\">" + "<div class=\"pg-panel pg-col pg-grow\" style=\"" + pg_css("gap:0px;padding:4px 14px;") + "\"><div class=\"bk-row head\"><span class=\"bk-name\">WERT</span><span class=\"bk-spark\">30 TAGE</span><span class=\"bk-num\">KURS</span><span class=\"bk-num wide\">ZUM VORTAG</span><span class=\"bk-num\">BESTAND</span></div>";
|
||||
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 = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 800 800\"><circle cx=\"400\" cy=\"400\" r=\"300\" fill=\"none\" stroke=\"" + faint + "\" stroke-width=\"110\"/>";
|
||||
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 += "<text x=\"" + scalar(400 + 300 * std::cos(angle)) + "\" y=\"" + scalar(400 + 300 * std::sin(angle) + 14) + "\" text-anchor=\"middle\" fill=\"#ffffff\" font-size=\"40\" font-weight=\"bold\" font-family=\"Arial, Liberation Sans, sans-serif\">" +
|
||||
std::to_string(int(std::lround(double(part.value) * 100 / double(wealth)))) + " %</text>";
|
||||
}
|
||||
if (part.value == wealth) { ring += "<circle cx=\"400\" cy=\"400\" r=\"300\" fill=\"none\" stroke=\"" + std::string(part.colour) + "\" stroke-width=\"110\"/>"; break; }
|
||||
ring += "<circle cx=\"400\" cy=\"400\" r=\"300\" fill=\"none\" stroke=\"" + std::string(part.colour) + "\" stroke-width=\"110\" stroke-dasharray=\"" + scalar(length) + " " + scalar(around - length) + "\" stroke-dashoffset=\"" + scalar(-turned) + "\" transform=\"rotate(-90 400 400)\"/>";
|
||||
turned += length;
|
||||
}
|
||||
ring += "</svg>";
|
||||
out += "<div class=\"pg-row pg-grow\" style=\"align-items:stretch;\"><div class=\"pg-col\" style=\"width:" + pg(590) + ";flex:none;" + pg_css("gap:10px;") + "\">" + banner("bank.scene.overview", 590, 196, "Vermögen", bank_money(wealth), "Konto, Sparbuch, Immobilien und Aktien") +
|
||||
"<div class=\"pg-panel pg-row pg-grow\" style=\"" + pg_css("gap:16px;padding:12px 16px;") + "\"><div class=\"bk-ring\">" + picture(renderer_.diagram("bank-ring-" + theme_, ring, 900), 400, 400) + "</div><div class=\"pg-grow\">";
|
||||
ring += marks + "<text x=\"400\" y=\"372\" text-anchor=\"middle\" fill=\"" + ink + "\" fill-opacity=\".62\" font-size=\"32\" font-weight=\"bold\" font-family=\"Arial, Liberation Sans, sans-serif\">VERMÖGEN</text><text x=\"400\" y=\"436\" text-anchor=\"middle\" fill=\"" + ink +
|
||||
"\" font-size=\"" + std::string(bank_money(wealth).size() > 16 ? "42" : "52") + "\" font-weight=\"bold\" font-family=\"Arial, Liberation Sans, sans-serif\">" + esc(bank_money(wealth)) + "</text></svg>";
|
||||
out += "<div class=\"pg-row pg-grow\" style=\"align-items:stretch;\"><div class=\"pg-col\" style=\"width:" + pg(590) + ";flex:none;" + pg_css("gap:10px;") + "\">" + banner("bank.scene.overview", 590, 170, "Vermögen", bank_money(wealth), "Konto, Sparbuch, Immobilien und Aktien") +
|
||||
"<div class=\"pg-panel pg-row pg-grow\" style=\"align-items:center;" + pg_css("gap:14px;padding:10px 14px;") + "\"><div class=\"bk-ring\">" + picture(renderer_.diagram("bank-ring-" + theme_, ring, 1400), 700, 700) + "</div><div class=\"pg-grow\">";
|
||||
const Part *largest = &parts[0];
|
||||
for (const auto &part : parts) {
|
||||
if (part.value > largest->value) largest = ∂
|
||||
const double width = wealth > 0 ? std::max<int64_t>(0, part.value) * 100.0 / wealth : 0;
|
||||
out += "<div class=\"bk-part\"><div class=\"pg-row\" style=\"" + pg_css("gap:8px;") + "\"><span class=\"bk-chip\" style=\"background-color:" + std::string(part.colour) + ";\"></span><span class=\"pg-grow\">" + part.label + "</span><strong>" +
|
||||
esc(bank_money(std::string(part.label) == "Konto" ? in_cash : part.value)) + "</strong><span class=\"pg-mut bk-share\">" + share(part.value) + "</span></div><div class=\"pg-bar\"><div style=\"width:" + scalar(width) + "%;background-color:" + part.colour + ";\"></div></div></div>";
|
||||
esc(bank_money(std::string(part.label) == "Konto" ? in_cash : part.value)) + "</strong></div><div class=\"pg-bar\"><div style=\"width:" + scalar(width) + "%;background-color:" + part.colour + ";\"></div></div></div>";
|
||||
}
|
||||
out += engine_mode_ ? kv("Kreditlinie", esc(bank_money(summary.at("credit_line").get<int64_t>()))) : kv("Kredit", "−" + esc(bank_money(summary.at("debt").get<int64_t>()))) + kv("Saldo", esc(bank_money(summary.at("net").get<int64_t>())));
|
||||
out += "</div></div><span class=\"pg-mut bk-reading\">";
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user