mirror of
https://github.com/Steffo99/patched-porobot.git
synced 2024-12-23 01:54:22 +00:00
Run reformat code
This commit is contained in:
parent
d2b8eb4398
commit
e346d3500a
14 changed files with 63 additions and 45 deletions
|
@ -1,11 +1,11 @@
|
|||
//! This module provides ways to load official data files from Riot Games' [Core Bundles](https://developer.riotgames.com/docs/lor#data-dragon_core-bundles) into Rust structs.
|
||||
|
||||
use std::io::Read;
|
||||
use std::collections::HashMap;
|
||||
use std::io::Read;
|
||||
|
||||
use crate::schema::corebundle::*;
|
||||
use crate::schema::setbundle::*;
|
||||
|
||||
|
||||
/// Deserialize a `globals.json` file into a [CoreGlobals] struct.
|
||||
pub fn globalsjson_to_coreglobals<R>(r: R) -> serde_json::Result<CoreGlobals>
|
||||
where R: Read
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
//! This module provides ways to load official data files from Riot Games' [Set Bundles](https://developer.riotgames.com/docs/lor#data-dragon_set-bundles) into Rust structs.
|
||||
|
||||
use std::io::Read;
|
||||
use std::collections::HashMap;
|
||||
use crate::schema::setbundle::*;
|
||||
use std::io::Read;
|
||||
|
||||
use crate::schema::setbundle::*;
|
||||
|
||||
/// Deserialize a `set.json` file into a [Vec] of [Card]s.
|
||||
pub fn setjson_to_cardvec<R>(r: R) -> serde_json::Result<Vec<Card>>
|
||||
|
@ -27,10 +27,12 @@ pub fn cardvec_to_cardhashmap(v: Vec<Card>) -> HashMap<String, Card> {
|
|||
#[allow(deprecated)]
|
||||
mod tests {
|
||||
use std::collections::HashMap;
|
||||
use super::setjson_to_cardvec;
|
||||
use super::cardvec_to_cardhashmap;
|
||||
|
||||
use crate::schema::setbundle::*;
|
||||
|
||||
use super::cardvec_to_cardhashmap;
|
||||
use super::setjson_to_cardvec;
|
||||
|
||||
const TEST_SETJSON: &str = r#"
|
||||
[
|
||||
{
|
||||
|
@ -160,7 +162,7 @@ mod tests {
|
|||
flavor_text: r#""Never fear change. It will question you, test your limits. It is our greatest teacher." - Karma"#.to_string(),
|
||||
artist_name: "SIXMOREVODKA".to_string(),
|
||||
subtypes: vec![],
|
||||
supertype: "".to_string()
|
||||
supertype: "".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,7 +183,7 @@ mod tests {
|
|||
art: vec![
|
||||
CardArt {
|
||||
card_png: "http://dd.b.pvp.net/3_11_0/set1/en_us/img/cards/01IO012T2.png".to_string(),
|
||||
full_png: "http://dd.b.pvp.net/3_11_0/set1/en_us/img/cards/01IO012T2-full.png".to_string()
|
||||
full_png: "http://dd.b.pvp.net/3_11_0/set1/en_us/img/cards/01IO012T2-full.png".to_string(),
|
||||
}
|
||||
],
|
||||
attack: 0,
|
||||
|
@ -204,7 +206,7 @@ mod tests {
|
|||
flavor_text: "".to_string(),
|
||||
artist_name: "SIXMOREVODKA".to_string(),
|
||||
subtypes: vec![],
|
||||
supertype: "".to_string()
|
||||
supertype: "".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
use super::vocabterm::CoreVocabTerm;
|
||||
use super::keyword::CoreKeyword;
|
||||
use super::rarity::CoreRarity;
|
||||
use super::region::CoreRegion;
|
||||
use super::speed::CoreSpellSpeed;
|
||||
use super::rarity::CoreRarity;
|
||||
|
||||
use super::vocabterm::CoreVocabTerm;
|
||||
|
||||
/// A complete `globals.json` file.
|
||||
///
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
//! This module defines the types used in Data Dragon's [Core Bundle](https://developer.riotgames.com/docs/lor#data-dragon_core-bundles) `globals.json` files.
|
||||
|
||||
pub use globals::CoreGlobals;
|
||||
pub use keyword::CoreKeyword;
|
||||
pub use rarity::CoreRarity;
|
||||
pub use region::CoreRegion;
|
||||
pub use set::CoreSet;
|
||||
pub use speed::CoreSpellSpeed;
|
||||
pub use vocabterm::CoreVocabTerm;
|
||||
|
||||
mod globals;
|
||||
mod vocabterm;
|
||||
mod keyword;
|
||||
|
@ -8,10 +16,3 @@ mod speed;
|
|||
mod rarity;
|
||||
mod set;
|
||||
|
||||
pub use globals::CoreGlobals;
|
||||
pub use vocabterm::CoreVocabTerm;
|
||||
pub use keyword::CoreKeyword;
|
||||
pub use region::CoreRegion;
|
||||
pub use speed::CoreSpellSpeed;
|
||||
pub use rarity::CoreRarity;
|
||||
pub use set::CoreSet;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
//! This module defines [CoreVocabTerm].
|
||||
|
||||
|
||||
/// A Legends of Runeterra vocabulary term, and its associated localization.
|
||||
///
|
||||
/// I'm not sure where these are used, other than in in-game tooltips.
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
//! Module defining [CardArt].
|
||||
|
||||
|
||||
/// An art asset associated with a [super::Card].
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
|
||||
pub struct CardArt {
|
||||
|
|
|
@ -2,12 +2,11 @@
|
|||
|
||||
|
||||
use std::collections::HashMap;
|
||||
use crate::schema::corebundle::*;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
||||
/// A single Legends of Runeterra card.
|
||||
///
|
||||
///
|
||||
/// The information is represented in a developer-friendly manner, but it can be serialized and deserialized via [serde] in the exact same format used in Data Dragon.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
|
||||
pub struct Card {
|
||||
|
@ -19,7 +18,7 @@ pub struct Card {
|
|||
pub name: String,
|
||||
|
||||
/// The [CardType] of the card.
|
||||
///
|
||||
///
|
||||
/// The `r#` prefix is required by the Rust syntax, since `type` is a reserved keyword.
|
||||
#[serde(rename = "type")]
|
||||
pub r#type: CardType,
|
||||
|
@ -38,6 +37,7 @@ pub struct Card {
|
|||
/// Regions this card belongs to.
|
||||
#[serde(rename = "regionRefs")]
|
||||
pub regions: Vec<CardRegion>,
|
||||
|
||||
/// Localized names of the regions this card belongs to.
|
||||
///
|
||||
/// For serialization purposes only, use the [method with the same name](Card::localized_regions()] instead!
|
||||
|
@ -70,6 +70,7 @@ pub struct Card {
|
|||
/// [SpellSpeed] of the card.
|
||||
#[serde(rename = "spellSpeedRef")]
|
||||
pub spell_speed: SpellSpeed,
|
||||
|
||||
/// Localized name of the [SpellSpeed] of the card.
|
||||
///
|
||||
/// For serialization purposes only, use the [method with the same name](Card::localized_spell_speed()] instead!
|
||||
|
@ -77,30 +78,33 @@ pub struct Card {
|
|||
pub(crate) localized_spell_speed: String,
|
||||
|
||||
/// [Vec] of [CardKeyword]s of the card.
|
||||
#[serde(rename="keywordRefs")]
|
||||
#[serde(rename = "keywordRefs")]
|
||||
pub keywords: Vec<CardKeyword>,
|
||||
|
||||
/// [Vec] of localized names of [CardKeyword]s of the card.
|
||||
///
|
||||
/// For serialization purposes only, use the [method with the same name](Card::localized_keywords()] instead!
|
||||
#[serde(rename="keywords")]
|
||||
#[serde(rename = "keywords")]
|
||||
pub(crate) localized_keywords: Vec<String>,
|
||||
|
||||
/// Localized description of the card, in pseudo-XML.
|
||||
#[serde(rename="description")]
|
||||
#[serde(rename = "description")]
|
||||
pub localized_description_xml: String,
|
||||
|
||||
/// Localized description of the card, in plain text.
|
||||
#[serde(rename="descriptionRaw")]
|
||||
#[serde(rename = "descriptionRaw")]
|
||||
pub localized_description_text: String,
|
||||
|
||||
/// Localized level up text of the card, in pseudo-XML.
|
||||
///
|
||||
/// If the card has no level up text, contains an empty string.
|
||||
#[serde(rename="levelupDescription")]
|
||||
#[serde(rename = "levelupDescription")]
|
||||
pub localized_levelup_xml: String,
|
||||
|
||||
/// Localized level up text of the card, in plain text.
|
||||
///
|
||||
/// If the card has no level up text, contains an empty string.
|
||||
#[serde(rename="levelupDescriptionRaw")]
|
||||
#[serde(rename = "levelupDescriptionRaw")]
|
||||
pub localized_levelup_text: String,
|
||||
|
||||
/// [Vec] with [Card::code]s of other cards associated with this one.
|
||||
|
@ -108,6 +112,7 @@ pub struct Card {
|
|||
/// To access references to the cards themselves, use [Card::associated_cards].
|
||||
#[serde(rename = "associatedCardRefs")]
|
||||
pub associated_card_codes: Vec<String>,
|
||||
|
||||
/// [Vec] with [Card::name]s of other cards associated with this one.
|
||||
///
|
||||
/// Sometimes, it may be missing some references.
|
||||
|
@ -116,19 +121,21 @@ pub struct Card {
|
|||
|
||||
/// Flavor text of the card, displayed when its image is inspected.
|
||||
pub flavor_text: String,
|
||||
|
||||
/// Name of the artist who drew the card.
|
||||
pub artist_name: String,
|
||||
|
||||
/// The subtypes the card has, such as `"PORO"`.
|
||||
///
|
||||
///
|
||||
/// Beware of Riot's inconsistent capitalization!
|
||||
///
|
||||
///
|
||||
/// TODO: Make this a enum.
|
||||
pub subtypes: Vec<String>,
|
||||
|
||||
/// The supertype the card belongs to, such as `"Champion"`.
|
||||
///
|
||||
///
|
||||
/// Beware of Riot's inconsistent capitalization!
|
||||
///
|
||||
///
|
||||
/// TODO: Make this a enum.
|
||||
pub supertype: String,
|
||||
}
|
||||
|
@ -156,11 +163,11 @@ impl Card {
|
|||
mod tests {
|
||||
use super::Card;
|
||||
use super::super::art::CardArt;
|
||||
use super::super::r#type::CardType;
|
||||
use super::super::rarity::CardRarity;
|
||||
use super::super::region::CardRegion;
|
||||
use super::super::set::CardSet;
|
||||
use super::super::speed::SpellSpeed;
|
||||
use super::super::r#type::CardType;
|
||||
|
||||
#[test]
|
||||
fn deserialize_card() {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
//! Module defining [CardKeyword].
|
||||
|
||||
|
||||
/// A keyword which cards can have.
|
||||
///
|
||||
/// Since more keywords will probably be added in the future, this enum is [non_exaustive](https://doc.rust-lang.org/reference/attributes/type_system.html#the-non_exhaustive-attribute).
|
||||
|
@ -252,7 +253,7 @@ pub enum CardKeyword {
|
|||
/// Quick Attack.
|
||||
///
|
||||
/// > While attacking, strikes before its blocker.
|
||||
#[serde(rename="QuickStrike")]
|
||||
#[serde(rename = "QuickStrike")]
|
||||
QuickAttack,
|
||||
|
||||
/// Tough.
|
||||
|
@ -303,7 +304,7 @@ pub enum CardKeyword {
|
|||
/// Lurk.
|
||||
///
|
||||
/// > When you attack while I'm on top of your deck, I Lurk, granting Lurker allies everywhere +1|+0. Max once per round.
|
||||
#[serde(rename="Lurker")]
|
||||
#[serde(rename = "Lurker")]
|
||||
Lurk,
|
||||
|
||||
/// Formidable.
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
//! This module defines the types used in Data Dragon's [Set Bundle](https://developer.riotgames.com/docs/lor#data-dragon_set-bundles) `set.json` files.
|
||||
|
||||
pub use art::CardArt;
|
||||
pub use card::Card;
|
||||
pub use keyword::CardKeyword;
|
||||
pub use r#type::CardType;
|
||||
pub use rarity::CardRarity;
|
||||
pub use region::CardRegion;
|
||||
pub use set::CardSet;
|
||||
pub use speed::SpellSpeed;
|
||||
|
||||
mod card;
|
||||
mod art;
|
||||
mod r#type;
|
||||
|
@ -9,11 +18,3 @@ mod set;
|
|||
mod speed;
|
||||
mod keyword;
|
||||
|
||||
pub use card::Card;
|
||||
pub use art::CardArt;
|
||||
pub use r#type::CardType;
|
||||
pub use rarity::CardRarity;
|
||||
pub use region::CardRegion;
|
||||
pub use set::CardSet;
|
||||
pub use speed::SpellSpeed;
|
||||
pub use keyword::CardKeyword;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
//! Module defining [CardRarity].
|
||||
|
||||
|
||||
/// A possible [super::Card] rarity.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
|
||||
pub enum CardRarity {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
//! Module defining [CardRegion].
|
||||
|
||||
|
||||
/// A region to which [super::Card]s can belong to.
|
||||
///
|
||||
/// Since more regions might be added in the future, especially Origin ones, this enum is [non_exaustive](https://doc.rust-lang.org/reference/attributes/type_system.html#the-non_exhaustive-attribute).
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
//! Module defining [CardSet].
|
||||
|
||||
|
||||
/// The release set a [super::Card] may belong to.
|
||||
///
|
||||
/// Since more sets will definitely be added in the future, this enum is [non_exaustive](https://doc.rust-lang.org/reference/attributes/type_system.html#the-non_exhaustive-attribute).
|
||||
|
|
|
@ -28,7 +28,7 @@ pub enum CardType {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::CardType;
|
||||
|
||||
|
||||
macro_rules! test_deserialization {
|
||||
( $id:ident, $src:literal, $res:expr ) => {
|
||||
#[test]
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
//! This module implements full-text search on [crate::schema::Card]s of multiple locales.
|
||||
|
||||
mod card;
|
Loading…
Reference in a new issue