jong/src/game/hand.rs

29 lines
612 B
Rust
Raw Normal View History

2026-01-13 01:08:14 -08:00
use bevy::{ecs::relationship::RelationshipSourceCollection, prelude::*};
2026-01-12 01:54:59 -08:00
2026-01-12 21:57:08 -08:00
use crate::{
2026-01-13 00:01:38 -08:00
game::{player::Player /* wall::WallTiles */},
tile::Tile,
2026-01-12 21:57:08 -08:00
};
2026-01-12 01:54:59 -08:00
#[derive(Component)]
pub struct Hand;
2026-01-13 00:01:38 -08:00
// #[derive(Component, Default)]
// enum SortHand {
// #[default]
// Unsorted,
// Sort,
// Manual,
// }
2026-01-12 21:57:08 -08:00
pub(crate) fn sort_hands(
2026-01-12 01:54:59 -08:00
tiles: Populated<&Tile>,
2026-01-13 01:08:14 -08:00
mut hands: Populated<&mut Children, (Changed<Hand>, Without<Player>)>,
2026-01-12 01:54:59 -08:00
) -> Result {
2026-01-13 00:01:38 -08:00
for mut hand in hands {
hand.sort_unstable_by_key(|e| tiles.get(*e).unwrap().suit);
2026-01-13 01:08:14 -08:00
debug!("sorted: {hand:?}");
2026-01-12 21:57:08 -08:00
}
2026-01-12 01:54:59 -08:00
Ok(())
}