" +
esc(bank_hint_.empty() ? "Ein Element in der Bankhalle auswählen." : bank_hint_) + "
";
// Every service of the bank shares one head: the house's name, the service, and tabs that
// lead to the other services without a walk back through the hall.
const std::array, 5> bank_tabs{{{"overview", "Übersicht"}, {"stocks", "Aktien"}, {"properties", "Immobilien"}, {"savings", "Sparbuch"}, {"credit", "Kredit"}}};
std::string service;
for (const auto &[id, label] : bank_tabs) if (bank_view_ == id) service = label;
out += "
Waldpark Bank" +
service + "
";
const auto one = [](double value) {
std::ostringstream text;
text << std::fixed << std::setprecision(1) << value;
auto result = text.str();
std::replace(result.begin(), result.end(), '.', ',');
return result;
};
// what the club owns, by where it lies
const int64_t in_cash = summary.at("cash").get(), in_deposit = summary.at("deposit").get(),
in_property = summary.at("properties").get(), in_stock = summary.at("stocks").get();
const int64_t wealth = std::max(0, in_cash) + in_deposit + in_property + in_stock;
const auto share = [&](int64_t part) { return wealth > 0 ? one(std::max(0, part) * 100.0 / wealth) + " %" : std::string("—"); };
const std::string ink = theme_ == "silver" ? "#233443" : "#e8eef2", faint = theme_ == "silver" ? "#4a433430" : "#dfeaf530",
up = theme_ == "silver" ? "#3f7d63" : "#8fd3ad", down = theme_ == "silver" ? "#a23f45" : "#f0a6a7",
gold = theme_ == "silver" ? "#9a7a3a" : "#d9bd7c", line = theme_ == "silver" ? "#25617a" : "#9ac7d8";
// an engine name arrives in capitals
const auto calm_name = [](std::string name) {
bool first = true;
std::string result;
for (size_t i = 0; i < name.size(); ++i) {
const unsigned char c = static_cast(name[i]);
if (c == 0xc3 && i + 1 < name.size()) { // Ä Ö Ü
unsigned char next = static_cast(name[i + 1]);
if (!first && (next == 0x84 || next == 0x96 || next == 0x9c)) next = static_cast(next + 0x20);
result += name[i]; result += static_cast(next); ++i; first = false;
continue;
}
if (std::isalpha(c)) { result += static_cast(first ? c : std::tolower(c)); first = false; }
else { result += name[i]; if (c == ' ' || c == '-') first = true; }
}
return result;
};
const auto factor = engine_mode_ ? 100 : finance_currency_factor(*world_);
const auto course = [&](int index) {
std::vector history;
const auto &stock = assets.at("stocks")[size_t(index)];
if (engine_mode_) {
for (const auto &value : stock.at("history")) if (value.get() > 0) history.push_back(value.get() / factor);
} else {
const double price = stock.at("price").get() / factor;
for (int i = 0; i < 30; ++i) history.push_back(price * (.85 + .08 * std::sin(i * .6 + index) + i * .003));
}
return history;
};
if (bank_view_ == "savings") {
out += "
" + std::string(engine_mode_ ? "Einzahlungen und Abhebungen werden nach Bestätigung im Spielstand verbucht." : "Einzahlungen und Abhebungen werden hier als fiktive Vorschau verbucht.") + "
Preise im Vergleich · " + number(houses) + " im Bestand
";
{
int64_t dearest = 1;
for (const auto &item : assets.at("properties")) dearest = std::max(dearest, item.at("price").get());
for (int i = 0; i < property_count; ++i) {
const auto &item = assets.at("properties")[size_t(i)];
out += "
";
for (const auto *label : {"Wert", "30 Tage", "Kurs", "zum Vortag", "Bestand"}) out += "
" + std::string(label) + "
";
out += "
";
for (int i = 0; i < stock_count; ++i) {
const auto &s = assets.at("stocks")[size_t(i)];
const auto history = course(i);
std::string spark = "";
out += "
";
// the chosen stock: its course with a five-day average, its range, and what the numbers say
const auto &chosen = assets.at("stocks")[size_t(bank_stock_)];
const auto history = course(bank_stock_);
const double price = chosen.at("price").get() / factor;
out += "
Gleichmäßige monatliche Tilgung · Restschuld ohne Zinsen
"
"
Fiktiver Kredit. Im POC erfolgen keine Zins- oder Ratenbuchungen.
" + actions("Aufnehmen", "loan", "Tilgen", "repay");
} else if (bank_view_ == "overview") {
// where the money lies: a ring by share, the four places with their sums, and a reading of it
struct Part { const char *label; int64_t value; const char *colour; };
const std::array parts{{{"Konto", std::max(0, in_cash), "#2f6f8f"}, {"Sparbuch", in_deposit, "#c9a24a"},
{"Immobilien", in_property, "#6f8a52"}, {"Aktien", in_stock, "#a8574f"}}};
const double around = 2 * 3.14159265358979 * 300;
std::string ring = "";
out += "
";
if (wealth > 0) {
const int64_t invested = in_deposit + in_property + in_stock;
out += "Größter Posten: " + std::string(largest->label) + " mit " + share(largest->value) + " des Vermögens. " +
(invested > 0 ? "Angelegt in Sparbuch, Immobilien und Aktien sind " + share(invested) + "."
: std::string("Bisher ist nichts angelegt: Das ganze Vermögen liegt auf dem Konto."));
} else out += "Es ist kein Vermögen vorhanden.";
out += "
";
// the market at a glance: every stock's change over its recorded days
std::vector> market;
double widest = 1;
for (int i = 0; i < stock_count; ++i) {
const auto history = course(i);
if (history.size() < 2 || history.front() <= 0) continue;
const double change = (history.back() - history.front()) * 100.0 / history.front();
market.emplace_back(assets.at("stocks")[size_t(i)].at("name").get(), change);
widest = std::max(widest, std::abs(change));
}
if (!market.empty()) {
out += "
Aktienmarkt · Veränderung über die aufgezeichneten Tage
";
for (const auto &[name, change] : market) {
const double height = std::abs(change) / widest * 120;
out += "
" + std::string(engine_mode_ ? "Bestände und Kurse aus dem Spielstand." : "Erfundene Bestände · Änderungen betreffen ausschließlich die Bankvorschau.") + "