mirror of
https://github.com/redstrate/Auracite.git
synced 2025-05-01 08:27:46 +00:00
Extract Grand Company information
This commit is contained in:
parent
bc0f8eff6e
commit
0312725624
3 changed files with 23 additions and 2 deletions
|
@ -1,8 +1,8 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use crate::value::{
|
||||
CityStateValue, ClassJobValue, GenderValue, GuardianValue, NamedayValue, RaceValue, TribeValue,
|
||||
WorldValue,
|
||||
CityStateValue, ClassJobValue, GenderValue, GrandCompanyValue, GuardianValue, NamedayValue,
|
||||
RaceValue, TribeValue, WorldValue,
|
||||
};
|
||||
|
||||
#[derive(Default, Serialize)]
|
||||
|
@ -52,6 +52,7 @@ pub struct CharacterData {
|
|||
pub gender: GenderValue,
|
||||
pub tribe: TribeValue,
|
||||
pub classjob_levels: Vec<ClassJobValue>,
|
||||
pub grand_company: GrandCompanyValue,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub currencies: Option<Currencies>,
|
||||
|
|
|
@ -105,6 +105,18 @@ pub fn parse_lodestone(data: &str) -> CharacterData {
|
|||
char_data.guardian =
|
||||
GuardianValue::try_from(block_name.inner_html().as_str()).unwrap();
|
||||
}
|
||||
} else if name == "Grand Company" {
|
||||
if let Some(block_name) = element
|
||||
.select(&Selector::parse(CHARACTER_BLOCK_NAME_SELECTOR).unwrap())
|
||||
.nth(0)
|
||||
{
|
||||
let re = Regex::new(r"([^\/]+)\s\/\s([^\/]+)").unwrap();
|
||||
let inner_html = block_name.inner_html();
|
||||
let captures = re.captures(&inner_html).unwrap();
|
||||
|
||||
char_data.grand_company.name = captures.get(1).unwrap().as_str().to_string();
|
||||
char_data.grand_company.rank = captures.get(2).unwrap().as_str().to_string();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -300,3 +300,11 @@ pub struct ClassJobValue {
|
|||
/// Level of the class or job.
|
||||
pub level: i32,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize)]
|
||||
pub struct GrandCompanyValue {
|
||||
/// Name of the grand company.
|
||||
pub name: String,
|
||||
/// Name of your rank in the grand company.
|
||||
pub rank: String,
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue