Implements Aurora Veil
This commit is contained in:
		| @@ -3,7 +3,7 @@ use crate::handling::cached_value::CachedValue; | ||||
| use crate::handling::Cacheable; | ||||
| use crate::{ | ||||
|     cached_value, cached_value_getters, wasm_value_getters, DynamicLibrary, ExternRef, | ||||
|     ExternalReferenceType, ImmutableList, VecExternRef, | ||||
|     ExternalReferenceType, ImmutableList, StringKey, VecExternRef, | ||||
| }; | ||||
| use alloc::rc::Rc; | ||||
|  | ||||
| @@ -56,6 +56,25 @@ impl Battle { | ||||
|             battle_find_party_for_pokemon(self.inner.reference, pokemon.reference()).get_value() | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     #[cfg(feature = "mock_data")] | ||||
|     pub fn weather_name(&self) -> Option<StringKey> { | ||||
|         None | ||||
|     } | ||||
|  | ||||
|     #[cfg(not(feature = "mock_data"))] | ||||
|     pub fn weather_name(&self) -> Option<StringKey> { | ||||
|         unsafe { battle_get_weather_name(self.inner.reference).get_value() } | ||||
|     } | ||||
|  | ||||
|     pub fn has_weather(&self, name: &str) -> bool { | ||||
|         if let Some(weather) = self.weather_name() { | ||||
|             if weather.eq(name) { | ||||
|                 return true; | ||||
|             } | ||||
|         } | ||||
|         false | ||||
|     } | ||||
| } | ||||
|  | ||||
| wasm_value_getters! { | ||||
| @@ -90,4 +109,6 @@ extern "wasm" { | ||||
|         r: ExternRef<Battle>, | ||||
|         mon: ExternRef<Pokemon>, | ||||
|     ) -> ExternRef<BattleParty>; | ||||
|  | ||||
|     fn battle_get_weather_name(r: ExternRef<Battle>) -> ExternRef<StringKey>; | ||||
| } | ||||
|   | ||||
| @@ -46,7 +46,15 @@ impl BattleSide { | ||||
|     } | ||||
|  | ||||
|     #[cfg(not(feature = "mock_data"))] | ||||
|     pub fn add_volatile(&self, script: Box<dyn Script>) -> &dyn Script { | ||||
|     pub fn has_volatile(&self, script_name: &str) -> bool { | ||||
|         unsafe { | ||||
|             let script_name = CString::new(script_name).unwrap(); | ||||
|             battleside_has_volatile(self.inner.reference, script_name.into_raw()) | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     #[cfg(not(feature = "mock_data"))] | ||||
|     pub fn add_volatile<'a, 'b>(&'a self, script: Box<dyn Script>) -> &'b dyn Script { | ||||
|         unsafe { | ||||
|             battleside_add_volatile(self.inner.reference, ScriptPtr::new(script)) | ||||
|                 .val() | ||||
|   | ||||
| @@ -5,7 +5,7 @@ use crate::{cached_value, cached_value_getters, ExternRef, ExternalReferenceType | ||||
| use alloc::rc::Rc; | ||||
|  | ||||
| #[repr(u8)] | ||||
| #[derive(Clone)] | ||||
| #[derive(Clone, Eq, PartialEq)] | ||||
| pub enum MoveCategory { | ||||
|     Physical = 0, | ||||
|     Special = 1, | ||||
| @@ -13,7 +13,7 @@ pub enum MoveCategory { | ||||
| } | ||||
|  | ||||
| #[repr(u8)] | ||||
| #[derive(Clone)] | ||||
| #[derive(Clone, Eq, PartialEq)] | ||||
| pub enum MoveTarget { | ||||
|     Adjacent, | ||||
|     AdjacentAlly, | ||||
|   | ||||
| @@ -68,6 +68,10 @@ impl StringKey { | ||||
|     pub fn hash(&self) -> u32 { | ||||
|         self.data.hash.borrow().unwrap() | ||||
|     } | ||||
|  | ||||
|     pub fn eq(&self, other: &str) -> bool { | ||||
|         self.hash() == get_hash(other) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl PartialEq for StringKey { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user