refactor a lil
This commit is contained in:
parent
178c344859
commit
ee4c492018
8 changed files with 34 additions and 144 deletions
22
Cargo.lock
generated
22
Cargo.lock
generated
|
|
@ -3084,6 +3084,17 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "jong"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"bevy",
|
||||||
|
"bevy_ratatui",
|
||||||
|
"clap",
|
||||||
|
"ratatui",
|
||||||
|
"strum 0.27.2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "js-sys"
|
name = "js-sys"
|
||||||
version = "0.3.83"
|
version = "0.3.83"
|
||||||
|
|
@ -4794,17 +4805,6 @@ dependencies = [
|
||||||
"strict-num",
|
"strict-num",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tiny_riichi"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"bevy",
|
|
||||||
"bevy_ratatui",
|
|
||||||
"clap",
|
|
||||||
"ratatui",
|
|
||||||
"strum 0.27.2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tinyvec"
|
name = "tinyvec"
|
||||||
version = "1.10.0"
|
version = "1.10.0"
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
[package]
|
[package]
|
||||||
name = "tiny_riichi"
|
name = "jong"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = { version = "0.17.3", features = ["dynamic_linking"] }
|
bevy = { version = "0.17.3", features = ["dynamic_linking"] }
|
||||||
bevy_ratatui = "0.10.0"
|
bevy_ratatui = "0.10.0"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
use bevy::{color::palettes::css::GREEN, prelude::*};
|
use bevy::{color::palettes::css::GREEN, prelude::*};
|
||||||
|
|
||||||
pub(crate) mod tiles;
|
|
||||||
|
|
||||||
pub(crate) fn init_environment(mut commands: Commands) {
|
pub(crate) fn init_environment(mut commands: Commands) {
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
DirectionalLight {
|
DirectionalLight {
|
||||||
|
|
|
||||||
|
|
@ -1,99 +0,0 @@
|
||||||
use bevy::{color::palettes::css::GREY, prelude::*};
|
|
||||||
use strum::FromRepr;
|
|
||||||
|
|
||||||
#[derive(Component)]
|
|
||||||
pub(crate) enum Tile {
|
|
||||||
Pin(Number),
|
|
||||||
Sou(Number),
|
|
||||||
Man(Number),
|
|
||||||
Wind(Wind),
|
|
||||||
Dragon(Dragon),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(FromRepr)]
|
|
||||||
pub(crate) enum Number {
|
|
||||||
One = 1,
|
|
||||||
Two,
|
|
||||||
Three,
|
|
||||||
Four,
|
|
||||||
Five,
|
|
||||||
Six,
|
|
||||||
Seven,
|
|
||||||
Eight,
|
|
||||||
Nine,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(FromRepr)]
|
|
||||||
pub(crate) enum Wind {
|
|
||||||
Ton,
|
|
||||||
Nan,
|
|
||||||
Shaa,
|
|
||||||
Pei,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(FromRepr)]
|
|
||||||
pub(crate) enum Dragon {
|
|
||||||
Haku,
|
|
||||||
Hatsu,
|
|
||||||
Chun,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Component)]
|
|
||||||
struct Dora;
|
|
||||||
|
|
||||||
pub fn init_tileset(
|
|
||||||
mut commands: Commands,
|
|
||||||
mut meshes: ResMut<Assets<Mesh>>,
|
|
||||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
|
||||||
) {
|
|
||||||
let cuboid = Cuboid::new(25., 20., 16.);
|
|
||||||
|
|
||||||
for _ in 0..4 {
|
|
||||||
for i in 1..=9 {
|
|
||||||
commands.spawn((
|
|
||||||
(
|
|
||||||
Mesh3d(meshes.add(cuboid)),
|
|
||||||
Transform::from_xyz(30., 0., 0.),
|
|
||||||
MeshMaterial3d(materials.add(std::convert::Into::<Color>::into(GREY))),
|
|
||||||
),
|
|
||||||
Tile::Pin(Number::from_repr(i).unwrap()),
|
|
||||||
));
|
|
||||||
commands.spawn((
|
|
||||||
(
|
|
||||||
Mesh3d(meshes.add(cuboid)),
|
|
||||||
Transform::from_xyz(30., 0., 0.),
|
|
||||||
MeshMaterial3d(materials.add(std::convert::Into::<Color>::into(GREY))),
|
|
||||||
),
|
|
||||||
Tile::Sou(Number::from_repr(i).unwrap()),
|
|
||||||
));
|
|
||||||
commands.spawn((
|
|
||||||
(
|
|
||||||
Mesh3d(meshes.add(cuboid)),
|
|
||||||
Transform::from_xyz(30., 0., 0.),
|
|
||||||
MeshMaterial3d(materials.add(std::convert::Into::<Color>::into(GREY))),
|
|
||||||
),
|
|
||||||
Tile::Man(Number::from_repr(i).unwrap()),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
for i in 0..4 {
|
|
||||||
commands.spawn((
|
|
||||||
(
|
|
||||||
Mesh3d(meshes.add(cuboid)),
|
|
||||||
Transform::from_xyz(30., 0., 0.),
|
|
||||||
MeshMaterial3d(materials.add(std::convert::Into::<Color>::into(GREY))),
|
|
||||||
),
|
|
||||||
Tile::Wind(Wind::from_repr(i).unwrap()),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
for i in 0..3 {
|
|
||||||
commands.spawn((
|
|
||||||
(
|
|
||||||
Mesh3d(meshes.add(cuboid)),
|
|
||||||
Transform::from_xyz(30., 0., 0.),
|
|
||||||
MeshMaterial3d(materials.add(std::convert::Into::<Color>::into(GREY))),
|
|
||||||
),
|
|
||||||
Tile::Dragon(Dragon::from_repr(i).unwrap()),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
4
src/lib.rs
Normal file
4
src/lib.rs
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
pub mod tiles;
|
||||||
|
pub mod yakus;
|
||||||
|
|
||||||
|
pub mod game;
|
||||||
|
|
@ -1,11 +1,6 @@
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
|
|
||||||
mod tiles;
|
|
||||||
mod yakus;
|
|
||||||
|
|
||||||
mod game;
|
|
||||||
|
|
||||||
mod gui;
|
mod gui;
|
||||||
mod tui;
|
mod tui;
|
||||||
|
|
||||||
|
|
@ -30,7 +25,7 @@ fn main() {
|
||||||
Mode::RunTui => app.add_plugins(tui::RiichiTui),
|
Mode::RunTui => app.add_plugins(tui::RiichiTui),
|
||||||
};
|
};
|
||||||
|
|
||||||
app.add_plugins(game::Riichi);
|
app.add_plugins(jong::game::Riichi);
|
||||||
|
|
||||||
app.run();
|
app.run();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
38
src/tiles.rs
38
src/tiles.rs
|
|
@ -2,29 +2,19 @@ use bevy::prelude::*;
|
||||||
use strum::FromRepr;
|
use strum::FromRepr;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub(crate) enum Tile {
|
pub enum Tile {
|
||||||
Pin(Number),
|
Pin(Rank),
|
||||||
Sou(Number),
|
Sou(Rank),
|
||||||
Man(Number),
|
Man(Rank),
|
||||||
Wind(Wind),
|
Wind(Wind),
|
||||||
Dragon(Dragon),
|
Dragon(Dragon),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(FromRepr)]
|
#[derive(Deref, DerefMut)]
|
||||||
pub(crate) enum Number {
|
pub struct Rank(u8);
|
||||||
One = 1,
|
|
||||||
Two,
|
|
||||||
Three,
|
|
||||||
Four,
|
|
||||||
Five,
|
|
||||||
Six,
|
|
||||||
Seven,
|
|
||||||
Eight,
|
|
||||||
Nine,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(FromRepr)]
|
#[derive(FromRepr)]
|
||||||
pub(crate) enum Wind {
|
pub enum Wind {
|
||||||
Ton,
|
Ton,
|
||||||
Nan,
|
Nan,
|
||||||
Shaa,
|
Shaa,
|
||||||
|
|
@ -32,27 +22,27 @@ pub(crate) enum Wind {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(FromRepr)]
|
#[derive(FromRepr)]
|
||||||
pub(crate) enum Dragon {
|
pub enum Dragon {
|
||||||
Haku,
|
Haku,
|
||||||
Hatsu,
|
Hatsu,
|
||||||
Chun,
|
Chun,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub(crate) struct Dora;
|
pub struct Dora;
|
||||||
|
|
||||||
pub fn init_tiles(mut commands: Commands) {
|
pub fn init_tiles(mut commands: Commands) {
|
||||||
for _ in 0..4 {
|
for _ in 0..4 {
|
||||||
for i in 1..=9 {
|
for i in 1..=9 {
|
||||||
commands.spawn((Tile::Pin(Number::from_repr(i).unwrap()),));
|
commands.spawn(Tile::Pin(Rank(i)));
|
||||||
commands.spawn((Tile::Sou(Number::from_repr(i).unwrap()),));
|
commands.spawn(Tile::Sou(Rank(i)));
|
||||||
commands.spawn((Tile::Man(Number::from_repr(i).unwrap()),));
|
commands.spawn(Tile::Man(Rank(i)));
|
||||||
}
|
}
|
||||||
for i in 0..4 {
|
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 {
|
for i in 0..3 {
|
||||||
commands.spawn((Tile::Dragon(Dragon::from_repr(i).unwrap()),));
|
commands.spawn(Tile::Dragon(Dragon::from_repr(i).unwrap()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use std::time::Duration;
|
||||||
use bevy::{app::ScheduleRunnerPlugin, prelude::*};
|
use bevy::{app::ScheduleRunnerPlugin, prelude::*};
|
||||||
use bevy_ratatui::{RatatuiContext, RatatuiPlugins};
|
use bevy_ratatui::{RatatuiContext, RatatuiPlugins};
|
||||||
|
|
||||||
use crate::tiles::Tile;
|
use jong::tiles::Tile;
|
||||||
|
|
||||||
mod input;
|
mod input;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue