Move Form and Species to traits, implement a bunch of mocks
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-11-28 21:34:28 +01:00
parent c1e09c654b
commit bce636b97e
25 changed files with 447 additions and 155 deletions

View File

@@ -12,8 +12,8 @@ use std::sync::Arc;
#[no_mangle]
extern "C" fn pokemon_new(
library: ExternPointer<Arc<DynamicLibrary>>,
species: ExternPointer<Arc<Species>>,
form: ExternPointer<Arc<Form>>,
species: ExternPointer<Arc<dyn Species>>,
form: ExternPointer<Arc<dyn Form>>,
hidden_ability: bool,
ability_index: u8,
level: LevelInt,
@@ -54,25 +54,25 @@ extern "C" fn pokemon_library(ptr: ExternPointer<Arc<Pokemon>>) -> IdentifiableP
/// The species of the Pokemon.
#[no_mangle]
extern "C" fn pokemon_species(ptr: ExternPointer<Arc<Pokemon>>) -> IdentifiablePointer<Arc<Species>> {
extern "C" fn pokemon_species(ptr: ExternPointer<Arc<Pokemon>>) -> IdentifiablePointer<Arc<dyn Species>> {
ptr.as_ref().species().into()
}
/// The form of the Pokemon.
#[no_mangle]
extern "C" fn pokemon_form(ptr: ExternPointer<Arc<Pokemon>>) -> IdentifiablePointer<Arc<Form>> {
extern "C" fn pokemon_form(ptr: ExternPointer<Arc<Pokemon>>) -> IdentifiablePointer<Arc<dyn Form>> {
ptr.as_ref().form().into()
}
/// The species that should be displayed to the user. This handles stuff like the Illusion ability.
#[no_mangle]
extern "C" fn pokemon_display_species(ptr: ExternPointer<Arc<Pokemon>>) -> IdentifiablePointer<Arc<Species>> {
extern "C" fn pokemon_display_species(ptr: ExternPointer<Arc<Pokemon>>) -> IdentifiablePointer<Arc<dyn Species>> {
ptr.as_ref().display_species().into()
}
/// The form that should be displayed to the user. This handles stuff like the Illusion ability.
#[no_mangle]
extern "C" fn pokemon_display_form(ptr: ExternPointer<Arc<Pokemon>>) -> IdentifiablePointer<Arc<Form>> {
extern "C" fn pokemon_display_form(ptr: ExternPointer<Arc<Pokemon>>) -> IdentifiablePointer<Arc<dyn Form>> {
ptr.as_ref().display_form().into()
}
@@ -294,8 +294,8 @@ extern "C" fn pokemon_recalculate_boosted_stats(ptr: ExternPointer<Arc<Pokemon>>
#[no_mangle]
extern "C" fn pokemon_change_species(
ptr: ExternPointer<Arc<Pokemon>>,
species: ExternPointer<Arc<Species>>,
form: ExternPointer<Arc<Form>>,
species: ExternPointer<Arc<dyn Species>>,
form: ExternPointer<Arc<dyn Form>>,
) {
ptr.as_ref()
.change_species(species.as_ref().clone(), form.as_ref().clone())
@@ -303,7 +303,7 @@ extern "C" fn pokemon_change_species(
/// Change the form of the Pokemon.
#[no_mangle]
extern "C" fn pokemon_change_form(ptr: ExternPointer<Arc<Pokemon>>, form: ExternPointer<Arc<Form>>) {
extern "C" fn pokemon_change_form(ptr: ExternPointer<Arc<Pokemon>>, form: ExternPointer<Arc<dyn Form>>) {
ptr.as_ref().change_form(form.as_ref())
}