add gif
This commit is contained in:
parent
a700bc8e72
commit
4d6538df56
4 changed files with 14 additions and 6 deletions
|
@ -14,3 +14,8 @@ Guess commands are character sequences you can guess to do additional behavior.
|
|||
|command|description|
|
||||
|---|---|
|
||||
|!ans[wer]|shows the answer to the current wordle|
|
||||
|
||||
|
||||
## Screenshots
|
||||
|
||||

|
||||
|
|
|
@ -9,6 +9,7 @@ mod wordle;
|
|||
|
||||
use utils::str_unique_by_characters;
|
||||
use wordle::{worlde_game_make_guess, WordleState};
|
||||
use crate::utils::clear_screen;
|
||||
|
||||
fn generate_wordle_dictionary() -> HashSet<String> {
|
||||
let existing_path = "./dictionaries/output/five_letter_words.txt";
|
||||
|
@ -90,10 +91,12 @@ fn main() {
|
|||
.filter(|x| str_unique_by_characters(x))
|
||||
.map(|w| w)
|
||||
.collect();
|
||||
let worlde_answer = unique_words.choose(&mut rand::thread_rng()).unwrap();
|
||||
let worlde_answer = String::from("EXAMS"); //unique_words.choose(&mut rand::thread_rng()).unwrap();
|
||||
|
||||
let mut wordle_game_state = WordleState::new(worlde_answer.as_str());
|
||||
|
||||
|
||||
clear_screen();
|
||||
loop {
|
||||
let mut input;
|
||||
|
||||
|
@ -112,6 +115,7 @@ fn main() {
|
|||
}
|
||||
|
||||
worlde_game_make_guess(input.as_ref(), &mut wordle_game_state);
|
||||
clear_screen();
|
||||
print!("Board:\n{}", wordle_game_state);
|
||||
if wordle_game_state.game_over() {
|
||||
break;
|
||||
|
|
|
@ -20,3 +20,7 @@ pub fn str_to_five_char(s: &str) -> [char; 5] {
|
|||
arr
|
||||
})
|
||||
}
|
||||
|
||||
pub fn clear_screen() {
|
||||
print!("\x1B[2J\x1B[1;1H");
|
||||
}
|
||||
|
|
|
@ -153,11 +153,6 @@ impl fmt::Display for WordleState {
|
|||
|
||||
pub fn worlde_game_make_guess(guess: &str, state: &mut WordleState) {
|
||||
let turn = state.guesses.iter().position(|guess| guess.is_none());
|
||||
match turn {
|
||||
Some(t) => println!("Current turn index: {}", t),
|
||||
None => println!("Game is over"),
|
||||
}
|
||||
|
||||
if turn.is_some() {
|
||||
let turn = turn.unwrap();
|
||||
state.set_guess(turn, str_to_five_char(guess));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue