From 0db00efc4f6d978e87bb86fa6a4464d6dcb02c10 Mon Sep 17 00:00:00 2001 From: kirbylife Date: Fri, 13 Oct 2023 00:45:12 -0600 Subject: [PATCH] Fix the message when you don't find the word --- src/components/result_board.rs | 26 +++++++++++++++++++------- src/main.rs | 2 +- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/components/result_board.rs b/src/components/result_board.rs index d5de789..59fdf67 100644 --- a/src/components/result_board.rs +++ b/src/components/result_board.rs @@ -1,30 +1,40 @@ -use crate::consts::MAX_ATTEMPTS; +use crate::consts::{GameResult, MAX_ATTEMPTS}; use yew::prelude::*; use crate::consts::{Attempts, Status}; #[derive(Properties, PartialEq)] pub struct ResultBoardProps { + pub result: GameResult, pub attempts: Attempts, } #[function_component] pub fn ResultBoard(props: &ResultBoardProps) -> Html { let ResultBoardProps { + result, attempts, } = props; + let game_result_text = match result { + GameResult::Win => { + format!("Palabra encontrada en {}/{} intentos", attempts.fields.len(), MAX_ATTEMPTS) + } + GameResult::Fail => { + format!("Palabra no encontrada :c") + } + }; + html! {
-

- { format!("Palabra encontrada en {}/{} intentos", attempts.fields.len(), MAX_ATTEMPTS) } -


-

{ +

{ game_result_text }

+
+

{ for attempts.fields.iter().map(|attempt| { html_nested! { <> { for attempt.iter().map(| att| { match att.status { - Status::Found => html_nested! { <> { "🟩" } }, + Status::Found => html_nested! { <>{ "🟩" } }, Status::Almost => html_nested! { <>{ "🟨" } }, Status::NotFound => html_nested! { <>{ "⬛" } } @@ -33,7 +43,9 @@ pub fn ResultBoard(props: &ResultBoardProps) -> Html { }
} }) - }

+ }

+
+

{ "Vuelve mañana para otro reto" }

} } diff --git a/src/main.rs b/src/main.rs index ddd237f..b9c58c3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -53,7 +53,7 @@ fn App() -> Html {
{ match *board.result { - Some(_) => html! { }, + Some(result) => html! { }, None => html! { }