stash
This commit is contained in:
parent
faa653b012
commit
7cbe10c19e
3 changed files with 66 additions and 6 deletions
19
src/game.rs
19
src/game.rs
|
|
@ -2,7 +2,7 @@ use bevy::prelude::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
game::{
|
game::{
|
||||||
hand::Hand,
|
hand::{Hand, Pond},
|
||||||
player::{CurrentPlayer, MainPlayer},
|
player::{CurrentPlayer, MainPlayer},
|
||||||
round::{TurnState, Wind},
|
round::{TurnState, Wind},
|
||||||
wall::Wall,
|
wall::Wall,
|
||||||
|
|
@ -27,6 +27,17 @@ pub enum GameState {
|
||||||
#[derive(Message)]
|
#[derive(Message)]
|
||||||
pub enum GameMessage {
|
pub enum GameMessage {
|
||||||
Discarded(Entity),
|
Discarded(Entity),
|
||||||
|
CallPending,
|
||||||
|
Called { player: Entity, calltype: Entity },
|
||||||
|
}
|
||||||
|
|
||||||
|
impl GameMessage {
|
||||||
|
pub(crate) fn is_called(&self) -> bool {
|
||||||
|
match self {
|
||||||
|
GameMessage::Called { .. } => true,
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Riichi;
|
pub struct Riichi;
|
||||||
|
|
@ -47,10 +58,9 @@ impl Plugin for Riichi {
|
||||||
.add_systems(OnEnter(TurnState::Menzen), round::menzen)
|
.add_systems(OnEnter(TurnState::Menzen), round::menzen)
|
||||||
.add_systems(Update, round::riichi_kan.run_if(in_state(TurnState::RiichiKan)))
|
.add_systems(Update, round::riichi_kan.run_if(in_state(TurnState::RiichiKan)))
|
||||||
.add_systems(Update, round::discard.run_if(in_state(TurnState::Discard)))
|
.add_systems(Update, round::discard.run_if(in_state(TurnState::Discard)))
|
||||||
.add_systems(Update, round::debug_discard.run_if(in_state(TurnState::Discard)))
|
.add_systems(OnEnter(TurnState::RonChiiPonKan), round::notify_callable)
|
||||||
.add_systems(Update, round::ron_chi_pon_kan.run_if(in_state(TurnState::RonChiiPonKan)))
|
.add_systems(Update, round::ron_chi_pon_kan.run_if(in_state(TurnState::RonChiiPonKan)).after(round::notify_callable))
|
||||||
.add_systems(OnEnter(TurnState::End), round::end)
|
.add_systems(OnEnter(TurnState::End), round::end)
|
||||||
// .add_systems(Update, systems)
|
|
||||||
// semicolon stopper
|
// semicolon stopper
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
@ -73,6 +83,7 @@ pub(crate) fn setup(
|
||||||
player,
|
player,
|
||||||
points,
|
points,
|
||||||
Hand,
|
Hand,
|
||||||
|
Pond,
|
||||||
Wind::from_repr((i - 1) as usize).unwrap(),
|
Wind::from_repr((i - 1) as usize).unwrap(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,9 @@ use crate::{
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Hand;
|
pub struct Hand;
|
||||||
|
|
||||||
|
#[derive(Component)]
|
||||||
|
pub struct Pond;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Drawn;
|
pub struct Drawn;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
use bevy::prelude::*;
|
use std::rc::Weak;
|
||||||
|
|
||||||
|
use bevy::{platform::collections::HashMap, prelude::*};
|
||||||
use strum::{EnumCount, FromRepr};
|
use strum::{EnumCount, FromRepr};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
EnumNextCycle,
|
EnumNextCycle,
|
||||||
game::{
|
game::{
|
||||||
GameMessage, GameState,
|
GameMessage, GameState,
|
||||||
hand::{Discarded, Drawn, Hand},
|
hand::{Discarded, Drawn, Hand, Pond},
|
||||||
player::{CurrentPlayer, Player},
|
player::{CurrentPlayer, Player},
|
||||||
wall::Wall,
|
wall::Wall,
|
||||||
},
|
},
|
||||||
|
|
@ -58,6 +60,15 @@ pub(crate) enum TurnState {
|
||||||
End,
|
End,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Component, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
|
pub(crate) enum CallType {
|
||||||
|
Skip,
|
||||||
|
Ron,
|
||||||
|
Chii,
|
||||||
|
Pon,
|
||||||
|
Kan,
|
||||||
|
}
|
||||||
|
|
||||||
impl Default for MatchSettings {
|
impl Default for MatchSettings {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|
@ -191,10 +202,45 @@ pub(crate) fn discard(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Resource)]
|
||||||
|
pub struct PendingCalls {
|
||||||
|
eligible: Vec<Entity>,
|
||||||
|
calls: HashMap<Entity, CallType>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn notify_callable() {}
|
||||||
|
|
||||||
pub(crate) fn ron_chi_pon_kan(
|
pub(crate) fn ron_chi_pon_kan(
|
||||||
|
mut commands: Commands,
|
||||||
|
mut reader: MessageReader<GameMessage>,
|
||||||
|
|
||||||
|
discarded: Single<Entity, With<Discarded>>,
|
||||||
|
mut ponds: Query<(&Children, Entity), (With<Pond>, Without<Player>)>,
|
||||||
|
calls: Query<&CallType>,
|
||||||
|
|
||||||
curr_turnstate: Res<State<TurnState>>,
|
curr_turnstate: Res<State<TurnState>>,
|
||||||
mut next_turnstate: ResMut<NextState<TurnState>>,
|
mut next_turnstate: ResMut<NextState<TurnState>>,
|
||||||
) {
|
) {
|
||||||
|
// check if can call?
|
||||||
|
// message players?
|
||||||
|
// collect then prioritize
|
||||||
|
|
||||||
|
// let mut received = vec![];
|
||||||
|
let mut received: Vec<_> = reader
|
||||||
|
.read()
|
||||||
|
.filter_map(|m| {
|
||||||
|
if let GameMessage::Called { player, calltype } = m
|
||||||
|
&& let Ok(calltype) = calls.get(*calltype)
|
||||||
|
{
|
||||||
|
Some((calltype, player))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
received.sort_unstable_by_key(|(c, t)| c);
|
||||||
|
// received.sort_unstable_by_key(|m| m.);
|
||||||
|
|
||||||
next_turnstate.set(curr_turnstate.next());
|
next_turnstate.set(curr_turnstate.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue