jong/src/tui/render/hand.rs

27 lines
669 B
Rust
Raw Normal View History

2026-01-11 22:32:30 -08:00
use bevy::prelude::*;
use ratatui::widgets::Paragraph;
use jong::game::player::HandTiles;
use jong::tiles::Tile;
use crate::tui::render::tiles;
#[derive(Component)]
pub(crate) struct RenderedHand<'a>(pub(crate) Vec<Paragraph<'a>>);
pub(crate) fn render_changed_hand(
hand: Single<&HandTiles, Changed<HandTiles>>,
// hand_tiles: Query<&HandTiles, With<Hand>>,
tiles: Query<&Tile>,
mut target: Single<&'static mut RenderedHand>,
) -> Result {
let hand_tiles = hand
.iter()
.map(|inhand| -> Result<_> { Ok(tiles.get(inhand).map(tiles::draw_tile)?) })
.collect::<Result<Vec<_>>>()?;
target.0 = hand_tiles;
Ok(())
}