The web site of oispa-tupakkaa
Welcome to my Website!
This is a paragraph! Here's how you make a link: Neocities.
Here's how you can make bold and italic text.
Here's how you can add an image:
Here's how to make a list:
- First thing
- Second thing
- Third thing
To learn more HTML/CSS, check out these tutorials!
#![feature(doc_auto_cfg)]
#![feature(let_chains)]
//! a basic engine and move validator for the game 2048
//!
//! Includes wasm functions generated with wasm_bindgen
pub mod board;
pub mod parser;
pub mod validator;
pub mod direction;
pub mod recording;
pub const DEBUG_INFO: bool = false;
#[cfg(feature = "add_random")]
use board::tile;
#[cfg(feature = "wasm")]
use wasm_bindgen::prelude::*;
#[cfg(feature = "wasm")]
#[wasm_bindgen]
pub fn parse(data: &str) -> String {
let parsed = parser::parse_data(String::from(data));
return serde_json::to_string(&parsed).unwrap();
}
#[cfg(feature = "wasm")]
#[wasm_bindgen]
pub fn get_frames(data: &str) -> String {
let parsed = parser::parse_data(String::from(data)).unwrap();
let out = parsed.history.iter().map(|x| {
let board = board::Board{ width: parsed.width, height: parsed.height, tiles: x.0 };
board.oispahalla_serialize(None)
}).collect::>();
return serde_json::to_string(&out).unwrap();
}
#[cfg(feature = "wasm")]
#[wasm_bindgen]
pub fn validate(data: &str) -> String {
let parsed = parser::parse_data(String::from(data)).unwrap();
// let first_move_valid = validator::validate_first_move(&parsed);
let history_valid = validator::validate_history(parsed);
return serde_json::to_string(&history_valid).unwrap();
}
#[cfg(feature = "wasm")]
#[wasm_bindgen]
pub fn validate_all_frames(data: &str) -> String {
let frames_src = data.split(":").collect::>();
let frame_count = frames_src.clone().len();
println!("found {} frames", frame_count);
let mut validation_results: Vec