render hand at index 0

This commit is contained in:
Tao Tien 2026-01-12 21:57:08 -08:00
parent a6079103a4
commit f4c4339204
7 changed files with 56 additions and 59 deletions

View file

@ -7,44 +7,26 @@ use jong::tiles::Tile;
use crate::tui::render::tiles;
#[derive(Resource, Default)]
pub(crate) struct RenderedHand(pub(crate) Vec<Paragraph<'static>>);
pub(crate) struct RenderedHand(pub(crate) Vec<Vec<Paragraph<'static>>>);
pub(crate) fn render_changed_hand(
hand: Single<&HandTiles, Changed<HandTiles>>,
hands: Populated<&Children, Changed<HandTiles>>,
tiles: Populated<&Tile>,
mut target: ResMut<RenderedHand>,
) -> Result {
let mut rendered = vec![];
for hand in hands {
let hand_tiles = hand
let tiles = hand
.iter()
.map(|inhand| -> Result<_> { Ok(tiles.get(inhand).map(tiles::draw_tile)?) })
.collect::<Result<Vec<_>>>()?;
rendered.push(hand_tiles);
.map(|inhand| tiles.get(inhand).map(tiles::draw_tile).unwrap())
.collect();
rendered.push(tiles);
}
target.0 = rendered;
trace!("render_changed_hand");
render_hand(hand, tiles, target)?;
Ok(())
}
pub(crate) fn render_hand(
hand: Single<&HandTiles, Changed<HandTiles>>,
tiles: Populated<&Tile>,
mut target: ResMut<RenderedHand>,
) -> Result {
trace!("render_hand");
let hand_tiles = hand
.iter()
.map(|inhand| -> Result<_> { Ok(tiles.get(inhand).map(tiles::draw_tile)?) })
.collect::<Result<Vec<_>>>()?;
target.0 = hand_tiles;
Ok(())
}