fours 0.1.0

Four in a row in your terminal, with three levels of opponent.
Documentation
//! The colours the front end draws with.

use crate::game::Player;
use ratatui::style::Color;

/// The colours of the board, the discs and the text around them.
///
/// The default theme uses the bright half of the sixteen terminal colours, which keeps the board
/// readable on light and dark terminals alike and avoids putting two similar colours next to each
/// other.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Theme {
    /// The colour behind everything that is not the board.
    pub background: Color,
    /// The face of the board.
    pub board: Color,
    /// The face of the column the player is pointing at.
    pub board_highlight: Color,
    /// The frame around the board.
    pub board_border: Color,
    /// An empty slot in the board.
    pub hole: Color,
    /// A disc of [`Player::Red`].
    pub red_disc: Color,
    /// A disc of [`Player::Yellow`].
    pub yellow_disc: Color,
    /// The title above the board.
    pub title: Color,
    /// Ordinary text.
    pub text: Color,
    /// Text that should stay in the background, such as the key bindings.
    pub muted: Color,
    /// A remark about the last action.
    pub notice: Color,
}

impl Theme {
    /// The colour of a player's discs.
    pub const fn disc(&self, player: Player) -> Color {
        match player {
            Player::Red => self.red_disc,
            Player::Yellow => self.yellow_disc,
        }
    }
}

impl Default for Theme {
    fn default() -> Self {
        Self {
            background: Color::Reset,
            board: Color::Blue,
            board_highlight: Color::LightBlue,
            board_border: Color::LightBlue,
            hole: Color::Black,
            red_disc: Color::LightRed,
            yellow_disc: Color::LightYellow,
            title: Color::White,
            text: Color::Gray,
            muted: Color::DarkGray,
            notice: Color::LightMagenta,
        }
    }
}