pub trait PrintableGame: Game {
// Required methods
fn draw_viewport<B: Backend>(
&self,
view: &Self::View,
term: &mut Terminal<B>,
area: Rect,
);
fn get_stats(&self, view: &Self::View) -> Vec<(String, String)>;
fn format_action(&self, action: &Self::Action) -> String;
}Expand description
A Game that knows how to render itself, for SimulationRunner.
Every method takes &self (the rules) and an explicit view: what a
player or spectator is allowed to see (Game::view), never the raw
Self::State. Games with no hidden information can have View be a
clone of State (as the perfect-information examples in this workspace
already do); games with hidden hands or decks get that redaction for
free, since SimulationRunner always renders from one fixed seat’s
perspective (see Simulator::primary_human) rather than the full
state.
Required Methods§
Sourcefn draw_viewport<B: Backend>(
&self,
view: &Self::View,
term: &mut Terminal<B>,
area: Rect,
)
fn draw_viewport<B: Backend>( &self, view: &Self::View, term: &mut Terminal<B>, area: Rect, )
Draws the board (map, cards, whatever the game is) into area.
Implementations should stay within area; the rest of the screen is
reserved for the dashboard.
Sourcefn get_stats(&self, view: &Self::View) -> Vec<(String, String)>
fn get_stats(&self, view: &Self::View) -> Vec<(String, String)>
Key/value pairs summarizing view (scores, resources, hand sizes) for
the stats panel, in display order.
Sourcefn format_action(&self, action: &Self::Action) -> String
fn format_action(&self, action: &Self::Action) -> String
Renders action as one line of menu text for the action-select panel.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.