Modern press journal: promotion, advertising, credit, stadium
The season change notes a human club's promotion or relegation; the confirmed commands note an advertising contract, a loan taken or paid off and a planned stand expansion. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
651d262546
commit
055b48697e
5 files changed
+60
-3
No files matched your search
@@ -9994,6 +9994,11 @@ cli::Json ModernSession::ui_command(const cli::Json& request, uint64_t& revision
|
||||
block_step(ui::StadiumRequestKind::expansion_confirm, slot, total, features);
|
||||
if (ok && stadium_.block_expansion && stadium_.block_expansion->tip)
|
||||
block_step(ui::StadiumRequestKind::expansion_answer_tip, slot, total, features, with_tip);
|
||||
if (ok)
|
||||
modern::note_press(g_, "stadium.expansion_planned", modern::ui_team_id(g_, team),
|
||||
cli::Json::Object{{"team", modern::press_team(g_, team)},
|
||||
{"stadium", modern::press_team(g_, team)},
|
||||
{"block", std::string("block:") + char('a' + slot)}, {"seats", int64_t(total)}});
|
||||
}
|
||||
} else {
|
||||
return refuse("stale_quote", "Es liegt kein Stadionangebot vor.");
|
||||
@@ -10073,6 +10078,7 @@ cli::Json ModernSession::ui_command(const cli::Json& request, uint64_t& revision
|
||||
if (team < 0 || team >= league_clubs()) return refuse("no_club", "Am Schreibtisch des Bundestrainers gibt es keine Werbung.");
|
||||
const ui::AdvertisingState a = ui::advertising_from_game(g_, manager, revision);
|
||||
ui::AdvertisingRequest r;
|
||||
cli::Json accepted_ad; // the press facts of an accepted offer
|
||||
r.request_id = last_advertising_request_id_ + 1;
|
||||
r.manager_slot = manager, r.runtime_club = team, r.revision = revision;
|
||||
if (kind == "advertising.accept") {
|
||||
@@ -10086,6 +10092,12 @@ cli::Json ModernSession::ui_command(const cli::Json& request, uint64_t& revision
|
||||
r.kind = ui::AdvertisingActionKind::accept_offer;
|
||||
r.offer.manager = manager, r.offer.display_slot = display, r.offer.contract_slot = list.contract_slot;
|
||||
r.offer.expected_contract = list.contract_bytes, r.offer.raw_slot = raw, r.offer.expected_offer = offer->bytes;
|
||||
const auto& names = display == 15 ? a.television_sponsor_names : a.board_sponsor_names;
|
||||
accepted_ad = cli::Json::Object{
|
||||
{"team", modern::press_team(g_, team)},
|
||||
{"company", offer->sponsor_id < names.size() ? cli::Json(cli::Json::Object{{"id", "sponsor:" + std::to_string(offer->sponsor_id)}, {"name", names[offer->sponsor_id]}}) : cli::Json(nullptr)},
|
||||
{"amount", modern::ui_money(offer->monthly_amount)}, {"months", int(offer->months)},
|
||||
{"place", display == 15 ? "tv" : display == 14 ? "shirt" : "boards"}};
|
||||
} else {
|
||||
const std::string id = ui_text(*payload, "budgetId");
|
||||
const int index = id == "budget:merchandise" ? 0 : id == "budget:press" ? 1 : id == "budget:fans" ? 2 : -1;
|
||||
@@ -10100,6 +10112,7 @@ cli::Json ModernSession::ui_command(const cli::Json& request, uint64_t& revision
|
||||
r.spending.expected_amount = view.current_amount, r.spending.expected_delivery_weeks = view.delivery_weeks;
|
||||
}
|
||||
if (!dispatch_advertising(r, revision, error)) { restore(); return refuse("advertising_refused", error); }
|
||||
if (accepted_ad.object()) modern::note_press(g_, "advertising.signed", modern::ui_team_id(g_, team), std::move(accepted_ad));
|
||||
revision = previous + 1;
|
||||
answer = modern::ui_command_result(request_id, previous, revision, {"advertising", "desktop", "bank"},
|
||||
kind == "advertising.accept" ? "Werbevertrag abgeschlossen." : "Budget gesetzt.");
|
||||
@@ -10406,6 +10419,8 @@ cli::Json ModernSession::ui_command(const cli::Json& request, uint64_t& revision
|
||||
const std::string action = ui_text(*payload, "action");
|
||||
ui::BankRequest r;
|
||||
r.manager_slot = manager, r.runtime_club = g_.manager_teams[size_t(manager)], r.revision = revision;
|
||||
int credit_lender = -1; // a credit booking: its lender (0 the bank), for the press
|
||||
std::array<uint32_t, 6> credit_before{}; // and the loan before it
|
||||
if (action == "deposit" || action == "withdraw") {
|
||||
const cli::Json* amount = ui_field(*payload, "amount");
|
||||
const std::string minor = amount ? ui_text(*amount, "minor") : std::string{};
|
||||
@@ -10437,7 +10452,9 @@ cli::Json ModernSession::ui_command(const cli::Json& request, uint64_t& revision
|
||||
if (!credit.available) return refuse("credit_unavailable", "Kein Kredit möglich.");
|
||||
r.kind = ui::BankRequestKind::bank_credit;
|
||||
r.expected_credit = credit.saved;
|
||||
credit_before = credit.saved;
|
||||
r.credit_counterparty = counterparty;
|
||||
credit_lender = counterparty;
|
||||
const cli::Json* fees = ui_field(*payload, "acceptFees");
|
||||
r.accept_credit_fees = fees && std::holds_alternative<bool>(fees->value) && std::get<bool>(fees->value);
|
||||
if (const cli::Json* edits = ui_field(*payload, "edits"); edits && edits->array())
|
||||
@@ -10451,6 +10468,19 @@ cli::Json ModernSession::ui_command(const cli::Json& request, uint64_t& revision
|
||||
return refuse("invalid_payload", "action ist deposit, withdraw, buy, sell oder credit.");
|
||||
}
|
||||
if (!dispatch_bank(r, revision, error)) { restore(); return refuse(error, "Bankauftrag abgelehnt: " + error); }
|
||||
if (credit_lender >= 0) {
|
||||
// the press: a loan taken (principal now) or paid off (none left)
|
||||
const int team = g_.manager_teams[size_t(manager)];
|
||||
const BankCreditContext now = modern::bank_credit_context(g_, exe_, manager, credit_lender);
|
||||
const cli::Json lender = credit_lender == 0 ? cli::Json(cli::Json::Object{{"id", "bank"}, {"name", "Bank"}})
|
||||
: cli::Json(cli::Json::Object{{"id", modern::ui_manager_id(g_, credit_lender - 1)}, {"name", nullptr}});
|
||||
if (now.saved[0] > 0 && now.saved != credit_before)
|
||||
modern::note_press(g_, "finance.loan_approved", modern::ui_team_id(g_, team),
|
||||
cli::Json::Object{{"team", modern::press_team(g_, team)}, {"amount", modern::ui_money(now.saved[0])}, {"bank", lender}});
|
||||
else if (now.saved[0] == 0 && credit_before[0] > 0)
|
||||
modern::note_press(g_, "finance.loan_repaid", modern::ui_team_id(g_, team),
|
||||
cli::Json::Object{{"team", modern::press_team(g_, team)}, {"amount", modern::ui_money(credit_before[0])}, {"bank", lender}});
|
||||
}
|
||||
revision = previous + 1;
|
||||
answer = modern::ui_command_result(request_id, previous, revision, {"bank", "desktop"}, "Bankauftrag ausgeführt.");
|
||||
} else if (kind == "lineup.commit") {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <variant>
|
||||
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "game/schedule.hpp"
|
||||
#include "game/state.hpp"
|
||||
#include "modern/content/ui_contract.hpp"
|
||||
#include "modern/game/almanac.hpp"
|
||||
@@ -148,6 +149,23 @@ void journal_advance(ModernState& g, const ModernState& before) {
|
||||
else if (b.paid > 0) note_press(g, "toto.loss", id, O{{"team", press_team(g, team)}, {"amount", ui_money(b.paid)}});
|
||||
}
|
||||
// a new season
|
||||
// promotion and relegation: a human club's league at the new season (a lower index is the
|
||||
// higher league)
|
||||
const auto league_entity = [&](int league) {
|
||||
const std::string id = size_t(league) < g.world_league_id.size() && !g.world_league_id[size_t(league)].empty()
|
||||
? g.world_league_id[size_t(league)] : "league:" + std::to_string(league);
|
||||
const std::string name = size_t(league) < g.world_league_name.size() && !g.world_league_name[size_t(league)].empty()
|
||||
? g.world_league_name[size_t(league)] : "Liga " + std::to_string(league + 1);
|
||||
return J(O{{"id", id}, {"name", name}, {"kind", "league"}, {"season", season_text(g)}});
|
||||
};
|
||||
if (g.season != before.season)
|
||||
for (const std::string& club : clubs) {
|
||||
const int was_team = team_of_identity(before, club), team = team_of_identity(g, club);
|
||||
const int from = team_league(was_team), to = team_league(team);
|
||||
if (from == to || from >= kLeagueCount || to >= kLeagueCount) continue;
|
||||
note_press(g, to < from ? "league.promoted" : "league.relegated", ui_team_id(g, team),
|
||||
O{{"team", press_team(g, team)}, {"competition", league_entity(to)}, {"from", league_entity(from)}, {"season", season_text(g)}});
|
||||
}
|
||||
if (g.season != before.season)
|
||||
for (const std::string& club : human_clubs(g)) {
|
||||
const int team = team_of_identity(g, club);
|
||||
|
||||
@@ -12,8 +12,11 @@
|
||||
// - a kickoff (session.advance, also live): the squads of the human clubs before and after
|
||||
// give transfer.signed (with fromClub, or transfer.free from the pool), transfer.sold
|
||||
// (toClub) and contract.ended (to the pool); a new toto settlement gives toto.win /
|
||||
// toto.loss; a season change career.season_finished and career.season_started;
|
||||
// - confirmed commands: contract.extended (contract.offer), career.manager_resigned.
|
||||
// toto.loss; a season change career.season_finished and career.season_started, and a human
|
||||
// club in another league league.promoted / league.relegated;
|
||||
// - confirmed commands: contract.extended (contract.offer), advertising.signed
|
||||
// (advertising.accept), finance.loan_approved / finance.loan_repaid (bank.commit credit),
|
||||
// stadium.expansion_planned (a stand block, stadium.commit), career.manager_resigned.
|
||||
// Fees are not known from the squads: the transfer events carry no fee (the renderer's
|
||||
// fee-undisclosed variants).
|
||||
|
||||
|
||||
Reference in new issue
Block a user