jong/src/game/player.rs

46 lines
977 B
Rust
Raw Normal View History

2026-01-08 23:58:26 -08:00
use bevy::prelude::*;
2026-01-11 20:10:30 -08:00
use crate::{
game::wall::{Wall, WallTiles},
tiles::Tile,
};
2026-01-08 23:58:26 -08:00
#[derive(Component)]
pub(crate) struct Player {
pub(crate) name: String,
}
2026-01-11 20:10:30 -08:00
fn spawn_players(mut commands: Commands) {}
2026-01-08 23:58:26 -08:00
#[derive(Component)]
pub(crate) struct Points(pub isize);
2026-01-11 20:10:30 -08:00
#[derive(Component)]
pub struct Hand;
#[derive(Component)]
#[relationship_target(relationship = InHand, linked_spawn)]
pub struct HandTiles(Vec<Entity>);
#[derive(Component)]
#[relationship(relationship_target = HandTiles)]
pub struct InHand(pub Entity);
pub(crate) fn deal_hands(
mut commands: Commands,
wall: Single<Entity, With<Wall>>,
2026-01-11 23:41:27 -08:00
wall_tiles: Populated<Entity, With<WallTiles>>,
tiles: Populated<Entity, With<Tile>>,
2026-01-11 20:10:30 -08:00
) -> Result {
let hand = wall_tiles.iter().collect::<Vec<_>>();
commands
.get_entity(*wall)?
.remove_children(hand.last_chunk::<13>().unwrap());
commands.spawn((Hand, HandTiles(hand)));
2026-01-11 23:41:27 -08:00
trace!("dealt hands");
2026-01-11 20:10:30 -08:00
Ok(())
}