use std::{ sync::{ atomic::{AtomicBool, AtomicU32, Ordering::SeqCst}, Arc, Mutex, MutexGuard, }, time::Duration, }; use anyhow::Result; use assetpath::AssetPath; use engine::prelude::{cgmath::vec3, *}; use crate::{ board::{Board, BoardSlot, BoardSlotState}, objects::Objects, simple_ai::SimpleAI, }; #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] pub enum StoneState { ReadyToBePlaced, Placed, Dead, } pub struct Stone { pub stone: Entity, pub state: StoneState, } #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] pub enum GameState { Waiting, Placing, Removing, Main, } #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] pub enum PlayerColor { White, Black, } #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] pub enum MillState { White, Black, None, } pub enum LogSeverity { Basic, Debug, } const LOG_SEVERITY: LogSeverity = LogSeverity::Basic; impl PlayerColor { pub fn swap(&mut self) { *self = match *self { PlayerColor::White => { MillGame::log("swapped to black player", LogSeverity::Debug); PlayerColor::Black } PlayerColor::Black => { MillGame::log("swapped to white player", LogSeverity::Debug); PlayerColor::White } } } pub fn other(&self) -> Self { match self { PlayerColor::White => PlayerColor::Black, PlayerColor::Black => PlayerColor::White, } } } pub struct MillGame { engine: Arc, last_turn_timing: Mutex, board: Arc>, white_stones: Mutex<[Stone; 9]>, black_stones: Mutex<[Stone; 9]>, state: Mutex, current_player: Mutex, scene: Mutex, camera_controls: Mutex, mouse_x: AtomicU32, mouse_y: AtomicU32, turn_finished: AtomicBool, selected_field: Mutex>, simple_ai: SimpleAI, white_player_label: Arc