Fixed "reject move" logic.

Added a system for tracking a pieces last move, which is not
necessary...
main
Elijah C. Voigt 2 years ago
parent 438358aab2
commit 983314faac

@ -207,11 +207,6 @@ pub(crate) struct BoardIndex {
pub y: usize, pub y: usize,
} }
#[derive(Debug, Component, PartialEq, Clone, Default, Copy, Eq, Hash)]
pub(crate) struct Previous {
board_index: BoardIndex,
}
#[derive(Debug, Component, PartialEq, Clone, Copy)] #[derive(Debug, Component, PartialEq, Clone, Copy)]
pub(crate) enum Side { pub(crate) enum Side {
A, A,
@ -367,7 +362,7 @@ impl Board {
} }
}; };
if valid_capture { if valid_capture {
// You cannot move a piece from SideB->SideA when it was just moved from SideA->SideB // You cannot move a piece from A to B and then back to A when it was just moved from SideA->SideB
// Move rejection is not allowed // Move rejection is not allowed
let rejection = { let rejection = {
if let Some(Move { if let Some(Move {
@ -378,8 +373,8 @@ impl Board {
{ {
// TODO: I think this is more logic than we need to express // TODO: I think this is more logic than we need to express
// the sentiment... // the sentiment...
Board::side(*last_from) == Board::side(this_board_index) *last_from == this_board_index
&& Board::side(*last_to) == Board::side(current_board_index) && *last_to == current_board_index
&& Board::side(this_board_index) && Board::side(this_board_index)
!= Board::side(current_board_index) != Board::side(current_board_index)
} else { } else {
@ -485,8 +480,8 @@ fn setup_board(mut commands: Commands) {
inner: vec![ inner: vec![
vec![ vec![
Some(Queen), Some(Queen),
None, // Some(Queen), Some(Queen),
None, // Some(Drone), Some(Drone),
None, None,
None, None,
None, None,
@ -494,24 +489,24 @@ fn setup_board(mut commands: Commands) {
None, None,
], ],
vec![ vec![
None, // Some(Queen), Some(Queen),
None, // Some(Drone), Some(Drone),
None, // Some(Pawn), Some(Pawn),
None, // None, None,
None, // None, None,
None, // Some(Pawn), Some(Pawn),
None, // Some(Pawn), Some(Pawn),
None, // Some(Drone), Some(Drone),
], ],
vec![ vec![
None, // Some(Drone), Some(Drone),
None, // Some(Pawn), Some(Pawn),
None, // Some(Pawn), Some(Pawn),
None, // None, None,
None, // None, None,
None, // Some(Pawn), Some(Pawn),
None, // Some(Drone), Some(Drone),
None, // Some(Queen), Some(Queen),
], ],
vec![ vec![
None, None,
@ -519,8 +514,8 @@ fn setup_board(mut commands: Commands) {
None, None,
None, None,
None, None,
None, // Some(Drone), Some(Drone),
None, // Some(Queen), Some(Queen),
Some(Queen), Some(Queen),
], ],
], ],
@ -578,14 +573,6 @@ pub(crate) fn update_board(
*played = false; *played = false;
} }
// Track the last spot that a piece was at
fn track_previous_move(
events: Query<&BoardIndex, (With<Piece>, Changed<BoardIndex>)>,
mut commands: Commands,
) {
todo!()
}
#[derive(Debug, Component)] #[derive(Debug, Component)]
struct Endgame; struct Endgame;

Loading…
Cancel
Save