Hotfix - class artifacts
This commit is contained in:
parent
a2e42f44ff
commit
965071bcf3
2 changed files with 30 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "drunk-venti-rust"
|
name = "drunk-venti-rust"
|
||||||
version = "1.0.4"
|
version = "1.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["Evann Regnault"]
|
authors = ["Evann Regnault"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
|
@ -25,9 +25,23 @@ pub struct Artifact {
|
||||||
pub domain: Option<Box<str>>
|
pub domain: Option<Box<str>>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_real_artifact_name(artifact: &str) -> &str {
|
||||||
|
match artifact {
|
||||||
|
"+18%_atk_set" => "gladiators_finale",
|
||||||
|
"+20%_energy_recharge" => "emblem_of_severed_fate",
|
||||||
|
"+25%_physical_dmg" => "bloodstained_chivalry",
|
||||||
|
"+80_em" => "gilded_dreams",
|
||||||
|
"+15%_healing_bonus_set" => "ocean-hued_clam",
|
||||||
|
_ => artifact
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Artifact{
|
impl Artifact{
|
||||||
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub async fn get(artifact: &str) -> Artifact {
|
pub async fn get(artifact: &str) -> Artifact {
|
||||||
|
let artifact = get_real_artifact_name(artifact);
|
||||||
let host = env::var("API_HOST").unwrap();
|
let host = env::var("API_HOST").unwrap();
|
||||||
let port = env::var("API_PORT").unwrap();
|
let port = env::var("API_PORT").unwrap();
|
||||||
let url = format!("http://{}:{}/api/artifacts/{}", host, port, artifact);
|
let url = format!("http://{}:{}/api/artifacts/{}", host, port, artifact);
|
||||||
|
@ -46,6 +60,7 @@ impl Artifact{
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub(crate) async fn search(artifact: &str) -> Vec<Artifact> {
|
pub(crate) async fn search(artifact: &str) -> Vec<Artifact> {
|
||||||
|
let artifact = get_real_artifact_name(artifact);
|
||||||
let host = env::var("API_HOST").unwrap();
|
let host = env::var("API_HOST").unwrap();
|
||||||
let port = env::var("API_PORT").unwrap();
|
let port = env::var("API_PORT").unwrap();
|
||||||
let url = format!("http://{}:{}/api/artifacts/search/{}", host, port, artifact);
|
let url = format!("http://{}:{}/api/artifacts/search/{}", host, port, artifact);
|
||||||
|
@ -95,3 +110,17 @@ fn test_artifact() {
|
||||||
let data = std::fs::read_to_string("test/artifact.json").expect("No Artifact test file");
|
let data = std::fs::read_to_string("test/artifact.json").expect("No Artifact test file");
|
||||||
serde_json::from_str::<Artifact>(&data).expect("Didn't work");
|
serde_json::from_str::<Artifact>(&data).expect("Didn't work");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_real_artfifact_name() {
|
||||||
|
match get_real_artifact_name("+18%_atk_set") {
|
||||||
|
"gladiators_finale" => {}
|
||||||
|
_ => panic!()
|
||||||
|
};
|
||||||
|
|
||||||
|
match get_real_artifact_name("lasfhkalkfhafsk") {
|
||||||
|
"lasfhkalkfhafsk" => {}
|
||||||
|
_ => panic!()
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue