insert shuffled wall
This commit is contained in:
parent
3ca8574a6e
commit
d7d567b0e6
7 changed files with 36 additions and 17 deletions
|
|
@ -19,6 +19,7 @@ clap = { workspace = true, features = ["derive"] }
|
|||
log = { workspace = true, features = ["release_max_level_error", "max_level_trace"] }
|
||||
rand = { workspace = true }
|
||||
ratatui = { workspace = true }
|
||||
spacetimedb.workspace = true
|
||||
strum = { workspace = true, features = ["derive"] }
|
||||
tracing = { workspace = true }
|
||||
tracing-subscriber = { workspace = true }
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
use bevy::prelude::*;
|
||||
use spacetimedb::SpacetimeType;
|
||||
use strum::FromRepr;
|
||||
|
||||
#[derive(Component, Debug, Clone, Copy)]
|
||||
#[derive(Component, Debug, Clone, Copy, SpacetimeType)]
|
||||
pub struct Tile {
|
||||
pub suit: Suit,
|
||||
}
|
||||
|
||||
#[derive(/* MapEntities, */ Debug, PartialEq, PartialOrd, Eq, Ord, Clone, Copy)]
|
||||
#[derive(/* MapEntities, */ Debug, PartialEq, PartialOrd, Eq, Ord, Clone, Copy, SpacetimeType)]
|
||||
pub enum Suit {
|
||||
Man(Rank),
|
||||
Pin(Rank),
|
||||
|
|
@ -27,10 +28,12 @@ impl Suit {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Deref, DerefMut, Debug, PartialEq, PartialOrd, Eq, Ord, Clone, Copy)]
|
||||
pub struct Rank(pub u8);
|
||||
#[derive(Deref, DerefMut, Debug, PartialEq, PartialOrd, Eq, Ord, Clone, Copy, SpacetimeType)]
|
||||
pub struct Rank {
|
||||
pub number: u8,
|
||||
}
|
||||
|
||||
#[derive(FromRepr, Debug, PartialEq, PartialOrd, Eq, Ord, Clone, Copy)]
|
||||
#[derive(FromRepr, Debug, PartialEq, PartialOrd, Eq, Ord, Clone, Copy, SpacetimeType)]
|
||||
pub enum Wind {
|
||||
Ton,
|
||||
Nan,
|
||||
|
|
@ -38,7 +41,7 @@ pub enum Wind {
|
|||
Pei,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromRepr, PartialEq, PartialOrd, Eq, Ord, Clone, Copy)]
|
||||
#[derive(Debug, FromRepr, PartialEq, PartialOrd, Eq, Ord, Clone, Copy, SpacetimeType)]
|
||||
pub enum Dragon {
|
||||
Haku,
|
||||
Hatsu,
|
||||
|
|
@ -53,13 +56,13 @@ pub fn init_tiles(mut commands: Commands) {
|
|||
for _ in 0..4 {
|
||||
for i in 1..=9 {
|
||||
tiles.push(Tile {
|
||||
suit: Suit::Pin(Rank(i)),
|
||||
suit: Suit::Pin(Rank { number: i }),
|
||||
});
|
||||
tiles.push(Tile {
|
||||
suit: Suit::Sou(Rank(i)),
|
||||
suit: Suit::Sou(Rank { number: i }),
|
||||
});
|
||||
tiles.push(Tile {
|
||||
suit: Suit::Man(Rank(i)),
|
||||
suit: Suit::Man(Rank { number: i }),
|
||||
});
|
||||
}
|
||||
for i in 0..4 {
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@ pub(crate) struct PickRegion {
|
|||
fn render_tile(tile: &Tile, hovered: bool) -> Paragraph<'_> {
|
||||
let block = ratatui::widgets::Block::bordered();
|
||||
let mut widget = Paragraph::new(match &tile.suit {
|
||||
jong::tile::Suit::Pin(rank) => format!("{}\np", rank.0),
|
||||
jong::tile::Suit::Sou(rank) => format!("{}\ns", rank.0),
|
||||
jong::tile::Suit::Man(rank) => format!("{}\nm", rank.0),
|
||||
jong::tile::Suit::Pin(rank) => format!("{}\np", rank.number),
|
||||
jong::tile::Suit::Sou(rank) => format!("{}\ns", rank.number),
|
||||
jong::tile::Suit::Man(rank) => format!("{}\nm", rank.number),
|
||||
jong::tile::Suit::Wind(wind) => (match wind {
|
||||
jong::tile::Wind::Ton => "e\nw",
|
||||
jong::tile::Wind::Nan => "s\nw",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue