jong/src/game/mod.rs

96 lines
2 KiB
Rust
Raw Normal View History

2026-01-08 20:49:19 -08:00
use bevy::prelude::*;
2026-01-09 23:14:29 -08:00
use tracing::instrument;
2026-01-08 20:49:19 -08:00
use crate::tiles::{self, *};
2026-01-11 20:10:30 -08:00
pub mod player;
2026-01-09 06:54:17 -08:00
pub mod wall;
2026-01-08 23:58:26 -08:00
2026-01-11 20:10:30 -08:00
#[derive(States, Default, Hash, Clone, Eq, Debug, PartialEq)]
pub enum GameState {
#[default]
None,
Setup,
// Deal,
Play,
Score,
}
2026-01-08 20:49:19 -08:00
2026-01-11 20:10:30 -08:00
pub struct Riichi;
2026-01-08 20:49:19 -08:00
impl Plugin for Riichi {
fn build(&self, app: &mut App) {
app.init_resource::<Compass>()
.add_systems(Startup, init_match)
2026-01-11 20:10:30 -08:00
.add_systems(Startup, tiles::init_tiles)
.init_state::<GameState>()
.add_systems(OnEnter(GameState::Setup), (wall::build_wall, player::deal_hands).chain())
2026-01-09 06:54:17 -08:00
// semicolon stopper
;
2026-01-08 20:49:19 -08:00
}
}
#[derive(Component)]
pub(crate) struct Dice(u8, u8);
#[derive(Resource)]
pub(crate) struct Compass {
pub(crate) prevalent_wind: Wind,
pub(crate) round: u8,
pub(crate) dealer_wind: Wind,
pub(crate) riichi: usize,
pub(crate) honba: usize,
}
impl Default for Compass {
fn default() -> Self {
Self {
prevalent_wind: Wind::Ton,
round: 1,
dealer_wind: Wind::Ton,
riichi: 0,
honba: 0,
}
}
}
#[derive(Resource)]
pub(crate) struct MatchSettings {
pub(crate) starting_points: isize,
pub(crate) player_count: u8,
}
2026-01-09 03:34:54 -08:00
pub(crate) fn next_round(_compass: Res<Compass>) {}
2026-01-08 20:49:19 -08:00
pub(crate) fn init_match(
mut commands: Commands,
2026-01-08 23:58:26 -08:00
// mut compass: ResMut<Compass>
2026-01-08 20:49:19 -08:00
) {
let starting = 25000;
let player_count = 4;
commands.insert_resource(MatchSettings {
starting_points: starting,
player_count,
});
let players = (1..=player_count)
.map(|i| {
(
2026-01-08 23:58:26 -08:00
player::Player {
2026-01-08 20:49:19 -08:00
name: format!("Player {i}"),
},
2026-01-08 23:58:26 -08:00
player::Points(starting),
2026-01-08 20:49:19 -08:00
)
})
.collect::<Vec<_>>();
commands.spawn_batch(players);
// *compass = Compass {
// prevalent_wind: Wind::Ton,
// round: 1,
// dealer_wind: todo!(),
// riichi: 0,
// honba: 0,
// }
}