jong/src/tiles.rs

49 lines
862 B
Rust
Raw Normal View History

2026-01-07 00:51:57 -08:00
use bevy::prelude::*;
use strum::FromRepr;
#[derive(Component)]
2026-01-08 21:35:16 -08:00
pub enum Tile {
Pin(Rank),
Sou(Rank),
Man(Rank),
2026-01-07 00:51:57 -08:00
Wind(Wind),
Dragon(Dragon),
}
2026-01-08 21:35:16 -08:00
#[derive(Deref, DerefMut)]
pub struct Rank(u8);
2026-01-07 00:51:57 -08:00
#[derive(FromRepr)]
2026-01-08 21:35:16 -08:00
pub enum Wind {
2026-01-07 00:51:57 -08:00
Ton,
Nan,
Shaa,
Pei,
}
#[derive(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 21:35:16 -08:00
commands.spawn(Tile::Pin(Rank(i)));
commands.spawn(Tile::Sou(Rank(i)));
commands.spawn(Tile::Man(Rank(i)));
2026-01-07 00:51:57 -08:00
}
for i in 0..4 {
2026-01-08 21:35:16 -08:00
commands.spawn(Tile::Wind(Wind::from_repr(i).unwrap()));
2026-01-07 00:51:57 -08:00
}
for i in 0..3 {
2026-01-08 21:35:16 -08:00
commands.spawn(Tile::Dragon(Dragon::from_repr(i).unwrap()));
2026-01-07 00:51:57 -08:00
}
}
}