Don't include final 5 in row sum
This commit is contained in:
parent
80865ace7d
commit
1213b0bd8f
2 changed files with 15 additions and 16 deletions
|
|
@ -1,7 +1,7 @@
|
|||
/* https://pajasevi.github.io/CSSnowflakes/ */
|
||||
.snowflake {
|
||||
color: #fff;
|
||||
font-size: 1em;
|
||||
font-size: 1.5em;
|
||||
font-family: Arial, sans-serif;
|
||||
text-shadow: 0 0 5px #000;
|
||||
}
|
||||
|
|
|
|||
29
src/main.rs
29
src/main.rs
|
|
@ -53,6 +53,7 @@ fn main() {
|
|||
fn App() -> Element {
|
||||
let mut rows = use_signal(State::default);
|
||||
let longest = use_memo(move || rows.read().longest());
|
||||
let row_finished = use_memo(move || rows.read().row_finished());
|
||||
let snow = true;
|
||||
rsx! {
|
||||
document::Link { rel: "icon", href: FAVICON }
|
||||
|
|
@ -82,7 +83,7 @@ fn App() -> Element {
|
|||
}
|
||||
tbody {
|
||||
tr {
|
||||
th { colspan: 100, "Game 1" }
|
||||
th { colspan: 100, "Why 5?" }
|
||||
}
|
||||
for row in &rows.read().rows {
|
||||
tr {
|
||||
|
|
@ -91,12 +92,16 @@ fn App() -> Element {
|
|||
}
|
||||
td {
|
||||
class: "number",
|
||||
colspan: (max(19, longest()).saturating_sub(row.len())).to_string()
|
||||
colspan: (max(19, longest() + 1).saturating_sub(row.len())).to_string()
|
||||
}
|
||||
td {
|
||||
class: "number",
|
||||
b {
|
||||
{row.iter().copied().sum::<u16>().to_string()}
|
||||
if row.len() <= 1 {
|
||||
{row.iter().sum::<u16>().to_string()}
|
||||
} else {
|
||||
{row.iter().take_while(|&&n| n != 5).sum::<u16>().to_string()}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -105,21 +110,15 @@ fn App() -> Element {
|
|||
}
|
||||
div {
|
||||
class: "controls",
|
||||
if rows.read().row_finished() {
|
||||
div {
|
||||
class: "number-buttons",
|
||||
for n in 1..=6 {
|
||||
button { disabled: true, "{n}" }
|
||||
}
|
||||
div {
|
||||
class: "number-buttons",
|
||||
for n in 1..=6 {
|
||||
button { disabled: row_finished(), "{n}" }
|
||||
}
|
||||
}
|
||||
if row_finished() {
|
||||
button { onclick: move |_| rows.write().new_row(), "Start new row" }
|
||||
} else {
|
||||
div {
|
||||
class: "number-buttons",
|
||||
for n in 1..=6 {
|
||||
button { onclick: move |_| rows.write().push(n), "{n}" }
|
||||
}
|
||||
}
|
||||
button { onclick: move |_| rows.write().roll(), "Roll" }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue