From f1cd36952b5f2f5d3043ececbebcd29e76fc1890 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sun, 25 Feb 2024 09:52:49 -0800 Subject: [PATCH] Fix build errors in explorer --- explorer/Cargo.toml | 1 + explorer/src/main.rs | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/explorer/Cargo.toml b/explorer/Cargo.toml index 3281cf4..9689332 100644 --- a/explorer/Cargo.toml +++ b/explorer/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" [dependencies] chessfriend_core = { path = "../core" } +chessfriend_moves = { path = "../moves" } chessfriend_position = { path = "../position" } clap = { version = "4.4.12", features = ["derive"] } rustyline = "13.0.0" diff --git a/explorer/src/main.rs b/explorer/src/main.rs index 8edb00e..5b8a17d 100644 --- a/explorer/src/main.rs +++ b/explorer/src/main.rs @@ -1,5 +1,8 @@ +// Eryn Wells + use chessfriend_core::{Color, Piece, PlacedPiece, Shape, Square}; -use chessfriend_position::{fen::ToFen, MakeMoveBuilder, MoveBuilder, Position, PositionBuilder}; +use chessfriend_moves::Builder as MoveBuilder; +use chessfriend_position::{fen::ToFen, MakeMoveBuilder, Position, PositionBuilder}; use clap::{Arg, Command}; use rustyline::error::ReadlineError; use rustyline::DefaultEditor; @@ -97,16 +100,15 @@ fn respond(line: &str, state: &mut State) -> Result { ) .map_err(|_| "Error: invalid square specifier")?; - let mv = MoveBuilder::new( - Piece::new(state.position.player_to_move(), shape), - from_square, - to_square, - ) - .build(); + let mv = MoveBuilder::new() + .from(from_square) + .to(to_square) + .build() + .map_err(|err| format!("Error: cannot build move: {:?}", err))?; state.position = MakeMoveBuilder::new(&state.position) .make(&mv) - .map_err(|err| format!("error: Cannot make move: {:?}", err))? + .map_err(|err| format!("Error: cannot make move: {:?}", err))? .build(); state.builder = PositionBuilder::from_position(&state.position); }