119 lines
3.4 KiB
Rust
119 lines
3.4 KiB
Rust
use crate::defines::LevelInt;
|
|
use crate::static_data::{Gender, Parameter};
|
|
use crate::StringKey;
|
|
use std::sync::Arc;
|
|
|
|
/// The different ways a Pokemon can evolve.
|
|
#[derive(Debug)]
|
|
pub enum EvolutionMethod {
|
|
/// Evolves when a certain level is reached.
|
|
Level {
|
|
/// The level at which the Pokemon evolves.
|
|
level: LevelInt,
|
|
},
|
|
/// Evolves when a certain level is reached, and the Pokemon is a specific gender.
|
|
LevelGender {
|
|
/// The level at which the Pokemon evolves.
|
|
level: LevelInt,
|
|
/// The gender the Pokemon needs to be.
|
|
gender: Gender,
|
|
},
|
|
/// Evolves when an item is used.
|
|
Item {
|
|
/// The item that needs to be used.
|
|
item: StringKey,
|
|
},
|
|
/// Evolves when an item is used, and the Pokemon is a specific gender.
|
|
ItemGender {
|
|
/// The item that needs to be used.
|
|
item: StringKey,
|
|
/// The gender the Pokemon needs to be.
|
|
gender: Gender,
|
|
},
|
|
/// Evolves if an item is held.
|
|
HoldItem {
|
|
/// The item that needs to be held.
|
|
item: StringKey,
|
|
},
|
|
/// Evolves if a held item is held, and it's day.
|
|
DayHoldItem {
|
|
/// The item that needs to be held.
|
|
item: StringKey,
|
|
},
|
|
/// Evolves if a held item is held, and it's night.
|
|
NightHoldItem {
|
|
/// The item that needs to be held.
|
|
item: StringKey,
|
|
},
|
|
/// Evolves if the Pokemon knows a certain move.
|
|
HasMove {
|
|
/// The move that needs to be known.
|
|
move_name: StringKey,
|
|
},
|
|
/// Evolves when above a certain happiness level.
|
|
Happiness {
|
|
/// The happiness level that needs to be reached.
|
|
happiness: u8,
|
|
},
|
|
/// Evolves when above a certain happiness level, and it's day.
|
|
HappinessDay {
|
|
/// The happiness level that needs to be reached.
|
|
happiness: u8,
|
|
},
|
|
/// Evolves when above a certain happiness level, and it's night.
|
|
HappinessNight {
|
|
/// The happiness level that needs to be reached.
|
|
happiness: u8,
|
|
},
|
|
/// Evolves when traded.
|
|
Trade,
|
|
/// Evolves when traded with a certain species.
|
|
TradeSpecies {
|
|
/// The species that needs to be traded with.
|
|
species: StringKey,
|
|
},
|
|
/// Evolves when traded while it's holding a certain item.
|
|
TradeItem {
|
|
/// The item that needs to be held.
|
|
item: StringKey,
|
|
},
|
|
/// Evolves in a certain location.
|
|
Location {
|
|
/// The location the Pokemon needs to be in.
|
|
location: StringKey,
|
|
},
|
|
/// A custom evolution method, implemented by the user.
|
|
Custom {
|
|
/// The name of the custom evolution method.
|
|
name: StringKey,
|
|
/// The parameters of the custom evolution method.
|
|
params: Vec<Arc<Parameter>>,
|
|
},
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
/// Data about how and into which Pokemon a species can evolve.
|
|
pub struct EvolutionData {
|
|
/// The method of evolution.
|
|
method: EvolutionMethod,
|
|
/// The Pokemon the species evolves into.
|
|
to: StringKey,
|
|
}
|
|
|
|
impl EvolutionData {
|
|
/// Creates a new evolution data instance.
|
|
pub fn new(method: EvolutionMethod, to: StringKey) -> Self {
|
|
Self { method, to }
|
|
}
|
|
|
|
/// Returns the method of evolution.
|
|
pub fn method(&self) -> &EvolutionMethod {
|
|
&self.method
|
|
}
|
|
|
|
/// Returns the Pokemon the species evolves into.
|
|
pub fn to(&self) -> &StringKey {
|
|
&self.to
|
|
}
|
|
}
|