Skip to content

Commit

Permalink
Merge pull request #30 from MerryweatherLost/0.3.96
Browse files Browse the repository at this point in the history
0.3.96
  • Loading branch information
bibi-reden authored Mar 4, 2024
2 parents b8ae2b1 + 03f1587 commit a154569
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.vscode/
Cargo.lock
.idea/
.DS_Store
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
4 changes: 3 additions & 1 deletion examples/fetch_student.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())),
Expand All @@ -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));
Expand Down
42 changes: 42 additions & 0 deletions examples/guessing_game.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use blue_archive::{types::Student, Language};
use rand::Rng;

fn read_line_to_buffer(buffer: &mut String) -> Result<usize, std::io::Error> {
std::io::stdin().read_line(buffer)
}

#[tokio::main]

async fn main() -> anyhow::Result<()> {
let mut input_buffer = String::new();

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 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(())
}
2 changes: 0 additions & 2 deletions src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ pub enum Language {
Korean,
Thai,
Taiwanese,
Vietnamese,
}

impl Language {
Expand All @@ -24,7 +23,6 @@ impl Language {
Self::Korean => "kr",
Self::Thai => "th",
Self::Taiwanese => "tw",
Self::Vietnamese => "vi",
}
.to_string()
}
Expand Down
1 change: 0 additions & 1 deletion tests/raids_from_langs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
1 change: 0 additions & 1 deletion tests/students_from_langs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
1 change: 0 additions & 1 deletion tests/summons_from_langs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit a154569

Please sign in to comment.