Skip to main content

rustemon/model/
moves.rs

1//! Moves group models
2
3use super::{
4    contests::{ContestEffect, ContestType, SuperContestEffect},
5    games::{Generation, VersionGroup},
6    pokemon::{AbilityEffectChange, Pokemon, Stat, Type},
7    resource::{
8        ApiResource, Description, MachineVersionDetail, Name, NamedApiResource, VerboseEffect,
9    },
10    utility::Language,
11};
12
13/// [Move official documentation](https://pokeapi.co/docs/v2#move)
14#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize)]
15#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
16pub struct Move {
17    /// The identifier for this resource.
18    pub id: i64,
19    /// The name for this resource.
20    pub name: String,
21    /// The percent value of how likely this move is to be successful.
22    pub accuracy: Option<i64>,
23    /// The percent value of how likely it is this moves effect will happen.
24    pub effect_chance: Option<i64>,
25    /// Power points. The number of times this move can be used.
26    pub pp: Option<i64>,
27    /// A value between -8 and 8. Sets the order in which moves are executed during battle.
28    /// See [Bulbapedia](http://bulbapedia.bulbagarden.net/wiki/Priority) for greater detail.
29    pub priority: i64,
30    /// The base power of this move with a value of 0 if it does not have a base power.
31    pub power: Option<i64>,
32    /// A detail of normal and super contest combos that require this move.
33    pub contest_combos: Option<ContestComboSets>,
34    /// The type of appeal this move gives a Pokémon when used in a contest.
35    pub contest_type: Option<NamedApiResource<ContestType>>,
36    /// The effect the move has when used in a contest.
37    pub contest_effect: Option<ApiResource<ContestEffect>>,
38    /// The type of damage the move inflicts on the target, e.g. physical.
39    pub damage_class: NamedApiResource<MoveDamageClass>,
40    /// The effect of this move listed in different languages.
41    pub effect_entries: Vec<VerboseEffect>,
42    /// The list of previous effects this move has had across version groups of the games.
43    pub effect_changes: Vec<AbilityEffectChange>,
44    /// List of Pokemon that can learn the move
45    pub learned_by_pokemon: Vec<NamedApiResource<Pokemon>>,
46    /// The flavor text of this move listed in different languages.
47    pub flavor_text_entries: Vec<MoveFlavorText>,
48    /// The generation in which this move was introduced.
49    pub generation: NamedApiResource<Generation>,
50    /// A list of the machines that teach this move.
51    pub machines: Vec<MachineVersionDetail>,
52    /// Metadata about this move.
53    pub meta: Option<MoveMetaData>,
54    /// The name of this resource listed in different languages.
55    pub names: Vec<Name>,
56    /// A list of move resource value changes across version groups of the game.
57    pub past_values: Vec<PastMoveStatValues>,
58    /// A list of stats this moves effects and how much it effects them.
59    pub stat_changes: Vec<MoveStatChange>,
60    /// The effect the move has when used in a super contest.
61    pub super_contest_effect: Option<ApiResource<SuperContestEffect>>,
62    /// The type of target that will receive the effects of the attack.
63    pub target: NamedApiResource<MoveTarget>,
64    /// The elemental type of this move.
65    #[serde(rename = "type")]
66    pub type_: NamedApiResource<Type>,
67}
68
69/// [ContestComboSets official documentation](https://pokeapi.co/docs/v2#contestcombosets)
70#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize)]
71#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
72pub struct ContestComboSets {
73    /// A detail of moves this move can be used before or after, granting additional appeal points in contests.
74    pub normal: ContestComboDetail,
75    /// A detail of moves this move can be used before or after, granting additional appeal points in super contests.
76    #[serde(rename = "super")]
77    pub super_: ContestComboDetail,
78}
79
80/// [ContestComboDetail official documentation](https://pokeapi.co/docs/v2#contestcombodetail)
81#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize)]
82#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
83pub struct ContestComboDetail {
84    /// A list of moves to use before this move.
85    pub use_before: Option<Vec<NamedApiResource<Move>>>,
86    /// A list of moves to use after this move.
87    pub use_after: Option<Vec<NamedApiResource<Move>>>,
88}
89
90/// [MoveFlavorText official documentation](https://pokeapi.co/docs/v2#moveflavortext)
91#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize)]
92#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
93pub struct MoveFlavorText {
94    /// The localized flavor text for an api resource in a specific language.
95    pub flavor_text: String,
96    /// The language this name is in.
97    pub language: NamedApiResource<Language>,
98    /// The version group that uses this flavor text.
99    pub version_group: NamedApiResource<VersionGroup>,
100}
101
102/// [MoveMetaData official documentation](https://pokeapi.co/docs/v2#movemetadata)
103#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize)]
104#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
105pub struct MoveMetaData {
106    /// The status ailment this move inflicts on its target.
107    pub ailment: NamedApiResource<MoveAilment>,
108    /// The category of move this move falls under, e.g. damage or ailment.
109    pub category: NamedApiResource<MoveCategory>,
110    /// The minimum number of times this move hits. Null if it always only hits once.
111    pub min_hits: Option<i64>,
112    /// The maximum number of times this move hits. Null if it always only hits once.
113    pub max_hits: Option<i64>,
114    /// The minimum number of turns this move continues to take effect. Null if it always only lasts one turn.
115    pub min_turns: Option<i64>,
116    /// The maximum number of turns this move continues to take effect. Null if it always only lasts one turn.
117    pub max_turns: Option<i64>,
118    /// HP drain (if positive) or Recoil damage (if negative), in percent of damage done.
119    pub drain: i64,
120    /// The amount of hp gained by the attacking Pokemon, in percent of it's maximum HP.
121    pub healing: i64,
122    /// Critical hit rate bonus.
123    pub crit_rate: i64,
124    /// The likelihood this attack will cause an ailment.
125    pub ailment_chance: i64,
126    /// The likelihood this attack will cause the target Pokémon to flinch.
127    pub flinch_chance: i64,
128    /// The likelihood this attack will cause a stat change in the target Pokémon.
129    pub stat_chance: i64,
130}
131
132/// [MoveStatChange official documentation](https://pokeapi.co/docs/v2#movestatchange)
133#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize)]
134#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
135pub struct MoveStatChange {
136    /// The amount of change.
137    pub change: i64,
138    /// The stat being affected.
139    pub stat: NamedApiResource<Stat>,
140}
141
142/// [PastMoveStatValues official documentation](https://pokeapi.co/docs/v2#pastmovestatvalues)
143#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize)]
144#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
145pub struct PastMoveStatValues {
146    /// The percent value of how likely this move is to be successful.
147    pub accuracy: Option<i64>,
148    /// The percent value of how likely it is this moves effect will take effect.
149    pub effect_chance: Option<i64>,
150    /// The base power of this move with a value of 0 if it does not have a base power.
151    pub power: Option<i64>,
152    /// Power points. The number of times this move can be used.
153    pub pp: Option<i64>,
154    /// The effect of this move listed in different languages.
155    pub effect_entries: Vec<VerboseEffect>,
156    /// The elemental type of this move.
157    #[serde(rename = "type")]
158    pub type_: Option<NamedApiResource<Type>>,
159    /// The version group in which these move stat values were in effect.
160    pub version_group: NamedApiResource<VersionGroup>,
161}
162
163/// [MoveAilment official documentation](https://pokeapi.co/docs/v2#moveailment)
164#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize)]
165#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
166pub struct MoveAilment {
167    /// The identifier for this resource.
168    pub id: i64,
169    /// The name for this resource.
170    pub name: String,
171    /// A list of moves that cause this ailment.
172    pub moves: Vec<NamedApiResource<Move>>,
173    /// The name of this resource listed in different languages.
174    pub names: Vec<Name>,
175}
176
177/// [MoveBattleStyle official documentation](https://pokeapi.co/docs/v2#movebattlestyle)
178#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize)]
179#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
180pub struct MoveBattleStyle {
181    /// The identifier for this resource.
182    pub id: i64,
183    /// The name for this resource.
184    pub name: String,
185    /// The name of this resource listed in different languages.
186    pub names: Vec<Name>,
187}
188
189/// [MoveCategory official documentation](https://pokeapi.co/docs/v2#movecategory)
190#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize)]
191#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
192pub struct MoveCategory {
193    /// The identifier for this resource.
194    pub id: i64,
195    /// The name for this resource.
196    pub name: String,
197    /// A list of moves that fall into this category.
198    pub moves: Vec<NamedApiResource<Move>>,
199    /// The description of this resource listed in different languages.
200    pub descriptions: Vec<Description>,
201}
202
203/// [MoveDamageClass official documentation](https://pokeapi.co/docs/v2#movedamageclass)
204#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize)]
205#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
206pub struct MoveDamageClass {
207    /// The identifier for this resource.
208    pub id: i64,
209    /// The name for this resource.
210    pub name: String,
211    /// The description of this resource listed in different languages.
212    pub descriptions: Vec<Description>,
213    /// A list of moves that fall into this damage class.
214    pub moves: Vec<NamedApiResource<Move>>,
215    /// The name of this resource listed in different languages.
216    pub names: Vec<Name>,
217}
218
219/// [MoveLearnMethod official documentation](https://pokeapi.co/docs/v2#movelearnmethod)
220#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize)]
221#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
222pub struct MoveLearnMethod {
223    /// The identifier for this resource.
224    pub id: i64,
225    /// The name for this resource.
226    pub name: String,
227    /// The description of this resource listed in different languages.
228    pub descriptions: Vec<Description>,
229    /// The name of this resource listed in different languages.
230    pub names: Vec<Name>,
231    /// A list of version groups where moves can be learned through this method.
232    pub version_groups: Vec<NamedApiResource<VersionGroup>>,
233}
234
235/// [MoveTarget official documentation](https://pokeapi.co/docs/v2#movetarget)
236#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize)]
237#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
238pub struct MoveTarget {
239    /// The identifier for this resource.
240    pub id: i64,
241    /// The name for this resource.
242    pub name: String,
243    /// The description of this resource listed in different languages.
244    pub descriptions: Vec<Description>,
245    /// A list of moves that that are directed at this target.
246    pub moves: Vec<NamedApiResource<Move>>,
247    /// The name of this resource listed in different languages.ƒ
248    pub names: Vec<Name>,
249}