refactor a lil
This commit is contained in:
parent
178c344859
commit
ee4c492018
8 changed files with 34 additions and 144 deletions
38
src/tiles.rs
38
src/tiles.rs
|
|
@ -2,29 +2,19 @@ use bevy::prelude::*;
|
|||
use strum::FromRepr;
|
||||
|
||||
#[derive(Component)]
|
||||
pub(crate) enum Tile {
|
||||
Pin(Number),
|
||||
Sou(Number),
|
||||
Man(Number),
|
||||
pub enum Tile {
|
||||
Pin(Rank),
|
||||
Sou(Rank),
|
||||
Man(Rank),
|
||||
Wind(Wind),
|
||||
Dragon(Dragon),
|
||||
}
|
||||
|
||||
#[derive(FromRepr)]
|
||||
pub(crate) enum Number {
|
||||
One = 1,
|
||||
Two,
|
||||
Three,
|
||||
Four,
|
||||
Five,
|
||||
Six,
|
||||
Seven,
|
||||
Eight,
|
||||
Nine,
|
||||
}
|
||||
#[derive(Deref, DerefMut)]
|
||||
pub struct Rank(u8);
|
||||
|
||||
#[derive(FromRepr)]
|
||||
pub(crate) enum Wind {
|
||||
pub enum Wind {
|
||||
Ton,
|
||||
Nan,
|
||||
Shaa,
|
||||
|
|
@ -32,27 +22,27 @@ pub(crate) enum Wind {
|
|||
}
|
||||
|
||||
#[derive(FromRepr)]
|
||||
pub(crate) enum Dragon {
|
||||
pub enum Dragon {
|
||||
Haku,
|
||||
Hatsu,
|
||||
Chun,
|
||||
}
|
||||
|
||||
#[derive(Component)]
|
||||
pub(crate) struct Dora;
|
||||
pub struct Dora;
|
||||
|
||||
pub fn init_tiles(mut commands: Commands) {
|
||||
for _ in 0..4 {
|
||||
for i in 1..=9 {
|
||||
commands.spawn((Tile::Pin(Number::from_repr(i).unwrap()),));
|
||||
commands.spawn((Tile::Sou(Number::from_repr(i).unwrap()),));
|
||||
commands.spawn((Tile::Man(Number::from_repr(i).unwrap()),));
|
||||
commands.spawn(Tile::Pin(Rank(i)));
|
||||
commands.spawn(Tile::Sou(Rank(i)));
|
||||
commands.spawn(Tile::Man(Rank(i)));
|
||||
}
|
||||
for i in 0..4 {
|
||||
commands.spawn((Tile::Wind(Wind::from_repr(i).unwrap()),));
|
||||
commands.spawn(Tile::Wind(Wind::from_repr(i).unwrap()));
|
||||
}
|
||||
for i in 0..3 {
|
||||
commands.spawn((Tile::Dragon(Dragon::from_repr(i).unwrap()),));
|
||||
commands.spawn(Tile::Dragon(Dragon::from_repr(i).unwrap()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue