1
0
mirror of https://gitlab.com/MisterBiggs/wordle-rs.git synced 2025-06-15 21:46:41 +00:00

basic login implemented

This commit is contained in:
MisterBiggs 2022-02-09 15:38:01 -07:00
parent 4ded67039a
commit 5b87589478
3 changed files with 19 additions and 20 deletions

9
Cargo.lock generated
View File

@ -2,15 +2,6 @@
# It is not intended for manual editing.
version = 3
[[package]]
name = "owo-colors"
version = "3.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20448fd678ec04e6ea15bbe0476874af65e98a01515d667aa49f1434dc44ebf4"
[[package]]
name = "wordlers"
version = "0.1.0"
dependencies = [
"owo-colors",
]

View File

@ -6,4 +6,4 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
owo-colors = "3.2.0"
# owo-colors = "3.2.0"

View File

@ -8,9 +8,17 @@ fn main() {
.map(|word| word.trim().to_lowercase())
.collect::<Vec<String>>();
let mut exact = "ak..";
let mut close: Vec<(char, usize)> = vec![('a', 2)];
let mut banned = "ponieu";
let exact = ".u...";
let close: Vec<(char, usize)> = vec![
('.', 0),
('m', 0),
('o', 1),
('h', 2),
('u', 3),
('r', 2),
('o', 4),
];
let banned = "ptbenisa";
words = words
.iter()
@ -43,10 +51,11 @@ fn check_exact(word: &String, exact: &str) -> bool {
}
fn check_close(word: &String, close: &Vec<(char, usize)>) -> bool {
let mut w = word.chars();
for (character, index) in close {
if character.to_owned() == w.nth(index - 1).unwrap() {
if *character == '.' {
continue;
}
if *character == word.chars().nth(*index).unwrap() {
return false;
}
}
@ -73,10 +82,9 @@ fn word_value(word: &String) -> usize {
}
}
// TODO: reimplement after needs uses letter index
// if word.chars().last().unwrap() == 's' {
// value = value + 3;
// }
if word.chars().last().unwrap() == 's' {
value = value + 3;
}
return value;
}