turnstates
This commit is contained in:
parent
8a8a702a08
commit
6e6b792a58
7 changed files with 133 additions and 41 deletions
|
|
@ -1,6 +1,7 @@
|
|||
use bevy::prelude::*;
|
||||
use strum::{EnumCount, FromRepr};
|
||||
|
||||
use crate::tile::*;
|
||||
use crate::{EnumNextCycle, game::GameState};
|
||||
|
||||
#[derive(Component)]
|
||||
pub(crate) struct Dice(u8, u8);
|
||||
|
|
@ -40,3 +41,46 @@ impl Default for MatchSettings {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Component, Clone, Copy, FromRepr, EnumCount)]
|
||||
pub enum Wind {
|
||||
Ton,
|
||||
Nan,
|
||||
Shaa,
|
||||
Pei,
|
||||
}
|
||||
|
||||
impl EnumNextCycle for Wind {
|
||||
fn next(&self) -> Self {
|
||||
if (*self as usize + 1) >= Self::COUNT {
|
||||
Self::from_repr(0).unwrap()
|
||||
} else {
|
||||
Self::from_repr(*self as usize + 1).unwrap()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Resource)]
|
||||
pub(crate) struct CurrentPlayer(pub Entity);
|
||||
|
||||
#[derive(SubStates, Default, Clone, Copy, PartialEq, Eq, Hash, Debug, FromRepr, EnumCount)]
|
||||
#[source(GameState = GameState::Play)]
|
||||
pub(crate) enum TurnState {
|
||||
#[default]
|
||||
Tsumo,
|
||||
Menzen,
|
||||
RiichiKan,
|
||||
Discard,
|
||||
RonChiiPonKan,
|
||||
End,
|
||||
}
|
||||
|
||||
impl EnumNextCycle for TurnState {
|
||||
fn next(&self) -> Self {
|
||||
if (*self as usize + 1) >= Self::COUNT {
|
||||
Self::from_repr(0).unwrap()
|
||||
} else {
|
||||
Self::from_repr(*self as usize + 1).unwrap()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue