we start printing again

This commit is contained in:
Tao Tien 2026-01-12 01:54:59 -08:00
parent 65ea256436
commit 59399c3590
7 changed files with 114 additions and 52 deletions

View file

@ -1,25 +1,37 @@
use bevy::prelude::*;
use ratatui::widgets::Paragraph;
use jong::game::player::HandTiles;
use jong::game::hand::HandTiles;
use jong::tiles::Tile;
use crate::tui::render::tiles;
#[derive(Component)]
pub(crate) struct RenderedHand<'a>(pub(crate) Vec<Paragraph<'a>>);
#[derive(Resource, Default)]
pub(crate) struct RenderedHand(pub(crate) Vec<Paragraph<'static>>);
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>,
tiles: Populated<&Tile>,
mut target: ResMut<RenderedHand>,
) -> Result {
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(())