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
@@ -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