Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rustemon-static-test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ async fn get_data(rc: &RustemonClient) -> anyhow::Result<Vec<(String, String, St
get_json_body(|| items::item_category::get_by_id(3, rc)).await?,
get_json_body(|| items::item_fling_effect::get_by_id(3, rc)).await?,
get_json_body(|| items::item_pocket::get_by_id(3, rc)).await?,
get_json_body(|| items::currency::get_by_id(1, rc)).await?,
// Locations endpoints
get_json_body(|| locations::location::get_by_id(5, rc)).await?,
get_json_body(|| locations::location_area::get_by_id(5, rc)).await?,
Expand Down
1 change: 1 addition & 0 deletions rustemon/examples/check_static_resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ async fn main() {
static_resources::get_item_category();
static_resources::get_item_fling_effect();
static_resources::get_item_pocket();
static_resources::get_currency();
static_resources::get_location();
static_resources::get_location_area();
static_resources::get_pal_park_area();
Expand Down
5 changes: 5 additions & 0 deletions rustemon/src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ pub mod item_fling_effect {
pub mod item_pocket {
crate::endpoint!(crate::model::items::ItemPocket; for "item-pocket");
}

/// Currencies are forms of money used throughout the Pokémon games to purchase items, services, and participate in various game mechanics.
pub mod currency {
crate::endpoint!(crate::model::items::Currency; for "currency");
}
45 changes: 41 additions & 4 deletions rustemon/src/model/evolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use super::{
items::Item,
locations::{Location, Region},
moves::Move,
pokemon::{Pokemon, PokemonSpecies, Type},
resource::{Name, NamedApiResource},
pokemon::{Nature, PokemonForm, PokemonSpecies, Type},
resource::{Description, Name, NamedApiResource},
};

/// [EvolutionChain official documentation](https:///pokeapi.co/docs/v2#evolutionchain)
Expand Down Expand Up @@ -97,9 +97,9 @@ pub struct EvolutionDetail {
/// The required region in which this evolution can occur.
pub region: Option<NamedApiResource<Region>>,
/// The required form for which this evolution can occur.
pub base_form: Option<NamedApiResource<Pokemon>>,
pub required_pokemon_form: Option<NamedApiResource<PokemonForm>>,
/// The form to which this evolution occurs.
pub evolved_form: Option<NamedApiResource<Pokemon>>,
pub evolved_pokemon_form: Option<NamedApiResource<PokemonForm>>,
/// The move that must be used by the evolving Pokémon species during the evolution trigger event
/// in order to evolve into this Pokémon species.
pub used_move: Option<NamedApiResource<Move>>,
Expand All @@ -110,6 +110,11 @@ pub struct EvolutionDetail {
/// The minimum amount of damage taken during the evolution trigger event in order to
/// evolve into this Pokémon species.
pub min_damage_taken: Option<i64>,
/// A list of natures the evolving Pokémon species must have to evolve into this Pokémon species.
pub allowed_natures: Option<Vec<NamedApiResource<Nature>>>,
/// An expression detailing variable-dependent conditional evolution requirements
/// (such as encryption constant or personality value calculations).
pub condition_expression: Option<EvolutionConditionExpression>,
}

/// [EvolutionTrigger official documentation](https:///pokeapi.co/docs/v2#evolutiontrigger)
Expand All @@ -125,3 +130,35 @@ pub struct EvolutionTrigger {
/// A list of pokemon species that result from this evolution trigger.
pub pokemon_species: Vec<NamedApiResource<PokemonSpecies>>,
}

/// [EvolutionConditionExpression official documentation](https://pokeapi.co/docs/v2#evolutionconditionexpression)
#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
pub struct EvolutionConditionExpression {
/// Evaluatable RPN condition expression using evolution variables (e.g. 'EC 100 % 0 ==').
pub expression: String,
/// Percentage chance of evolution under this condition (0-100).
pub percentage_chance: Option<i64>,
/// Evolution variables referenced in the expression.
pub variables: Vec<NamedApiResource<EvolutionVariable>>,
}

/// [EvolutionVariable official documentation](https://pokeapi.co/docs/v2#evolutionvariable)
#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
pub struct EvolutionVariable {
/// The identifier for this resource.
pub id: i64,
/// The name for this resource.
pub name: String,
/// The symbol used to represent this variable in condition expressions.
pub symbol: String,
/// The data type of the variable.
pub data_type: String,
/// The version group in which this evolution variable was introduced.
pub version_group: NamedApiResource<VersionGroup>,
/// The name of this resource listed in different languages.
pub names: Vec<Name>,
/// The description of this resource listed in different languages.
pub descriptions: Vec<Description>,
}
34 changes: 31 additions & 3 deletions rustemon/src/model/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use super::{
evolution::EvolutionChain,
games::Version,
games::{Version, VersionGroup},
pokemon::Pokemon,
resource::{
ApiResource, Description, Effect, GenerationGameIndex, MachineVersionDetail, Name,
Expand All @@ -18,8 +18,6 @@ pub struct Item {
pub id: i64,
/// The name for this resource.
pub name: String,
/// The price of this item in stores.
pub cost: i64,
/// The power of the move Fling when used with this item.
pub fling_power: Option<i64>,
/// The effect of the move Fling when used with this item.
Expand All @@ -34,6 +32,8 @@ pub struct Item {
pub flavor_text_entries: Vec<VersionGroupFlavorText>,
/// A list of game indices relevent to this item by generation.
pub game_indices: Vec<GenerationGameIndex>,
/// The purchase and sell prices of this item for each version group.
pub prices: Vec<ItemPrice>,
/// The name of this item listed in different languages.
pub names: Vec<Name>,
/// A set of sprites used to depict this item in the game.
Expand Down Expand Up @@ -133,3 +133,31 @@ pub struct ItemPocket {
/// The name of this resource listed in different languages.
pub names: Vec<Name>,
}

/// [Currency official documentation](https://pokeapi.co/docs/v2#currency)
#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
pub struct Currency {
/// The identifier for this resource.
pub id: i64,
/// The name for this resource.
pub name: String,
/// The name of this resource listed in different languages.
pub names: Vec<Name>,
}

/// [ItemPrice official documentation](https://pokeapi.co/docs/v2#itemprice)
#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
pub struct ItemPrice {
/// The currency used for this price.
pub currency: NamedApiResource<Currency>,
/// The purchase price of this item in this version group.
/// Null if the item cannot be purchased.
pub purchase_price: Option<i64>,
/// The sell price of this item in this version group.
/// Null if the item cannot be sold.
pub sell_price: Option<i64>,
/// The version group these prices apply to.
pub version_group: NamedApiResource<VersionGroup>,
}
33 changes: 19 additions & 14 deletions rustemon/src/static_resources.rs

Large diffs are not rendered by default.