init wall
This commit is contained in:
parent
76b720b0a2
commit
3fb03cfbcb
7 changed files with 69 additions and 27 deletions
|
|
@ -4,24 +4,20 @@ use bevy::prelude::*;
|
|||
|
||||
use crate::tiles::{self, *};
|
||||
|
||||
mod player;
|
||||
pub(crate) mod wall;
|
||||
|
||||
pub struct Riichi;
|
||||
|
||||
impl Plugin for Riichi {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.init_resource::<Compass>()
|
||||
.add_systems(Startup, init_match)
|
||||
.add_systems(Startup, tiles::init_tiles);
|
||||
.add_systems(Startup, tiles::init_tiles)
|
||||
.add_systems(Startup, wall::build_wall);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Component)]
|
||||
pub(crate) struct Player {
|
||||
pub(crate) name: String,
|
||||
}
|
||||
|
||||
#[derive(Component)]
|
||||
pub(crate) struct Points(isize);
|
||||
|
||||
#[derive(Component)]
|
||||
pub(crate) struct Dice(u8, u8);
|
||||
|
||||
|
|
@ -52,14 +48,11 @@ pub(crate) struct MatchSettings {
|
|||
pub(crate) player_count: u8,
|
||||
}
|
||||
|
||||
#[derive(Component)]
|
||||
pub(crate) struct Wall(VecDeque<Tile>);
|
||||
|
||||
pub(crate) fn next_round(mut compass: Res<Compass>) {}
|
||||
|
||||
pub(crate) fn init_match(
|
||||
mut commands: Commands,
|
||||
// , mut compass: ResMut<Compass>
|
||||
// mut compass: ResMut<Compass>
|
||||
) {
|
||||
let starting = 25000;
|
||||
let player_count = 4;
|
||||
|
|
@ -72,10 +65,10 @@ pub(crate) fn init_match(
|
|||
let players = (1..=player_count)
|
||||
.map(|i| {
|
||||
(
|
||||
Player {
|
||||
player::Player {
|
||||
name: format!("Player {i}"),
|
||||
},
|
||||
Points(starting),
|
||||
player::Points(starting),
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
9
src/game/player.rs
Normal file
9
src/game/player.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
use bevy::prelude::*;
|
||||
|
||||
#[derive(Component)]
|
||||
pub(crate) struct Player {
|
||||
pub(crate) name: String,
|
||||
}
|
||||
|
||||
#[derive(Component)]
|
||||
pub(crate) struct Points(pub isize);
|
||||
12
src/game/wall.rs
Normal file
12
src/game/wall.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
use std::collections::VecDeque;
|
||||
|
||||
use bevy::prelude::*;
|
||||
|
||||
use crate::tiles::Tile;
|
||||
|
||||
#[derive(Component)]
|
||||
pub(crate) struct Wall(Vec<Entity>);
|
||||
|
||||
pub(crate) fn build_wall(tiles: Query<&Tile>) {
|
||||
info!("built a wall!")
|
||||
}
|
||||
42
src/tiles.rs
42
src/tiles.rs
|
|
@ -1,8 +1,26 @@
|
|||
use bevy::prelude::*;
|
||||
use bevy::{ecs::entity::MapEntities, prelude::*};
|
||||
use strum::FromRepr;
|
||||
|
||||
use crate::game::wall::Wall;
|
||||
|
||||
// #[derive(Component)]
|
||||
// #[derive(relasionship(re))]
|
||||
// pub struct TileEntity {
|
||||
// #[relationship]
|
||||
// pub parent: Entity,
|
||||
|
||||
// r#type: Tile,
|
||||
// }
|
||||
|
||||
struct Hand;
|
||||
|
||||
#[derive(Component)]
|
||||
pub enum Tile {
|
||||
pub struct Tile {
|
||||
suit: Suit,
|
||||
}
|
||||
|
||||
#[derive(MapEntities)]
|
||||
pub enum Suit {
|
||||
Pin(Rank),
|
||||
Sou(Rank),
|
||||
Man(Rank),
|
||||
|
|
@ -34,15 +52,25 @@ pub struct Dora;
|
|||
pub fn init_tiles(mut commands: Commands) {
|
||||
for _ in 0..4 {
|
||||
for i in 1..=9 {
|
||||
commands.spawn(Tile::Pin(Rank(i)));
|
||||
commands.spawn(Tile::Sou(Rank(i)));
|
||||
commands.spawn(Tile::Man(Rank(i)));
|
||||
commands.spawn(Tile {
|
||||
suit: Suit::Pin(Rank(i)),
|
||||
});
|
||||
commands.spawn(Tile {
|
||||
suit: Suit::Sou(Rank(i)),
|
||||
});
|
||||
commands.spawn(Tile {
|
||||
suit: Suit::Man(Rank(i)),
|
||||
});
|
||||
}
|
||||
for i in 0..4 {
|
||||
commands.spawn(Tile::Wind(Wind::from_repr(i).unwrap()));
|
||||
commands.spawn(Tile {
|
||||
suit: Suit::Wind(Wind::from_repr(i).unwrap()),
|
||||
});
|
||||
}
|
||||
for i in 0..3 {
|
||||
commands.spawn(Tile::Dragon(Dragon::from_repr(i).unwrap()));
|
||||
commands.spawn(Tile {
|
||||
suit: Suit::Dragon(Dragon::from_repr(i).unwrap()),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,7 @@ use bevy::prelude::*;
|
|||
use bevy_ratatui::crossterm::event::KeyCode;
|
||||
|
||||
pub(crate) fn keyboard_input_system(
|
||||
input: Res<ButtonInput<KeyCode>>,
|
||||
key_input: Res<ButtonInput<Key>>,
|
||||
input: Option<Res<ButtonInput<KeyCode>>>,
|
||||
key_input: Option<Res<ButtonInput<Key>>>,
|
||||
) {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ impl Plugin for RiichiTui {
|
|||
..Default::default()
|
||||
},
|
||||
))
|
||||
.add_systems(Update, draw_system)
|
||||
.add_systems(Update, input::keyboard_input_system);
|
||||
.add_systems(Update, input::keyboard_input_system)
|
||||
.add_systems(Update, draw_system);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue