//! Text rendering for the terminal adapter. //! //! This is the TUI's half of the `View` boundary: the GUI renders the same //! data with a painter instead of strings. use crate::client::games::blackjack::BlackjackGame; use crate::client::games::crash::CrashGame; use crate::client::games::roulette::RouletteGame; use crate::client::games::slots::SlotsGame; use crate::client::view::View; /// Render any view to terminal lines. pub fn render_view(view: &View) -> Vec { let rendered = match view { View::Slots(slots) => SlotsGame::render_view(slots), View::Roulette(roulette) => RouletteGame::render_view(roulette), View::Blackjack(blackjack) => BlackjackGame::render_view(blackjack), View::Crash(crash) => CrashGame::render_view(crash), // The terminal adapter keeps its command prompt for these screens. View::Lobby(_) | View::History(_) => String::new(), }; rendered.lines().map(str::to_string).collect() }