diff --git a/src/game.rs b/src/game.rs index d47ece6..cf0edf8 100644 --- a/src/game.rs +++ b/src/game.rs @@ -1393,13 +1393,13 @@ fn show_valid_moves( // For each one with a ValidMove index, make it visible let valid_moves = board.valid_moves(*idx); info!("Showing valid moves for {:?}: {:?}", idx, valid_moves); - valid_moves.iter().for_each(|idx| { - indicators.iter_mut().for_each(|(i, mut vis)| { - if i == idx { - *vis = Visibility::Inherited; - } - }); - }) + indicators.iter_mut().for_each(|(i, mut vis)| { + if valid_moves.contains(i) { + *vis = Visibility::Inherited; + } else { + *vis = Visibility::Hidden; + } + }); }); } diff --git a/src/tutorial.rs b/src/tutorial.rs index 93cf5f4..246be49 100644 --- a/src/tutorial.rs +++ b/src/tutorial.rs @@ -373,6 +373,9 @@ fn step( pieces: Query<&game::Piece, Added>, transitions: Query>, curr_state: Res>, + all_pieces: Query<(&Piece, &BoardIndex, &Side)>, + side_state: Res>, + mut valid_moves: Query<(&mut Visibility, &BoardIndex), With>, mut next_state: ResMut>, mut seen: ResMut, ) { @@ -457,6 +460,30 @@ fn step( } // Default, empty (tutorial doesn't always need to show something) else { + // When prompting to show a piece, find a random piece on this side and high-light it + all_pieces.iter() + .find_map(|(piece, board_index, side)| { + if *side == side_state.get().0 { + if !queen_seen && *piece == Piece::Queen { + Some(board_index) + } else if !drone_seen && *piece == Piece::Drone { + Some(board_index) + } else if !pawn_seen && *piece == Piece::Pawn { + Some(board_index) + } else { + None + } + } else { + None + } + }) + .iter() + .for_each(|hilight_index| { + valid_moves + .iter_mut() + .filter(|(_, board_index)| board_index == hilight_index) + .for_each(|(mut vis, _)| *vis = Visibility::Inherited); + }); TutorialState::PieceIntro } };