generated from PlexSheep/rs-base
automatic cargo CI changes
cargo devel CI / cargo CI (push) Successful in 41s
Details
cargo devel CI / cargo CI (push) Successful in 41s
Details
This commit is contained in:
parent
da9a7cd036
commit
6158043a60
|
@ -71,11 +71,7 @@ fn main() -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if response.won() {
|
if response.won() {
|
||||||
println!(
|
println!("You win! You took {} guesses.", game.step() - 1);
|
||||||
"You win! You took {} guesses. {:?}",
|
|
||||||
game.step() - 1,
|
|
||||||
game.solution()
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
println!("You lose! The solution was {:?}.", game.solution());
|
println!("You lose! The solution was {:?}.", game.solution());
|
||||||
}
|
}
|
||||||
|
@ -88,9 +84,6 @@ fn get_word(_cli: &Cli, step: usize) -> std::io::Result<Word> {
|
||||||
let stdin = std::io::stdin();
|
let stdin = std::io::stdin();
|
||||||
let mut stdout = std::io::stdout();
|
let mut stdout = std::io::stdout();
|
||||||
|
|
||||||
// TODO: get user input
|
|
||||||
// TODO: validate user input
|
|
||||||
|
|
||||||
print!("guess {step} > ");
|
print!("guess {step} > ");
|
||||||
stdout.flush()?;
|
stdout.flush()?;
|
||||||
stdin.read_line(&mut word)?;
|
stdin.read_line(&mut word)?;
|
||||||
|
|
|
@ -94,7 +94,7 @@ impl<'wl, WL: WordList> Game<'wl, WL> {
|
||||||
for (idx, c) in guess.chars().enumerate() {
|
for (idx, c) in guess.chars().enumerate() {
|
||||||
if compare_solution.chars().nth(idx) == Some(c) {
|
if compare_solution.chars().nth(idx) == Some(c) {
|
||||||
status = Status::Matched;
|
status = Status::Matched;
|
||||||
compare_solution.replace_range(idx..idx+1, "_");
|
compare_solution.replace_range(idx..idx + 1, "_");
|
||||||
} else if compare_solution.contains(c) {
|
} else if compare_solution.contains(c) {
|
||||||
status = Status::Exists;
|
status = Status::Exists;
|
||||||
compare_solution = compare_solution.replacen(c, "_", 1);
|
compare_solution = compare_solution.replacen(c, "_", 1);
|
||||||
|
|
Loading…
Reference in New Issue