summaryrefslogtreecommitdiffstats
path: root/src/client/tui.rs
blob: 9853edf3278d9daeb2fd853451cd3327c43e4897 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//! 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<String> {
    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()
}