jong/src/game/player.rs

45 lines
936 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::{
2026-01-12 01:08:27 -08:00
game::wall::{InWall, Wall, WallTiles},
2026-01-11 20:10:30 -08:00
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,
2026-01-12 01:08:27 -08:00
inwalls: Single<&WallTiles>,
walltiles: Single<Entity, With<WallTiles>>,
2026-01-11 20:10:30 -08:00
) -> Result {
2026-01-12 01:08:27 -08:00
let hand = inwalls.iter().collect::<Vec<_>>();
2026-01-11 20:10:30 -08:00
commands
2026-01-12 01:08:27 -08:00
.get_entity(*walltiles)?
2026-01-11 20:10:30 -08:00
.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(())
}