2026-01-07 00:51:57 -08:00
|
|
|
use std::{collections::VecDeque, time::Duration};
|
2026-01-05 23:49:37 -08:00
|
|
|
|
2026-01-07 00:51:57 -08:00
|
|
|
use bevy::{app::ScheduleRunnerPlugin, input::keyboard::Key, prelude::*};
|
|
|
|
|
use bevy_ratatui::RatatuiPlugins;
|
|
|
|
|
use clap::{Parser, Subcommand};
|
|
|
|
|
|
|
|
|
|
use crate::tiles::*;
|
|
|
|
|
|
|
|
|
|
mod tiles;
|
|
|
|
|
mod yakus;
|
2026-01-05 23:49:37 -08:00
|
|
|
|
|
|
|
|
mod gui;
|
|
|
|
|
mod tui;
|
|
|
|
|
|
2026-01-07 00:51:57 -08:00
|
|
|
#[derive(Parser)]
|
|
|
|
|
struct Args {
|
|
|
|
|
#[command(subcommand)]
|
|
|
|
|
mode: Mode,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Subcommand)]
|
|
|
|
|
enum Mode {
|
|
|
|
|
RunGui,
|
|
|
|
|
RunTui,
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-05 23:24:42 -08:00
|
|
|
fn main() {
|
2026-01-07 00:51:57 -08:00
|
|
|
let args = Args::parse();
|
|
|
|
|
|
|
|
|
|
let mut app = App::new();
|
|
|
|
|
let app = match args.mode {
|
|
|
|
|
Mode::RunGui => app.add_plugins(DefaultPlugins),
|
|
|
|
|
Mode::RunTui => app
|
|
|
|
|
.add_plugins((
|
|
|
|
|
MinimalPlugins.set(ScheduleRunnerPlugin::run_loop(Duration::from_secs_f32(
|
|
|
|
|
1. / 1.,
|
|
|
|
|
))),
|
|
|
|
|
RatatuiPlugins {
|
|
|
|
|
// enable_kitty_protocol: todo!(),
|
|
|
|
|
// enable_mouse_capture: todo!(),
|
|
|
|
|
enable_input_forwarding: true,
|
|
|
|
|
..Default::default()
|
|
|
|
|
},
|
|
|
|
|
))
|
|
|
|
|
.add_systems(Update, tui::draw_system),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
app.init_resource::<Compass>()
|
|
|
|
|
.add_systems(Startup, init_match)
|
|
|
|
|
.add_systems(Startup, init_tiles);
|
|
|
|
|
|
|
|
|
|
app.run();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn keyboard_input_system(
|
|
|
|
|
input: Res<ButtonInput<KeyCode>>,
|
|
|
|
|
key_input: Res<ButtonInput<Key>>,
|
|
|
|
|
) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Component)]
|
|
|
|
|
struct Player {
|
|
|
|
|
name: String,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Component)]
|
|
|
|
|
struct Points(isize);
|
|
|
|
|
|
|
|
|
|
#[derive(Component)]
|
|
|
|
|
struct Dice(u8, u8);
|
|
|
|
|
|
|
|
|
|
#[derive(Resource)]
|
|
|
|
|
struct Compass {
|
|
|
|
|
prevalent_wind: Wind,
|
|
|
|
|
round: u8,
|
|
|
|
|
dealer_wind: Wind,
|
|
|
|
|
riichi: usize,
|
|
|
|
|
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)]
|
|
|
|
|
struct MatchSettings {
|
|
|
|
|
starting_points: isize,
|
|
|
|
|
player_count: u8,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Component)]
|
|
|
|
|
struct Wall(VecDeque<Tile>);
|
|
|
|
|
|
|
|
|
|
fn next_round(mut compass: Res<Compass>) {}
|
|
|
|
|
|
|
|
|
|
fn init_match(mut commands: Commands, // , mut compass: ResMut<Compass>
|
|
|
|
|
) {
|
|
|
|
|
let starting = 25000;
|
|
|
|
|
let player_count = 4;
|
|
|
|
|
|
|
|
|
|
commands.insert_resource(MatchSettings {
|
|
|
|
|
starting_points: starting,
|
|
|
|
|
player_count,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
let players = (1..=player_count)
|
|
|
|
|
.map(|i| {
|
|
|
|
|
(
|
|
|
|
|
Player {
|
|
|
|
|
name: format!("Player {i}"),
|
|
|
|
|
},
|
|
|
|
|
Points(starting),
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
.collect::<Vec<_>>();
|
|
|
|
|
commands.spawn_batch(players);
|
|
|
|
|
|
|
|
|
|
// *compass = Compass {
|
|
|
|
|
// prevalent_wind: Wind::Ton,
|
|
|
|
|
// round: 1,
|
|
|
|
|
// dealer_wind: todo!(),
|
|
|
|
|
// riichi: 0,
|
|
|
|
|
// honba: 0,
|
|
|
|
|
// }
|
2026-01-05 23:24:42 -08:00
|
|
|
}
|