35 lines
1.1 KiB
Rust
35 lines
1.1 KiB
Rust
|
|
use bevy::prelude::*;
|
||
|
|
use ratatui::widgets::Paragraph;
|
||
|
|
|
||
|
|
use jong::tile::Tile;
|
||
|
|
|
||
|
|
#[derive(Component)]
|
||
|
|
pub(crate) struct RenderedTile(pub(crate) Paragraph<'static>);
|
||
|
|
|
||
|
|
pub(crate) fn draw_tile(tile: &Tile) -> Paragraph<'static> {
|
||
|
|
use ratatui::prelude::*;
|
||
|
|
|
||
|
|
let block = ratatui::widgets::Block::bordered();
|
||
|
|
|
||
|
|
Paragraph::new(match &tile.suit {
|
||
|
|
jong::tile::Suit::Pin(rank) => format!("{}\np", rank.0),
|
||
|
|
jong::tile::Suit::Sou(rank) => format!("{}\ns", rank.0),
|
||
|
|
jong::tile::Suit::Man(rank) => format!("{}\nm", rank.0),
|
||
|
|
jong::tile::Suit::Wind(wind) => (match wind {
|
||
|
|
jong::tile::Wind::Ton => "e\nw",
|
||
|
|
jong::tile::Wind::Nan => "s\nw",
|
||
|
|
jong::tile::Wind::Shaa => "w\nw",
|
||
|
|
jong::tile::Wind::Pei => "n\nw",
|
||
|
|
})
|
||
|
|
.into(),
|
||
|
|
jong::tile::Suit::Dragon(dragon) => (match dragon {
|
||
|
|
jong::tile::Dragon::Haku => "w\nd",
|
||
|
|
jong::tile::Dragon::Hatsu => "g\nd",
|
||
|
|
jong::tile::Dragon::Chun => "r\nd",
|
||
|
|
})
|
||
|
|
.into(),
|
||
|
|
})
|
||
|
|
.block(block)
|
||
|
|
.centered()
|
||
|
|
}
|