Bind the transfer market to world-relative Modern data (by Codex)
This commit is contained in:
1 parent
e559e84a69
commit
1e88304019
23 files changed
+1230
-76
No files matched your search
@@ -11,6 +11,7 @@ void App::close_transfer(bool restore) {
|
||||
refresh();
|
||||
}
|
||||
bool App::transfer_action(const std::string &action, Rml::Element *target) {
|
||||
if (engine_mode_) return engine_transfer_action(action,target);
|
||||
if (!action.starts_with("transfer-"))
|
||||
return false;
|
||||
if (menu_ != "transfer" || !world_ || !source_)
|
||||
@@ -392,7 +393,7 @@ bool App::transfer_action(const std::string &action, Rml::Element *target) {
|
||||
return true;
|
||||
}
|
||||
bool App::transfer_event(Rml::Event &event) {
|
||||
if (menu_ != "transfer" || !source_ || amount_ || !popup_.empty() ||
|
||||
if (menu_ != "transfer" || (!engine_mode_ && !source_) || amount_ || !popup_.empty() ||
|
||||
!report_detail_kind_.empty())
|
||||
return false;
|
||||
const auto type = event.GetType();
|
||||
@@ -458,7 +459,7 @@ bool App::transfer_event(Rml::Event &event) {
|
||||
target->HasAttribute("data-criterion")) {
|
||||
const auto field =
|
||||
target->GetAttribute<Rml::String>("data-criterion", "");
|
||||
const int maximum = (field == "age_min" || field == "age_max") ? 40
|
||||
const int maximum = (field == "age_min" || field == "age_max") ? (engine_mode_?47:40)
|
||||
: (field == "foot" || field == "type") ? 3
|
||||
: 100;
|
||||
const int minimum = (field == "age_min" || field == "age_max") ? 16 : 0;
|
||||
@@ -549,7 +550,7 @@ bool App::transfer_event(Rml::Event &event) {
|
||||
offers = true;
|
||||
if (offers) {
|
||||
const auto pool =
|
||||
demo_transfer_view(snap().state, *world_, transfer_ui_club(snap()))
|
||||
transfer_data()
|
||||
.at("market");
|
||||
const int pages = std::max(1, int((pool.size() + 5) / 6));
|
||||
transfer_view_["page"] = (transfer_view_.value("page", 0) + 1) % pages;
|
||||
@@ -576,9 +577,8 @@ bool App::transfer_event(Rml::Event &event) {
|
||||
return false;
|
||||
if (transfer_view_.value("hover", std::string()) != hover) {
|
||||
transfer_view_["hover"] = hover;
|
||||
const auto snapshot = snap();
|
||||
const auto rows = demo_transfer_view(snapshot.state, *world_,
|
||||
transfer_ui_club(snapshot));
|
||||
const auto snapshot = engine_mode_ ? Snapshot{} : snap();
|
||||
const auto rows = transfer_data();
|
||||
auto row = transfer_ui_find(rows.at("market"), hover);
|
||||
if (row.is_null())
|
||||
row = transfer_view_.value("side", std::string()) == "own"
|
||||
@@ -589,19 +589,19 @@ bool App::transfer_event(Rml::Event &event) {
|
||||
transfer_view_.value("market", std::string()));
|
||||
std::string body = "<p>Wähle einen angebotenen Spieler.</p>";
|
||||
if (row.is_object()) {
|
||||
const auto fee = row.at("fee").get<int64_t>(),
|
||||
remaining = snapshot.state.at("cash").get<int64_t>() +
|
||||
const auto fee = row.at("fee").is_number_integer() ? row.at("fee").get<int64_t>() : 0,
|
||||
remaining = (engine_mode_ ? engine_transfer_value_.at("cash").get<int64_t>() : snapshot.state.at("cash").get<int64_t>()) +
|
||||
(row.at("own") == true ? fee : -fee);
|
||||
body = "<p>" + label(world_->find("clubs", row.at("club")), 32) +
|
||||
body = "<p>" + (world_->find("clubs",row.at("club"))?label(world_->find("clubs",row.at("club")),32):esc(row.value("seller_name",std::string("—")))) +
|
||||
"</p><div><section><span>" +
|
||||
std::string(row.at("own") == true ? "Marktwert"
|
||||
: "Geforderte Ablöse") +
|
||||
"</span><strong>" + esc(cash(fee)) +
|
||||
"</span><strong>" + esc(row.at("fee").is_null()?std::string("—"):transfer_money(fee)) +
|
||||
"</strong></section><section><span>Restkapital nach " +
|
||||
std::string(row.at("own") == true ? "Verkauf" : "Kauf") +
|
||||
"</span><strong class=\"" +
|
||||
std::string(remaining < 0 ? "transfer-negative" : "") + "\">" +
|
||||
esc(cash(remaining)) + "</strong></section></div>";
|
||||
money_classes(remaining) + "\">" +
|
||||
esc(row.at("fee").is_null()?std::string("—"):transfer_money(remaining)) + "</strong></section></div>";
|
||||
}
|
||||
if (auto *preview = element("transfer-preview"))
|
||||
preview->SetInnerRML(body);
|
||||
|
||||
Reference in new issue
Block a user