2026-01-08 23:58:26 -08:00
|
|
|
use bevy::{ecs::entity::MapEntities, prelude::*};
|
2026-01-07 00:51:57 -08:00
|
|
|
use strum::FromRepr;
|
|
|
|
|
|
2026-01-09 06:54:17 -08:00
|
|
|
use crate::game::wall::Wall;
|
2026-01-08 23:58:26 -08:00
|
|
|
|
2026-01-09 06:54:17 -08:00
|
|
|
#[derive(Component)]
|
|
|
|
|
#[relationship(relationship_target = Wall)]
|
|
|
|
|
pub struct InWall(pub Entity);
|
2026-01-08 23:58:26 -08:00
|
|
|
|
2026-01-09 06:54:17 -08:00
|
|
|
// #[derive(Component)]
|
|
|
|
|
// #[relationship(relationship_target = WallTiles)]
|
|
|
|
|
// pub(crate) struct InHand(pub Entity);
|
2026-01-08 23:58:26 -08:00
|
|
|
|
2026-01-09 06:54:17 -08:00
|
|
|
#[derive(Component, Debug)]
|
2026-01-08 23:58:26 -08:00
|
|
|
pub struct Tile {
|
|
|
|
|
suit: Suit,
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-09 06:54:17 -08:00
|
|
|
#[derive(MapEntities, Debug)]
|
2026-01-08 23:58:26 -08:00
|
|
|
pub enum Suit {
|
2026-01-08 21:35:16 -08:00
|
|
|
Pin(Rank),
|
|
|
|
|
Sou(Rank),
|
|
|
|
|
Man(Rank),
|
2026-01-07 00:51:57 -08:00
|
|
|
Wind(Wind),
|
|
|
|
|
Dragon(Dragon),
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-09 06:54:17 -08:00
|
|
|
#[derive(Deref, DerefMut, Debug)]
|
2026-01-08 21:35:16 -08:00
|
|
|
pub struct Rank(u8);
|
2026-01-07 00:51:57 -08:00
|
|
|
|
2026-01-09 06:54:17 -08:00
|
|
|
#[derive(FromRepr, Debug)]
|
2026-01-08 21:35:16 -08:00
|
|
|
pub enum Wind {
|
2026-01-07 00:51:57 -08:00
|
|
|
Ton,
|
|
|
|
|
Nan,
|
|
|
|
|
Shaa,
|
|
|
|
|
Pei,
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-09 06:54:17 -08:00
|
|
|
#[derive(Debug, FromRepr)]
|
2026-01-08 21:35:16 -08:00
|
|
|
pub enum Dragon {
|
2026-01-07 00:51:57 -08:00
|
|
|
Haku,
|
|
|
|
|
Hatsu,
|
|
|
|
|
Chun,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Component)]
|
2026-01-08 21:35:16 -08:00
|
|
|
pub struct Dora;
|
2026-01-07 00:51:57 -08:00
|
|
|
|
|
|
|
|
pub fn init_tiles(mut commands: Commands) {
|
|
|
|
|
for _ in 0..4 {
|
|
|
|
|
for i in 1..=9 {
|
2026-01-08 23:58:26 -08:00
|
|
|
commands.spawn(Tile {
|
|
|
|
|
suit: Suit::Pin(Rank(i)),
|
|
|
|
|
});
|
|
|
|
|
commands.spawn(Tile {
|
|
|
|
|
suit: Suit::Sou(Rank(i)),
|
|
|
|
|
});
|
|
|
|
|
commands.spawn(Tile {
|
|
|
|
|
suit: Suit::Man(Rank(i)),
|
|
|
|
|
});
|
2026-01-07 00:51:57 -08:00
|
|
|
}
|
|
|
|
|
for i in 0..4 {
|
2026-01-08 23:58:26 -08:00
|
|
|
commands.spawn(Tile {
|
|
|
|
|
suit: Suit::Wind(Wind::from_repr(i).unwrap()),
|
|
|
|
|
});
|
2026-01-07 00:51:57 -08:00
|
|
|
}
|
|
|
|
|
for i in 0..3 {
|
2026-01-08 23:58:26 -08:00
|
|
|
commands.spawn(Tile {
|
|
|
|
|
suit: Suit::Dragon(Dragon::from_repr(i).unwrap()),
|
|
|
|
|
});
|
2026-01-07 00:51:57 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|