Modern UI contract: envelope, career and manager ids, session and desktop reads
First engine delivery for the Modern interface handoff (docs/new_ui/integration, issue #15): ModernSession::ui_read answers in the draft envelope with careerId, worldId, stateRevision, date, season, scope and Money in minor units. Careers and human managers get persistent ids (saved in state/modern.json, older saves get them on load). Reads: session and desktop. Engine decisions on the P0 points in docs/new_engine/ui-anbindung.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9061123c7e
commit
3336d01004
9 files changed
+342
-2
No files matched your search
@@ -0,0 +1,49 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
// The engine side of the Modern interface contract (docs/new_ui/integration, draft
|
||||
// "bmh-modern-ui@draft1"; engine decisions in docs/new_engine/ui-anbindung.md).
|
||||
//
|
||||
// A read answers in the contract's envelope:
|
||||
// {messageType: "snapshot", requestId, meta: {contractVersion, careerId, worldId, worldRevision,
|
||||
// stateRevision, projectionRevision, locale, date, season, scope, availability, currency}, data}
|
||||
// or {messageType: "error", requestId, code, message, currentRevision, retryable, stateChanged}.
|
||||
//
|
||||
// Reads never change the game, draw random numbers or move the revision. Money is the
|
||||
// contract's Money {minor: decimal string, currency: "EUR", minorUnits: 2}: the engine keeps
|
||||
// whole euros, converted here exactly once. Revisions are decimal strings.
|
||||
//
|
||||
// Read kinds so far: "session" (the human managers and who is at the desk) and "desktop"
|
||||
// (the desk of the active manager: manager, team, account, next match, menu availability).
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "cli/json.hpp"
|
||||
#include "modern/game/modern_state.hpp"
|
||||
|
||||
namespace bmh::modern {
|
||||
|
||||
// What the session adds to the state: the revision the interface acts on and the manager at
|
||||
// the desk (runtime manager slot).
|
||||
struct UiContext {
|
||||
uint64_t state_revision = 0;
|
||||
int manager = 0;
|
||||
// The desk's next match as the session prepared it (DeskState): the opponent's runtime
|
||||
// team (-1: none, nullopt: not known), the competition label, whether it is away.
|
||||
std::optional<int> next_opponent;
|
||||
std::string next_competition;
|
||||
bool next_away = false;
|
||||
};
|
||||
|
||||
// Gives a career without them its identities: a career id ("career:" + 16 hex digits, drawn
|
||||
// from the system, not from a game generator) and an id per human manager slot
|
||||
// ("manager:<n>", counted per career, never reused). Called after the career start, a join
|
||||
// and loading; changes nothing that is already set.
|
||||
void ensure_ui_identities(ModernState& g);
|
||||
|
||||
// The money of the engine (whole euros) as the contract's Money.
|
||||
cli::Json ui_money(int64_t euros);
|
||||
|
||||
cli::Json ui_read(const ModernState& g, const UiContext& context, const cli::Json& request);
|
||||
|
||||
} // namespace bmh::modern
|
||||
Reference in new issue
Block a user