Modern UI contract: stadium read and ticket.commit
The stadium read lists the periphery (the traffic access with its stage), the eight facilities with their level, the eight stand blocks and the ticket price, with the original names. ticket.commit sets the admission price. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4372e6b78a
commit
6386c891b5
4 files changed
+77
-2
No files matched your search
@@ -8824,7 +8824,7 @@ cli::Json ModernSession::ui_read(const cli::Json& request, uint64_t revision) co
|
||||
const int manager = context.manager;
|
||||
if (manager < 0 || size_t(manager) >= g_.manager_teams.size() ||
|
||||
(kind != "lineup" && kind != "tactics" && kind != "training" && kind != "bank" && kind != "contracts" &&
|
||||
kind != "advertising"))
|
||||
kind != "advertising" && kind != "stadium"))
|
||||
return modern::ui_read(g_, context, request);
|
||||
if (const std::string wanted = ui_text(request, "managerId"); !wanted.empty() && wanted != modern::ui_manager_id(g_, manager))
|
||||
return modern::ui_error(request_id, "manager_not_active", "Dieser Manager sitzt nicht am Schreibtisch.", revision, false);
|
||||
@@ -8854,6 +8854,47 @@ cli::Json ModernSession::ui_read(const cli::Json& request, uint64_t revision) co
|
||||
{"rows", std::move(rows)}, {"positions", std::move(positions)}, {"depthMax", 19}, {"laneMax", 8},
|
||||
{"manual", g_.manager_options.size() > size_t(manager) * 5 && g_.manager_options[size_t(manager) * 5] == 0}});
|
||||
}
|
||||
if (kind == "stadium") {
|
||||
// the periphery (14 objects; the traffic access has three stages), the eight facilities with
|
||||
// their level, the eight stand blocks (capacity in thousands, seats, roof) and the ticket price;
|
||||
// building prices follow with the stadium quotes (they carry the day's construction percent)
|
||||
ui::StadiumState st;
|
||||
ui::StadiumDataProjection data;
|
||||
try {
|
||||
st = ui::stadium_from_game(g_, exe_, revision);
|
||||
data = ui::stadium_data_from_game(g_, exe_, manager, 0x40);
|
||||
} catch (const std::exception&) {
|
||||
return modern::ui_error(request_id, "stadium_unavailable", "Das Stadion ist hier nicht verfügbar.", revision, false);
|
||||
}
|
||||
const auto text = [&](size_t id) { return g_.texts && id < g_.texts->strings.size() ? ui::original_to_utf8(g_.texts->strings[id]) : std::string{}; };
|
||||
A periphery, facilities, blocks;
|
||||
for (size_t o = 0; o < 14; ++o) {
|
||||
const int level = st.level[o];
|
||||
O row{{"id", "periphery:" + std::to_string(o)}, {"name", text(720 + o)}, {"constructionDays", int(st.days[o])}};
|
||||
if (o == 0) row["stage"] = level == 0 ? 0 : (level - 1) / 85 + 1, row["maxStage"] = 3;
|
||||
else row["built"] = level != 0;
|
||||
periphery.push_back(std::move(row));
|
||||
}
|
||||
static constexpr const char* kFacilities[8] = {"floodlights", "scoreboard", "pitch_heating", "vip_lounge", "pitch", "comfort", "condition", "safety"};
|
||||
for (size_t i = 0; i < 8; ++i) {
|
||||
const auto& f = st.investments[i];
|
||||
facilities.push_back(O{{"id", std::string("facility:") + kFacilities[i]}, {"name", text(734 + i)},
|
||||
{"level", int(f.current_level)}, {"maxLevel", i == 2 || i == 3 ? 2 : 4},
|
||||
{"constructionWeeks", int(f.construction_weeks)}, {"upgradeAvailable", f.available}});
|
||||
}
|
||||
for (size_t b = 0; b < st.blocks.size(); ++b) {
|
||||
const auto& k = st.blocks[b];
|
||||
blocks.push_back(O{{"id", "block:" + std::string(1, char('a' + b))}, {"name", text(742 + b)},
|
||||
{"places", int64_t(k.capacity_level) * 1000},
|
||||
{"maxPlaces", int64_t(exe_.u8(::bmh::layout::CareerSession_Invalid_RuntimeField + uint32_t(b))) * 1000},
|
||||
{"seats", (k.flags & 1) != 0}, {"roof", (k.flags & 2) != 0},
|
||||
{"constructionWeeks", int(k.construction_weeks)}, {"placesAfterConstruction", int64_t(k.capacity) * 1000}});
|
||||
}
|
||||
return modern::ui_snapshot(g_, context, request_id,
|
||||
O{{"kind", "stadium"}, {"teamId", modern::ui_team_id(g_, team)}, {"periphery", std::move(periphery)},
|
||||
{"facilities", std::move(facilities)}, {"blocks", std::move(blocks)},
|
||||
{"ticketPrice", modern::ui_money(data.ticket_price)}, {"ticketPriceRange", O{{"min", modern::ui_money(8)}, {"max", modern::ui_money(25)}}}});
|
||||
}
|
||||
if (kind == "advertising") {
|
||||
// the 14 boards, the shirt and the TV rights with their contract, the open offers per place,
|
||||
// the three budgets and the original's finance preview
|
||||
@@ -9347,6 +9388,19 @@ cli::Json ModernSession::ui_command(const cli::Json& request, uint64_t& revision
|
||||
revision = previous + 1;
|
||||
answer = modern::ui_command_result(request_id, previous, revision, {"advertising", "desktop", "bank"},
|
||||
kind == "advertising.accept" ? "Werbevertrag abgeschlossen." : "Budget gesetzt.");
|
||||
} else if (kind == "ticket.commit") {
|
||||
// payload {price: Money}: the admission price, 8 to 25 euros
|
||||
const cli::Json* price = ui_field(*payload, "price");
|
||||
int64_t cents = -1;
|
||||
try { cents = price ? std::stoll(ui_text(*price, "minor")) : -1; } catch (const std::exception&) { cents = -1; }
|
||||
if (cents < 800 || cents > 2500 || cents % 100) return refuse("invalid_amount", "Eintritt 8 bis 25 Euro in ganzen Euro.");
|
||||
TicketPriceRequest r;
|
||||
r.identity.manager_slot = manager, r.identity.runtime_club = g_.manager_teams[size_t(manager)], r.identity.revision = revision;
|
||||
r.identity.stable_club_identity = int(g_.club_ids.at(size_t(r.identity.runtime_club)));
|
||||
r.price = int(cents / 100);
|
||||
if (!dispatch_ticket_price(r, revision, error)) { restore(); return refuse("ticket_refused", error); }
|
||||
if (revision != previous) revision = previous + 1;
|
||||
answer = modern::ui_command_result(request_id, previous, revision, {"stadium"}, "Eintrittspreis gesetzt.");
|
||||
} else if (kind == "bank.commit") {
|
||||
// payload {action: deposit|withdraw, amount: Money} or {action: buy|sell, assetId: stock:<n>|fund:<n>, count}
|
||||
const std::string action = ui_text(*payload, "action");
|
||||
|
||||
Reference in new issue
Block a user