" + picture(renderer_.diagram("assembly-dial-" + theme_, dial, 1280), 640, 358) +
"
AbwahlBestätigung
" +
"
" + assembly_group("Sportliche Leitung", vote.value("sport", 0)) + assembly_group("Kassenprüfer", vote.value("finance", 0)) +
assembly_group("Fans", vote.value("supporters", 0)) + "
" + std::to_string(yes) + " % Ja" +
std::to_string(100 - yes) + " % Nein
" + esc(verdict) + "
";
}
// The needle swings while the votes are counted and comes to rest on the result. It moves from
// the middle towards the result within a second and a half; the swing around it starts at a
// good fifth of the dial and dies away, so a clear result never looks like its opposite.
void App::engine_assembly_tick() {
if (!engine_assembly_started_) return;
if (popup_.empty()) { engine_assembly_started_ = 0; return; }
auto *needle = element("assembly-needle");
if (!needle) return; // the note is drawn with this frame
constexpr double duration = 7.5;
const double t = double(SDL_GetTicks64() - engine_assembly_started_) / 1000.0;
const double target = std::clamp(engine_assembly_target_, 0, 100);
double shown = target;
if (t < duration) {
const double x = std::min(t / 1.5, 1.0), approach = x * x * (3 - 2 * x);
const double swing = 22.0 * std::pow(1.0 - t / duration, 1.4);
const double phase = double(engine_assembly_started_ % 6283) / 1000.0;
const double wave = 0.55 * std::sin(t * 4.3 + phase) + 0.3 * std::sin(t * 7.9 + phase * 2.1) + 0.25 * std::sin(t * 2.1 + phase * 0.7);
shown = std::clamp(50 + (target - 50) * approach + swing * wave, 0.0, 100.0);
}
needle->SetProperty("transform", "rotate(" + scalar((shown - 50) * 1.8) + "deg)");
if (t >= duration) {
if (auto *result = element("assembly-result")) result->SetProperty("visibility", "visible");
engine_assembly_started_ = 0;
}
}
// The clubs that want the manager: crest, league, the strength of their eleven beside his own,
// and the cash they give him to start with.
void App::engine_assembly_clubs(bool forced) {
engine_assembly_forced_ = forced;
const Json offers = engine_assembly_.value("offers", Json::array());
const Json own = engine_assembly_.value("club", Json::object());
std::string body = "";
for (const auto &offer : offers) {
const std::string id = offer.value("teamId", std::string());
const auto *club = world_->find("clubs", id);
const std::string name = club ? world_->name(*club) : offer.value("name", std::string("Ein Verein"));
body += "
" + (club ? crest(club, 72) : std::string()) + "" + esc(name) + "" + esc(offer.value("league", std::string())) +
(offer.contains("position") && offer.at("position").is_number_integer() ? " · Platz " + std::to_string(offer.at("position").get()) : std::string()) + " · Stärke " + std::to_string(offer.value("strength", 0)) +
" · Startkapital " + esc(offer.contains("cash") ? engine_price(offer.at("cash")) : std::string("—")) + "
" +
pg_button("assembly-club", "Übernehmen", "primary", "id=\"assembly-club-" + esc(id) + "\" data-id=\"" + esc(id) + "\"") + "
";
}
body += "
";
const std::string strength = own.contains("strength") ? " Deine Elf hat die Stärke " + std::to_string(own.value("strength", 0)) + "." : std::string();
message(offers.empty() ? "Zurzeit interessiert sich kein Verein für dich."
: forced ? "Diese Vereine wollen dich verpflichten. Einen davon musst du übernehmen, bevor die neue Saison beginnt." + strength
: "Diese Vereine wollen dich verpflichten. Die Liste wechselt alle zwei Wochen." + strength);
popup_title_ = "Interessierte Vereine";
popup_close_ = forced ? "Zum Schreibtisch" : "Abbrechen";
popup_body_ = body;
}
// A club of the list was chosen: asked once more, because nothing of the old club comes along.
void App::engine_assembly_choose(const std::string &team) {
const auto *club = world_->find("clubs", team);
const std::string name = club ? world_->name(*club) : std::string("diesem Verein");
const bool forced = engine_assembly_forced_;
confirmation("Wirklich zu " + name + " wechseln? Dein Konto, deine Aktien, Fonds und Kredite bleiben zurück; beim neuen Verein beginnst du mit dessen Startkapital und einem neuen Vertragswerk.", [this, team, forced] {
if (forced) {
engine_advance_payload_["assembly"] = {{"seen", true}, {"teamId", team}};
engine_kickoff();
return;
}
try {
engine_finance_submit(engine_club_change_command(engine_data_, team, editor::new_id("request:ui-")));
} catch (const std::exception &e) { message(e.what()); }
});
popup_title_ = "Vereinswechsel";
popup_accept_ = "Wechseln";
}