1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//! Draught
//! 
//! An implementation of checkers/draughts in Rust WebAssembly with a minimax AI player

pub mod board;
pub mod utils;
pub mod game;
pub mod paint;
pub mod comp;

extern crate wasm_bindgen;
use wasm_bindgen::prelude::*;

pub use board::Board;
pub use game::Game;
pub use comp::Computer;
pub use paint::Painter;

/// Wrap the [`web_sys`] access to the browser console in a macro for easy logging
#[macro_export]
macro_rules! log {
    ( $( $t:tt )* ) => {
        web_sys::console::log_1(&format!( $( $t )* ).into());
    }
}
#[macro_export]
macro_rules! log_error {
    ( $( $t:tt )* ) => {
        web_sys::console::error_1(&format!( $( $t )* ).into());
    }
}

#[wasm_bindgen]
pub fn init_wasm() {
    log!("Initialising WebAssembly");
    utils::set_panic_hook();
}