Merge pull request #32 from itsscb/feature
feat(frontend): improves current_status chore: updates nix flake
This commit is contained in:
commit
540b86ba1f
12
flake.lock
generated
12
flake.lock
generated
@ -20,11 +20,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1724748588,
|
"lastModified": 1725534445,
|
||||||
"narHash": "sha256-NlpGA4+AIf1dKNq76ps90rxowlFXUsV9x7vK/mN37JM=",
|
"narHash": "sha256-Yd0FK9SkWy+ZPuNqUgmVPXokxDgMJoGuNpMEtkfcf84=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "a6292e34000dc93d43bccf78338770c1c5ec8a99",
|
"rev": "9bb1e7571aadf31ddb4af77fc64b2d59580f9a39",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -62,11 +62,11 @@
|
|||||||
"nixpkgs": "nixpkgs_2"
|
"nixpkgs": "nixpkgs_2"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1724811750,
|
"lastModified": 1725589472,
|
||||||
"narHash": "sha256-PvhVgQ1rm3gfhK7ts4emprhh/KMkFwXogmgsQ3srR7g=",
|
"narHash": "sha256-+OB00N6Yql/ZRQQkQ0PNnxfW2tH89DHnv29hBS7tXMM=",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "6a1c4915dca7149e7258d8c7f3ac634d8c65f6c6",
|
"rev": "2b00881d2ff72174cffdc007238cb6bedd6e1d8e",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -83,31 +83,29 @@ impl Game {
|
|||||||
pub fn current_status(&self) -> Status {
|
pub fn current_status(&self) -> Status {
|
||||||
self.word.as_ref().map_or(Status::New, |_| {
|
self.word.as_ref().map_or(Status::New, |_| {
|
||||||
let word_count = self.submitted_words.len();
|
let word_count = self.submitted_words.len();
|
||||||
if self.tries == 0 {
|
match self.tries {
|
||||||
Status::New
|
0 => Status::New,
|
||||||
} else if self.tries < MAX_TRIES {
|
1..MAX_TRIES => self
|
||||||
if self
|
|
||||||
.submitted_words
|
.submitted_words
|
||||||
.last()
|
.last()
|
||||||
.unwrap()
|
.map_or(Status::InProgress, |words| {
|
||||||
.iter()
|
if words.iter().all(|v| matches!(v, CharStatus::Match(_))) {
|
||||||
.all(|v| matches!(v, CharStatus::Match(_)))
|
|
||||||
{
|
|
||||||
Status::Win(word_count)
|
Status::Win(word_count)
|
||||||
} else {
|
} else {
|
||||||
Status::InProgress
|
Status::InProgress
|
||||||
}
|
}
|
||||||
} else if self
|
}),
|
||||||
|
_ => self
|
||||||
.submitted_words
|
.submitted_words
|
||||||
.last()
|
.last()
|
||||||
.unwrap()
|
.map_or(Status::Lose(word_count), |words| {
|
||||||
.iter()
|
if words.iter().all(|v| matches!(v, CharStatus::Match(_))) {
|
||||||
.all(|v| matches!(v, CharStatus::Match(_)))
|
|
||||||
{
|
|
||||||
Status::Win(word_count)
|
Status::Win(word_count)
|
||||||
} else {
|
} else {
|
||||||
Status::Lose(word_count)
|
Status::Lose(word_count)
|
||||||
}
|
}
|
||||||
|
}),
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user