shuffle
This commit is contained in:
parent
78029687d7
commit
bea146d439
9 changed files with 88 additions and 41 deletions
|
|
@ -1,10 +1,9 @@
|
|||
|
||||
use bevy::prelude::*;
|
||||
|
||||
use crate::tiles::{self, *};
|
||||
|
||||
mod player;
|
||||
pub(crate) mod wall;
|
||||
pub mod wall;
|
||||
|
||||
pub struct Riichi;
|
||||
|
||||
|
|
@ -13,10 +12,21 @@ impl Plugin for Riichi {
|
|||
app.init_resource::<Compass>()
|
||||
.add_systems(Startup, init_match)
|
||||
.add_systems(Startup, tiles::init_tiles)
|
||||
.add_systems(Startup, wall::build_wall);
|
||||
.add_systems(Update, wall::build_wall)
|
||||
// semicolon stopper
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(States, Default, Hash, Clone, Eq, Debug, PartialEq)]
|
||||
enum GameState {
|
||||
#[default]
|
||||
Setup,
|
||||
Deal,
|
||||
Play,
|
||||
Score,
|
||||
}
|
||||
|
||||
#[derive(Component)]
|
||||
pub(crate) struct Dice(u8, u8);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,24 @@
|
|||
|
||||
use bevy::log::tracing::instrument;
|
||||
use bevy::prelude::*;
|
||||
use rand::seq::SliceRandom;
|
||||
|
||||
use crate::game::InWall;
|
||||
use crate::tiles::Tile;
|
||||
|
||||
#[derive(Component)]
|
||||
pub(crate) struct Wall(Vec<Entity>);
|
||||
#[relationship_target(relationship = InWall)]
|
||||
pub struct Wall(Vec<Entity>);
|
||||
|
||||
pub(crate) fn build_wall(_tiles: Query<&Tile>) {
|
||||
info!("built a wall!")
|
||||
#[instrument(level = "trace", skip_all)]
|
||||
pub(crate) fn build_wall(mut commands: Commands, tiles: Query<Entity, With<Tile>>) -> Result {
|
||||
let mut rng = rand::rng();
|
||||
|
||||
let mut wall = commands.spawn(Wall(vec![]));
|
||||
|
||||
let mut shuffled = tiles.iter().collect::<Vec<_>>();
|
||||
shuffled.shuffle(&mut rng);
|
||||
|
||||
wall.replace_children(&shuffled);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue