Modern UI contract: session.advance
The desk's kickoff as a command: the calendar runs to the next human desk, the season end desk or the end of the career (matches without live view for now). A missing desk decision or a failed step answers decision_pending or advance_failed and leaves the state as it was. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a1590a34ef
commit
ae817c6d6d
3 files changed
+37
No files matched your search
@@ -46,6 +46,7 @@ Fehler: `unknown_read`, `manager_not_active`, `no_active_manager`, `unknown_team
|
||||
| Command | payload | Wirkung |
|
||||
|---|---|---|
|
||||
| `camp.book` | `campId`, optional `focus {condition, technique, play}` (0–15; Erholung folgt) | setzt die Schwerpunkte und bucht das Lager wie der Schreibtisch; Fehler `unknown_camp`, `invalid_focus`, `booked_this_week`, `visit_limit`, `insufficient_funds` |
|
||||
| `session.advance` | `{}` | der Anstoß am Schreibtisch: der Kalender läuft bis zum nächsten Schreibtisch eines Menschen, zum Saisonende oder zum Karriereende (Spiele noch ohne Live-Ansicht); `outcome` `career_ended` am Ende; Fehler `decision_pending` (eine Entscheidung am Schreibtisch fehlt, z. B. ein auslaufender Vertrag), `advance_failed` |
|
||||
| `bank.commit` | `action` `deposit`/`withdraw` mit `amount` (`Money`, ganze Euro) oder `buy`/`sell` mit `assetId` (`stock:<n>`, `fund:<n>`) und `count` | wie die Bank am Schreibtisch; Fehler `invalid_amount`, `amount_unavailable`, `invalid_share_count`, `insufficient_funds`, `investment_limit`, `invalid_fund_count` u. a. |
|
||||
| `lineup.commit` | `order`: Spieler-IDs in der gewünschten Reihenfolge | öffnet die Aufstellung wie am Schreibtisch und tauscht die Zeilen; Fehler `unknown_player`, `lineup_refused` (z. B. Verletzte, Ausländerregel) |
|
||||
| `tactics.commit` | `values`: die acht Werte | jede geänderte Einstellung über die Prüfung der Taktiktafel (eine gesetzte Grundausrichtung beendet die Steuerung durch den Assistenten); Fehler `invalid_tactic` |
|
||||
|
||||
@@ -9045,6 +9045,29 @@ cli::Json ModernSession::ui_command(const cli::Json& request, uint64_t& revision
|
||||
if (!ok) { restore(); return refuse(error.empty() ? "invalid_training" : error, "Training nicht übernommen: " + error); }
|
||||
if (revision != previous) revision = previous + 1;
|
||||
answer = modern::ui_command_result(request_id, previous, revision, {"training"}, "Training übernommen.");
|
||||
} else if (kind == "session.advance") {
|
||||
// payload {}: the kickoff of the desk - the calendar runs (matches without live view) to the
|
||||
// next desk of a human manager, the season end desk or the end of the career
|
||||
ui::DeskRequest kickoff;
|
||||
kickoff.kind = ui::DeskRequestKind::advance_turn;
|
||||
kickoff.manager_slot = manager;
|
||||
kickoff.revision = revision;
|
||||
const TurnAdvanceResult r = dispatch_kickoff(kickoff, revision, error);
|
||||
if (r.kind == TurnDeskKind::Failed || r.kind == TurnDeskKind::WaitingAtDesk) {
|
||||
restore();
|
||||
const std::string reason = r.reason.empty() ? error : r.reason;
|
||||
return refuse(r.kind == TurnDeskKind::WaitingAtDesk ? "decision_pending" : "advance_failed",
|
||||
"Weiter nicht möglich: " + reason);
|
||||
}
|
||||
modern::ensure_ui_identities(g_);
|
||||
revision = previous + 1;
|
||||
const char* what = r.kind == TurnDeskKind::SeasonEndDesk ? "Saisonende." : r.kind == TurnDeskKind::CareerComplete
|
||||
? "Die Karriere ist zu Ende." : "Weiter zum nächsten Termin.";
|
||||
answer = modern::ui_command_result(request_id, previous, revision,
|
||||
{"session", "desktop", "squad", "lineup", "tactics", "training", "camps", "bank",
|
||||
"statistics", "almanac"}, what);
|
||||
if (r.kind == TurnDeskKind::CareerComplete)
|
||||
std::get<cli::Json::Object>(answer.value)["outcome"] = "career_ended";
|
||||
} 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");
|
||||
|
||||
@@ -235,6 +235,19 @@ int main(int argc, char** argv) {
|
||||
check(s(at(refused, "messageType")) == "error" && modern::save_stream(session.state()) == kept && rev == before_bank + 2,
|
||||
"withdrawal above the deposit refused without change");
|
||||
}
|
||||
// session.advance: three kickoffs, each one revision, the date moves on
|
||||
{
|
||||
const std::string date_before = s(at(at(session.ui_read(O{{"kind", "desktop"}}, rev), "meta"), "date"));
|
||||
for (int k = 0; k < 3; ++k) {
|
||||
const uint64_t before = rev;
|
||||
const J done = session.ui_command(cmd("request:a" + std::to_string(k), "session.advance", O{}), rev);
|
||||
if (s(at(done, "messageType")) != "command_result")
|
||||
std::fprintf(stderr, "advance: %s\n", cli::dump_json(done).c_str());
|
||||
check(s(at(done, "messageType")) == "command_result" && rev == before + 1, "advance accepted");
|
||||
}
|
||||
const std::string date_after = s(at(at(session.ui_read(O{{"kind", "desktop"}}, rev), "meta"), "date"));
|
||||
check(date_after > date_before, "the date moved on");
|
||||
}
|
||||
} catch (const std::exception& ex) {
|
||||
std::fprintf(stderr, "FAIL: %s\n", ex.what());
|
||||
return 1;
|
||||
|
||||
Reference in new issue
Block a user