92 lines
1.9 KiB
Rust
92 lines
1.9 KiB
Rust
|
|
use std::collections::VecDeque;
|
||
|
|
|
||
|
|
use bevy::prelude::*;
|
||
|
|
|
||
|
|
use crate::tiles::{self, *};
|
||
|
|
|
||
|
|
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);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
#[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);
|
||
|
|
|
||
|
|
#[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,
|
||
|
|
}
|
||
|
|
|
||
|
|
#[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>
|
||
|
|
) {
|
||
|
|
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,
|
||
|
|
// }
|
||
|
|
}
|