From cd0667b4c6d06b5bd23b7be704b375c16ed02cc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Merryweather=20=CE=BC?= Date: Thu, 29 Feb 2024 01:31:36 -0600 Subject: [PATCH 1/4] Vietnamese removal, example add - Vietnamese was unfortunately removed from available languages. - Changed examples around and added an extra one that provides an example of a guessing game with the characters. --- examples/fetch_student.rs | 4 +++- examples/guessing_game.rs | 28 ++++++++++++++++++++++++++++ src/enums.rs | 2 -- tests/raids_from_langs.rs | 1 - tests/students_from_langs.rs | 1 - tests/summons_from_langs.rs | 1 - 6 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 examples/guessing_game.rs diff --git a/examples/fetch_student.rs b/examples/fetch_student.rs index 9b481e6..ab1bea4 100644 --- a/examples/fetch_student.rs +++ b/examples/fetch_student.rs @@ -7,11 +7,12 @@ async fn main() -> anyhow::Result<()> { let hina = (blue_archive::fetch_student_by_name("Hina", Language::English).await?).unwrap(); // Let us print some important details of Hina! - let header = format!("|:: {} : Details", hina.full_name_last()); + let header = hina.full_name_last().to_string(); println!("{header}"); println!("{}", "-".repeat(header.len())); let segments = [ ("age", format!("{}", hina.age())), + ("birthday", hina.birthday.to_string()), ("school", format!("{}", hina.school())), ("club", format!("{}", hina.club())), ("armor", format!("{}", hina.armor())), @@ -24,6 +25,7 @@ async fn main() -> anyhow::Result<()> { hina.bullet_type() ), ), + ("designer", hina.designer.to_string()), ]; let max = segments.iter().map(|(n, _)| n.len()).max().unwrap(); segments.map(|(name, details)| println!("{}{name}: {}", " ".repeat(max - name.len()), details)); diff --git a/examples/guessing_game.rs b/examples/guessing_game.rs new file mode 100644 index 0000000..a6a98c7 --- /dev/null +++ b/examples/guessing_game.rs @@ -0,0 +1,28 @@ +use blue_archive::Language; +use rand::Rng; + +fn read_line_to_buffer(buffer: &mut String) -> Result { + std::io::stdin().read_line(buffer) +} + +#[tokio::main] + +async fn main() -> anyhow::Result<()> { + let mut input_buffer = String::new(); + + println!("Guessing Game"); + println!("---------------------------"); + println!("See if you can guess the characters based on certain properties.\n\n"); + + let chosen = blue_archive::fetch_random_student(Language::English) + .await? + .unwrap(); + let mut changed_name = &chosen.name.clone(); + let tng = rand::thread_rng().gen_range(0..changed_name.len()); + + println!("Who is this character's name? [{chosen}]: "); + + read_line_to_buffer(&mut input_buffer)?; + + Ok(()) +} diff --git a/src/enums.rs b/src/enums.rs index b06b9cf..3132f62 100644 --- a/src/enums.rs +++ b/src/enums.rs @@ -11,7 +11,6 @@ pub enum Language { Korean, Thai, Taiwanese, - Vietnamese, } impl Language { @@ -24,7 +23,6 @@ impl Language { Self::Korean => "kr", Self::Thai => "th", Self::Taiwanese => "tw", - Self::Vietnamese => "vi", } .to_string() } diff --git a/tests/raids_from_langs.rs b/tests/raids_from_langs.rs index b0baf43..6cfc008 100644 --- a/tests/raids_from_langs.rs +++ b/tests/raids_from_langs.rs @@ -15,4 +15,3 @@ lang_test!(fetch_raids_by_chinese, Language::Chinese); lang_test!(fetch_raids_by_korean, Language::Korean); lang_test!(fetch_raids_by_thai, Language::Thai); lang_test!(fetch_raids_by_taiwanese, Language::Taiwanese); -lang_test!(fetch_raids_by_vietnamese, Language::Vietnamese); diff --git a/tests/students_from_langs.rs b/tests/students_from_langs.rs index 47e4cc7..97d20dd 100644 --- a/tests/students_from_langs.rs +++ b/tests/students_from_langs.rs @@ -17,4 +17,3 @@ lang_test!(fetch_students_by_chinese, Language::Chinese); lang_test!(fetch_students_by_korean, Language::Korean); lang_test!(fetch_students_by_thai, Language::Thai); lang_test!(fetch_students_by_taiwanese, Language::Taiwanese); -lang_test!(fetch_students_by_vietnamese, Language::Vietnamese); diff --git a/tests/summons_from_langs.rs b/tests/summons_from_langs.rs index 61d01d3..b42bd9d 100644 --- a/tests/summons_from_langs.rs +++ b/tests/summons_from_langs.rs @@ -17,4 +17,3 @@ lang_test!(fetch_summons_by_chinese, Language::Chinese); lang_test!(fetch_summons_by_korean, Language::Korean); lang_test!(fetch_summons_by_thai, Language::Thai); lang_test!(fetch_summons_by_taiwanese, Language::Taiwanese); -lang_test!(fetch_summons_by_vietnamese, Language::Vietnamese); From dc9d3f486af944e0ae7e4d0c33b3e0c08fad2725 Mon Sep 17 00:00:00 2001 From: Edelweiss Date: Thu, 29 Feb 2024 02:07:03 -0600 Subject: [PATCH 2/4] Update Guessing Game --- examples/guessing_game.rs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/examples/guessing_game.rs b/examples/guessing_game.rs index a6a98c7..a8abfea 100644 --- a/examples/guessing_game.rs +++ b/examples/guessing_game.rs @@ -1,4 +1,4 @@ -use blue_archive::Language; +use blue_archive::{types::Student, Language}; use rand::Rng; fn read_line_to_buffer(buffer: &mut String) -> Result { @@ -10,19 +10,33 @@ fn read_line_to_buffer(buffer: &mut String) -> Result { async fn main() -> anyhow::Result<()> { let mut input_buffer = String::new(); - println!("Guessing Game"); + println!("Guessing Game (it's really bad)"); println!("---------------------------"); println!("See if you can guess the characters based on certain properties.\n\n"); let chosen = blue_archive::fetch_random_student(Language::English) .await? .unwrap(); - let mut changed_name = &chosen.name.clone(); - let tng = rand::thread_rng().gen_range(0..changed_name.len()); + let mut changed_name = chosen.name.clone(); - println!("Who is this character's name? [{chosen}]: "); + let index = rand::thread_rng().gen_range(0..chosen.name.len()); + changed_name.remove(index); + changed_name.insert(index, '_'); + + println!("Who is this character's name? [{changed_name}]: "); read_line_to_buffer(&mut input_buffer)?; + println!("Your input: {}", input_buffer.trim()); + + if input_buffer.trim().to_lowercase() == chosen.name.to_lowercase() { + println!("Yay! You got it right!") + } else { + println!( + "Aw... you got it wrong... it was actually: {}.", + chosen.name + ) + } + Ok(()) } From a0daa555fc6ddb3253b425ca11bb27bb8dfc4cbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Merryweather=20=CE=BC?= Date: Mon, 4 Mar 2024 12:15:33 -0600 Subject: [PATCH 3/4] =?UTF-8?q?=E2=80=A6=20mac=20moment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1362536..6490177 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .vscode/ Cargo.lock .idea/ +.DS_Store \ No newline at end of file From 03f15872e0562ff21829964c151153348fde2230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Merryweather=20=CE=BC?= Date: Mon, 4 Mar 2024 12:19:10 -0600 Subject: [PATCH 4/4] Incrementing version to 0.3.96 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 3b5cd8f..e4e7094 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "blue_archive" -version = "0.3.95" +version = "0.3.96" edition = "2021" license-file = "LICENSE" description = "A Blue Archive api wrapper for Rust, based off of SchaleDB's data: https://github.com/lonqie/SchaleDB"