refactor: update ffxiv_types
This commit is contained in:
parent
6820aff913
commit
ab89c33038
|
@ -23,6 +23,6 @@ version = "0.4"
|
||||||
features = ["serde"]
|
features = ["serde"]
|
||||||
|
|
||||||
[dependencies.ffxiv_types]
|
[dependencies.ffxiv_types]
|
||||||
version = "0.2"
|
version = "0.3"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["worlds", "with_serde"]
|
features = ["worlds", "races", "clans", "guardians", "with_serde"]
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
use crate::models::character::{
|
use crate::models::character::{
|
||||||
Character,
|
Character,
|
||||||
CityState,
|
CityState,
|
||||||
Clan,
|
|
||||||
Gender,
|
Gender,
|
||||||
GrandCompany,
|
GrandCompany,
|
||||||
GrandCompanyInfo,
|
GrandCompanyInfo,
|
||||||
Guardian,
|
|
||||||
Race,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use ffxiv_types::{Race, Clan, Guardian};
|
||||||
|
|
||||||
use scraper::Html;
|
use scraper::Html;
|
||||||
|
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
@ -41,18 +40,18 @@ pub fn parse(id: u64, html: &str) -> Option<Character> {
|
||||||
|
|
||||||
let mut rcg = html.select(&*PROFILE_RACE_CLAN_GENDER).next()?.text();
|
let mut rcg = html.select(&*PROFILE_RACE_CLAN_GENDER).next()?.text();
|
||||||
|
|
||||||
let race = Race::parse(rcg.next()?)?;
|
let race = Race::from_str(rcg.next()?).ok()?;
|
||||||
|
|
||||||
let mut clan_gender_str = rcg.next()?.split(" / ");
|
let mut clan_gender_str = rcg.next()?.split(" / ");
|
||||||
|
|
||||||
let clan = Clan::parse(clan_gender_str.next()?)?;
|
let clan = Clan::from_str(clan_gender_str.next()?).ok()?;
|
||||||
|
|
||||||
let gender = Gender::parse(clan_gender_str.next()?)?;
|
let gender = Gender::parse(clan_gender_str.next()?)?;
|
||||||
|
|
||||||
let name_day = html.select(&*PROFILE_NAME_DAY).next()?.text().collect();
|
let name_day = html.select(&*PROFILE_NAME_DAY).next()?.text().collect();
|
||||||
|
|
||||||
let guardian_str: String = html.select(&*PROFILE_GUARDIAN).next()?.text().collect();
|
let guardian_str: String = html.select(&*PROFILE_GUARDIAN).next()?.text().collect();
|
||||||
let guardian = Guardian::parse(&guardian_str)?;
|
let guardian = Guardian::from_str(guardian_str.split(",").next()?).ok()?;
|
||||||
|
|
||||||
let city_state_str: String = html.select(&*PROFILE_CITY_STATE).next()?.text().collect();
|
let city_state_str: String = html.select(&*PROFILE_CITY_STATE).next()?.text().collect();
|
||||||
let city_state = CityState::parse(&city_state_str)?;
|
let city_state = CityState::parse(&city_state_str)?;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use ffxiv_types::World;
|
use ffxiv_types::{World, Race, Clan, Guardian};
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
pub struct Character {
|
pub struct Character {
|
||||||
|
@ -32,44 +32,12 @@ ffxiv_enum!(Gender {
|
||||||
Female => "♀",
|
Female => "♀",
|
||||||
});
|
});
|
||||||
|
|
||||||
ffxiv_enum!(Race {
|
|
||||||
AuRa => "Au Ra",
|
|
||||||
Elezen => "Elezen",
|
|
||||||
Hyur => "Hyur",
|
|
||||||
Lalafell => "Lalafell",
|
|
||||||
Miqote => "Miqo'te",
|
|
||||||
Roegadyn => "Roegadyn",
|
|
||||||
});
|
|
||||||
|
|
||||||
ffxiv_enum!(Clan {
|
|
||||||
Raen => "Raen",
|
|
||||||
Xaela => "Xaela",
|
|
||||||
Duskwight => "Duskwight",
|
|
||||||
Wildwood => "Wildwood",
|
|
||||||
Highlander => "Highlander",
|
|
||||||
Midlander => "Midlander",
|
|
||||||
Dunesfolk => "Dunesfolk",
|
|
||||||
Plainsfolk => "Plainsfolk",
|
|
||||||
SeekerOfTheMoon => "Seeker of the Moon",
|
|
||||||
SeekerOfTheSun => "Seeker of the Sun",
|
|
||||||
Hellsguard => "Hellsguard",
|
|
||||||
SeaWolf => "Sea Wolf",
|
|
||||||
});
|
|
||||||
|
|
||||||
ffxiv_enum!(GrandCompany {
|
ffxiv_enum!(GrandCompany {
|
||||||
Flames => "Immortal Flames",
|
Flames => "Immortal Flames",
|
||||||
Maelstrom => "Maelstrom",
|
Maelstrom => "Maelstrom",
|
||||||
TwinAdders => "Order of the Twin Adder",
|
TwinAdders => "Order of the Twin Adder",
|
||||||
});
|
});
|
||||||
|
|
||||||
ffxiv_enum!(Guardian {
|
|
||||||
Althyk => "Althyk, the Keeper",
|
|
||||||
Halone => "Halone, the Fury",
|
|
||||||
Menphina => "Menphina, the Lover",
|
|
||||||
Oschon => "Oschon, the Wanderer",
|
|
||||||
Rhalgr => "Rhalgr, the Destroyer",
|
|
||||||
});
|
|
||||||
|
|
||||||
ffxiv_enum!(CityState {
|
ffxiv_enum!(CityState {
|
||||||
Gridania => "Gridania",
|
Gridania => "Gridania",
|
||||||
LimsaLominsa => "Limsa Lominsa",
|
LimsaLominsa => "Limsa Lominsa",
|
||||||
|
|
Loading…
Reference in New Issue