22 lines
458 B
Rust
22 lines
458 B
Rust
|
use serde_wasm_bindgen::Error;
|
||
|
use wasm_bindgen::JsValue;
|
||
|
use wasm_bindgen::prelude::wasm_bindgen;
|
||
|
use crate::game::Game;
|
||
|
|
||
|
#[wasm_bindgen]
|
||
|
pub struct GameWasm(Game);
|
||
|
|
||
|
#[wasm_bindgen]
|
||
|
impl GameWasm {
|
||
|
|
||
|
#[wasm_bindgen(constructor)]
|
||
|
pub fn new(seed: u64) -> GameWasm {
|
||
|
GameWasm(Game::new(seed))
|
||
|
}
|
||
|
|
||
|
pub fn get_tray(&self) -> Result<JsValue, Error> {
|
||
|
let tray = self.0.get_tray();
|
||
|
|
||
|
serde_wasm_bindgen::to_value(tray)
|
||
|
}
|
||
|
}
|