Change fn string_from_board to accept board ref
This commit is contained in:
parent
f799bae530
commit
a4bf4cbd25
2 changed files with 4 additions and 4 deletions
|
@ -857,7 +857,7 @@ impl DBHandler {
|
|||
}
|
||||
|
||||
// board back to string
|
||||
let (board_string, ended_state_opt) = string_from_board(board, final_pos);
|
||||
let (board_string, ended_state_opt) = string_from_board(&board, final_pos);
|
||||
|
||||
// update DB
|
||||
let update_result = if ended_state_opt.is_none() {
|
||||
|
@ -1004,7 +1004,7 @@ impl DBHandler {
|
|||
});
|
||||
|
||||
// get board string from board while checking if game has ended
|
||||
let (board_string, end_state_opt) = string_from_board(board, ai_choice_pos);
|
||||
let (board_string, end_state_opt) = string_from_board(&board, ai_choice_pos);
|
||||
|
||||
let state;
|
||||
if let Some(board_state) = end_state_opt {
|
||||
|
|
|
@ -456,12 +456,12 @@ pub fn board_from_string(board_string: String) -> BoardType {
|
|||
|
||||
/// Returns the board as a String, and None if game has not ended, Empty if game
|
||||
/// ended in a draw, or a player if that player has won
|
||||
pub fn string_from_board(board: BoardType, placed: usize) -> (String, Option<BoardState>) {
|
||||
pub fn string_from_board(board: &BoardType, placed: usize) -> (String, Option<BoardState>) {
|
||||
let mut board_string = String::with_capacity(56);
|
||||
|
||||
// check for winning pieces
|
||||
let mut win_set: HashSet<usize> = HashSet::new();
|
||||
let win_opt = check_win_draw(&board);
|
||||
let win_opt = check_win_draw(board);
|
||||
if let Some((_board_state, win_type)) = win_opt {
|
||||
match win_type {
|
||||
WinType::Horizontal(pos) => {
|
||||
|
|
Loading…
Reference in a new issue