Skip to content
Snippets Groups Projects
Commit ba0e8cde authored by Jason Hiser's avatar Jason Hiser :tractor:
Browse files

Make hangman easier to use up all your turns so afl can very very easily find the 'crash'

parent 389f5052
Branches add-u24
No related tags found
No related merge requests found
Pipeline #31000 failed
......@@ -33,28 +33,51 @@ fn main() {
process::exit(1);
}
};
println!("Your guess is: {} ", guess);
if guess.len() == 0 {
println!("You didn't guess anything, thus you lose.");
break;
}
if guess.len() != 1 {
continue;
println!("you guessed more than 1 char at a time, lose a turn ");
tries -= 1;
println!("42/tries = {}.", 42/tries);
println!("You have {} tries left.", tries);
continue;
}
let mut found = false;
let mut in_word = false;
for (i, c) in secret_word.chars().enumerate() {
if guess.chars().next().unwrap() == c {
found = true;
if word_progress[i] != c
{
println!("Found a new letter, good job!");
found = true;
}
in_word = true;
word_progress[i] = c;
}
}
if !found {
if !in_word {
tries -= 1;
println!("42/tries = {}.", 42/tries);
println!("Wrong! You have {} tries left.", tries);
continue;
}
if !found {
tries -= 1;
println!("42/tries = {}.", 42/tries);
println!("You already guessed that. You have {} tries left.", tries);
continue;
}
else
{
println!("42/tries = {}.", 42/tries);
println!("That letter is in the word! You have {} tries left.", tries);
}
if !word_progress.contains(&'_') {
println!("You win! The word was {}.", secret_word);
......@@ -66,5 +89,6 @@ fn main() {
break;
}
}
println!("No more guesses have been found, you lose");
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment