diff --git a/.gitignore b/.gitignore index 91b8835..6e1a9fe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /target /Cargo.lock .idea/ +pkg/ \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 8b37f87..b477739 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,8 +3,11 @@ name = "word_grid" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lib] +crate-type = ["cdylib"] [dependencies] csv = "1.2.2" rand = {version = "0.8.5", features = ["small_rng"]} +getrandom = {version = "0.2", features = ["js"]} +wasm-bindgen = "0.2.87" \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 3df9d6c..ea1fb99 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,14 @@ +use wasm_bindgen::prelude::wasm_bindgen; pub mod constants; pub mod board; pub mod dictionary; pub mod player_interaction; + +#[wasm_bindgen] +pub fn return_option(some: bool) -> Option { + if some { + Some("Heyo".to_string()) + } else {None} +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs deleted file mode 100644 index 0fdba7c..0000000 --- a/src/main.rs +++ /dev/null @@ -1,24 +0,0 @@ -use word_grid::board::{Board, Coordinates, Letter}; - -fn main() { - let mut board = Board::new(); - - let c1 = board.get_cell_mut(Coordinates(8, 6)).unwrap(); - c1.value = Some(Letter::new_fixed( 'J', 0)); - board.get_cell_mut(Coordinates(8, 7)).unwrap().value = Some(Letter::new_fixed('o', 0)); - board.get_cell_mut(Coordinates(8, 8)).unwrap().value = Some(Letter::new_fixed( 'e', 0)); - board.get_cell_mut(Coordinates(8, 9)).unwrap().value = Some(Letter::new_fixed( 'l', 0)); - - board.get_cell_mut(Coordinates(9, 8)).unwrap().value = Some(Letter::new_fixed( 'i', 0)); - board.get_cell_mut(Coordinates(9, 9)).unwrap().value = Some(Letter::new_fixed( 's', 0)); - - board.get_cell_mut(Coordinates(10, 8)).unwrap().value = Some(Letter::new_fixed( 'c', 0)); - board.get_cell_mut(Coordinates(10, 9)).unwrap().value = Some(Letter::new_fixed( 'o', 0)); - board.get_cell_mut(Coordinates(10, 10)).unwrap().value = Some(Letter::new_fixed( 'o', 0)); - board.get_cell_mut(Coordinates(10, 11)).unwrap().value = Some(Letter::new_fixed( 'l', 0)); - - println!("{}", board); - - //println!("\x1b[38;5;196m Hello my name is Joel"); - //println!("\x1b[48;5;20m Hello my name is Joel"); -} \ No newline at end of file