use crate::board::zobrist::ZobristKey;
use crate::types::Move16;

/// Bookで利用する局面キー。
pub type BookKey = ZobristKey;

/// 定跡の1手。
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct BookMove {
    move16: Move16,
    score: i16,
    depth: u16,
}

impl BookMove {
    #[must_use]
    pub const fn new(move16: Move16, score: i16, depth: u16) -> Self {
        Self { move16, score, depth }
    }

    #[must_use]
    pub const fn move16(self) -> Move16 {
        self.move16
    }

    #[must_use]
    pub const fn score(self) -> i16 {
        self.score
    }

    #[must_use]
    pub const fn depth(self) -> u16 {
        self.depth
    }
}

/// 参照専用の定跡エントリー。
#[derive(Clone, Copy, Debug)]
pub struct BookEntry<'a> {
    key: BookKey,
    moves: &'a [BookMove],
}

impl<'a> BookEntry<'a> {
    #[must_use]
    pub const fn new(key: BookKey, moves: &'a [BookMove]) -> Self {
        Self { key, moves }
    }

    #[must_use]
    pub const fn key(self) -> BookKey {
        self.key
    }

    #[must_use]
    pub const fn moves(self) -> &'a [BookMove] {
        self.moves
    }
}
