diff --git a/CHANGELOG.md b/CHANGELOG.md index 473f481..3dae27b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,22 @@ # Changelog All notable changes to this project will be documented in this file. + +## v1.8 - 2022-01-22 + +### Added +- User can now switch between different game modes and settings without losing the old game state or streaks +- Lots of internal refactoring to how game state is persisted + +### Changed +- Profanities are now disallowed by default +- Streaks are now per game mode, and you can no longer cheat and restart the word by changing settings + - This unfortunately also means that some users will lose their current streak if daily game mode was the last selected mode. Sorry. + +### Fixed +- Animation when sixth word is correct and new game is started + + ## v1.7 - 2022-01-16 ### Added diff --git a/Cargo.lock b/Cargo.lock index 8a69d52..6420f2e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -36,6 +36,7 @@ dependencies = [ "libc", "num-integer", "num-traits", + "serde", "time", "wasm-bindgen", "winapi", @@ -342,7 +343,10 @@ version = "0.1.0" dependencies = [ "chrono", "getrandom", + "gloo-storage", "rand", + "serde", + "serde_json", "serde_scan", "wasm-bindgen", "web-sys", @@ -357,18 +361,18 @@ checksum = "c2e9d7eaddb227e8fbaaa71136ae0e1e913ca159b86c7da82f3e8f0044ad3a63" [[package]] name = "serde" -version = "1.0.132" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b9875c23cf305cd1fd7eb77234cbb705f21ea6a72c637a5c6db5fe4b8e7f008" +checksum = "97565067517b60e2d1ea8b268e59ce036de907ac523ad83a0475da04e818989a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.132" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc0db5cb2556c0e558887d9bbdcf6ac4471e83ff66cf696e5419024d1606276" +checksum = "ed201699328568d8d08208fdd080e3ff594e6c422e438b6705905da01005d537" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index cea3c29..1da531b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,10 +11,16 @@ serde_scan = "0.4.1" rand = "0.8.4" getrandom = { version = "0.2", features = ["js"] } wasm-bindgen = "0.2.78" +serde_json = "1.0" +gloo-storage = "0.2.0" + +[dependencies.serde] +version = "1.0" +features = ["derive"] [dependencies.chrono] version = "0.4" -features = ["wasmbind"] +features = ["wasmbind", "serde"] [dependencies.web-sys] version = "0.3" diff --git a/src/components/header.rs b/src/components/header.rs index 07cefe9..2d34223 100644 --- a/src/components/header.rs +++ b/src/components/header.rs @@ -34,7 +34,7 @@ pub fn header(props: &Props) -> Html {
{ - if props.game_mode == GameMode::DailyWord { + if let GameMode::DailyWord(_) = props.game_mode { html! {

{format!("Päivän sanuli #{}", props.daily_word_number)}

} } else if props.streak > 0 { html! {

{format!("Sanuli — Putki: {}", props.streak)}

} diff --git a/src/components/keyboard.rs b/src/components/keyboard.rs index 11f90f6..4b66f8a 100644 --- a/src/components/keyboard.rs +++ b/src/components/keyboard.rs @@ -117,7 +117,7 @@ pub fn keyboard(props: &Props) -> Html { { "ARVAA" } } - } else if props.game_mode == GameMode::DailyWord { + } else if let GameMode::DailyWord(_) = props.game_mode { let callback = props.callback.clone(); let onmousedown = Callback::from(move |e: MouseEvent| { e.prevent_default(); @@ -134,7 +134,7 @@ pub fn keyboard(props: &Props) -> Html { let callback = props.callback.clone(); let onmousedown = Callback::from(move |e: MouseEvent| { e.prevent_default(); - callback.emit(Msg::NewGame); + callback.emit(Msg::NextWord); }); html! { diff --git a/src/components/modal.rs b/src/components/modal.rs index ce51a51..3e7b033 100644 --- a/src/components/modal.rs +++ b/src/components/modal.rs @@ -1,11 +1,12 @@ use yew::prelude::*; +use chrono::{Local}; use crate::state::{GameMode, WordList, Theme}; use crate::Msg; const FORMS_LINK_TEMPLATE_ADD: &str = "https://docs.google.com/forms/d/e/1FAIpQLSfH8gs4sq-Ynn8iGOvlc99J_zOG2rJEC4m8V0kCgF_en3RHFQ/viewform?usp=pp_url&entry.461337706=Lis%C3%A4yst%C3%A4&entry.560255602="; const CHANGELOG_URL: &str = "https://github.com/Cadiac/sanuli/blob/master/CHANGELOG.md"; -const VERSION: &str = "v1.7"; +const VERSION: &str = "v1.8"; macro_rules! onmousedown { ( $cb:ident, $msg:expr ) => { @@ -86,12 +87,14 @@ pub struct MenuModalProps { pub fn menu_modal(props: &MenuModalProps) -> Html { let callback = props.callback.clone(); + let today = Local::now().naive_local().date(); + let toggle_menu = onmousedown!(callback, Msg::ToggleMenu); let change_word_length_5 = onmousedown!(callback, Msg::ChangeWordLength(5)); let change_word_length_6 = onmousedown!(callback, Msg::ChangeWordLength(6)); let change_game_mode_classic = onmousedown!(callback, Msg::ChangeGameMode(GameMode::Classic)); let change_game_mode_relay = onmousedown!(callback, Msg::ChangeGameMode(GameMode::Relay)); - let change_game_mode_daily = onmousedown!(callback, Msg::ChangeGameMode(GameMode::DailyWord)); + let change_game_mode_daily = onmousedown!(callback, Msg::ChangeGameMode(GameMode::DailyWord(today))); let change_word_list_full = onmousedown!(callback, Msg::ChangeWordList(WordList::Full)); let change_word_list_common = onmousedown!(callback, Msg::ChangeWordList(WordList::Common)); let change_allow_profanities_yes = onmousedown!(callback, Msg::ChangeAllowProfanities(true)); @@ -99,48 +102,58 @@ pub fn menu_modal(props: &MenuModalProps) -> Html { let change_theme_dark = onmousedown!(callback, Msg::ChangeTheme(Theme::Dark)); let change_theme_colorblind = onmousedown!(callback, Msg::ChangeTheme(Theme::Colorblind)); + let is_daily_word = matches!(props.game_mode, GameMode::DailyWord(_)); + html! {