spawn each player and hand
This commit is contained in:
parent
50fd406dbf
commit
f6bd7fd6f7
3 changed files with 79 additions and 75 deletions
|
|
@ -228,6 +228,8 @@ fn view_hand(
|
||||||
// trace!("view_hand");
|
// trace!("view_hand");
|
||||||
if let Some(view) = stdb.db().view_player_hand().iter().next() {
|
if let Some(view) = stdb.db().view_player_hand().iter().next() {
|
||||||
let mut view = view.tiles.iter().map(Tile::from).collect::<Vec<_>>();
|
let mut view = view.tiles.iter().map(Tile::from).collect::<Vec<_>>();
|
||||||
|
// view.sort();
|
||||||
|
debug!("view: {view:?}");
|
||||||
|
|
||||||
let tiles = tiles
|
let tiles = tiles
|
||||||
.iter()
|
.iter()
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,7 @@ pub(crate) fn render(
|
||||||
// // trace!("arg!");
|
// // trace!("arg!");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
// FIXME we don't care about other players atm
|
||||||
#[allow(clippy::too_many_arguments, clippy::type_complexity)]
|
#[allow(clippy::too_many_arguments, clippy::type_complexity)]
|
||||||
pub(crate) fn render_hands(
|
pub(crate) fn render_hands(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
|
|
@ -124,7 +125,7 @@ pub(crate) fn render_hands(
|
||||||
main_player: Single<(&Player, Entity /* , &Wind */), With<MainPlayer>>,
|
main_player: Single<(&Player, Entity /* , &Wind */), With<MainPlayer>>,
|
||||||
curr_player: Single<Entity, With<CurrentPlayer>>,
|
curr_player: Single<Entity, With<CurrentPlayer>>,
|
||||||
players: Query<(&Player, Entity, &Children)>,
|
players: Query<(&Player, Entity, &Children)>,
|
||||||
hands: Query<(&Children, Entity), (With<Hand>, Without<Player>)>,
|
hands: Query<(&Children, Entity), With<Hand>>,
|
||||||
// drawn_tile: Single<Entity, With<Drawn>>,
|
// drawn_tile: Single<Entity, With<Drawn>>,
|
||||||
) -> Result {
|
) -> Result {
|
||||||
let mut frame = tui.get_frame();
|
let mut frame = tui.get_frame();
|
||||||
|
|
@ -132,10 +133,10 @@ pub(crate) fn render_hands(
|
||||||
|
|
||||||
for (hand, hand_ent) in hands {
|
for (hand, hand_ent) in hands {
|
||||||
// debug!("{hand:?}");
|
// debug!("{hand:?}");
|
||||||
let (player, player_ent, _) = players
|
// let (player, player_ent, _) = players
|
||||||
.iter()
|
// .iter()
|
||||||
.find(|(_, e, c)| c.contains(&hand_ent))
|
// .find(|(_, e, c)| c.contains(&hand_ent))
|
||||||
.unwrap();
|
// .unwrap();
|
||||||
let hand: Vec<_> = hand
|
let hand: Vec<_> = hand
|
||||||
.iter()
|
.iter()
|
||||||
.map(|entity| -> Result<_> {
|
.map(|entity| -> Result<_> {
|
||||||
|
|
@ -147,7 +148,8 @@ pub(crate) fn render_hands(
|
||||||
})
|
})
|
||||||
.collect::<Result<_>>()?;
|
.collect::<Result<_>>()?;
|
||||||
|
|
||||||
if player == main_player.0 {
|
let (player, player_ent) = *main_player;
|
||||||
|
// if player == main_player.0 {
|
||||||
// split main box into thirds
|
// split main box into thirds
|
||||||
let mut this_hand = layouts.this_hand;
|
let mut this_hand = layouts.this_hand;
|
||||||
// let this_drawer = drawn_tile..is_some_and(|dt| dt.0 == player);
|
// let this_drawer = drawn_tile..is_some_and(|dt| dt.0 == player);
|
||||||
|
|
@ -214,13 +216,13 @@ pub(crate) fn render_hands(
|
||||||
// frame.render_widget(widget, area);
|
// frame.render_widget(widget, area);
|
||||||
// }
|
// }
|
||||||
// TODO draw melds
|
// TODO draw melds
|
||||||
} else {
|
// } else {
|
||||||
// match mainplayer.1.relate(wind) {
|
// match mainplayer.1.relate(wind) {
|
||||||
// jong::game::round::WindRelation::Shimocha => todo!(),
|
// jong::game::round::WindRelation::Shimocha => todo!(),
|
||||||
// jong::game::round::WindRelation::Toimen => todo!(),
|
// jong::game::round::WindRelation::Toimen => todo!(),
|
||||||
// jong::game::round::WindRelation::Kamicha => todo!(),
|
// jong::game::round::WindRelation::Kamicha => todo!(),
|
||||||
// }
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue