[board, explorer, position] Clean up naming of sight and movement methods

These methods have a prefix, either `sight` or `movement`, and then follow the conventions
for other "trio" clusters where there's an un-suffixed method that takes an
Option<Color>, a _active method that uses the active color, and a _unwrapped
method that takes a bare Color.
This commit is contained in:
Eryn Wells 2025-06-29 09:23:20 -07:00
parent e7fd65672d
commit a30553503f
4 changed files with 42 additions and 25 deletions

View file

@ -65,7 +65,7 @@ fn command_line() -> Command {
)
.subcommand(
Command::new("sight")
.arg(Arg::new("square").required(true))
.arg(Arg::new("square").required(false))
.about("Show sight of a piece on a square"),
)
.subcommand(
@ -163,12 +163,12 @@ fn respond(line: &str, state: &mut State) -> anyhow::Result<CommandResult> {
.place_piece(piece, square, PlacePieceStrategy::default())?;
}
Some(("sight", matches)) => {
let square = matches
.get_one::<String>("square")
.ok_or(CommandHandlingError::MissingArgument("square"))?;
let square = square.parse::<Square>()?;
let sight = state.position.sight(square);
let sight = if let Some(square) = matches.get_one::<String>("square") {
let square: Square = square.parse()?;
state.position.sight_piece(square)
} else {
state.position.sight_active()
};
let display = state.position.display().highlight(sight);
println!("\n{display}");
@ -331,7 +331,7 @@ fn do_movement_command(
.get_one::<Square>("square")
.ok_or(CommandHandlingError::MissingArgument("square"))?;
let movement = state.position.movement(square);
let movement = state.position.movement_piece(square);
let display = state.position.display().highlight(movement);
println!("\n{display}");