Initial work on rune as scripting library
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -5,7 +5,7 @@ use std::fs::File;
|
||||
use std::io::{BufReader, Read};
|
||||
use std::sync::Arc;
|
||||
|
||||
use hashbrown::HashSet;
|
||||
use hashbrown::{HashMap, HashSet};
|
||||
use num_traits::PrimInt;
|
||||
use project_root::get_project_root;
|
||||
use serde_json::Value;
|
||||
@@ -223,10 +223,11 @@ pub fn load_abilities(path: &String) -> Arc<dyn AbilityLibrary> {
|
||||
if let Some(e) = value.get("effect") {
|
||||
effect = e.as_str().unwrap().into();
|
||||
}
|
||||
let mut parameters = Vec::new();
|
||||
if let Some(p) = value.get("parameters") {
|
||||
for par in p.as_array().unwrap() {
|
||||
parameters.push(parse_parameter(par));
|
||||
let mut parameters = HashMap::new();
|
||||
if let Some(pars) = value.get("parameters") {
|
||||
let pars = pars.as_object().unwrap();
|
||||
for par in pars {
|
||||
parameters.insert(par.0.as_str().into(), parse_parameter(par.1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,11 +259,11 @@ pub fn load_moves(path: &String, types: &Arc<dyn TypeLibrary>) -> Arc<dyn MoveLi
|
||||
if let Some(chance_value) = v.get("chance") {
|
||||
chance = chance_value.as_f64().unwrap() as f32;
|
||||
}
|
||||
let mut parameters = Vec::new();
|
||||
let mut parameters = HashMap::new();
|
||||
if let Some(pars) = v.get("parameters") {
|
||||
let pars = pars.as_array().unwrap();
|
||||
let pars = pars.as_object().unwrap();
|
||||
for par in pars {
|
||||
parameters.push(parse_parameter(par));
|
||||
parameters.insert(par.0.as_str().into(), parse_parameter(par.1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -451,10 +452,8 @@ fn parse_evolution(value: &Value) -> EvolutionData {
|
||||
EvolutionData::new(method, species)
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "wasm"))]
|
||||
fn load_script_resolver(path: &String) -> Arc<dyn ScriptResolver> {
|
||||
Arc::new(EmptyScriptResolver::default())
|
||||
}
|
||||
#[cfg(not(any(feature = "wasm", feature = "rune")))]
|
||||
fn load_script_resolver(path: &String) -> Arc<dyn ScriptResolver> { Arc::new(EmptyScriptResolver::default()) }
|
||||
|
||||
#[cfg(feature = "wasm")]
|
||||
fn load_script_resolver(path: &String) -> Arc<dyn ScriptResolver> {
|
||||
@@ -468,6 +467,28 @@ fn load_script_resolver(path: &String) -> Arc<dyn ScriptResolver> {
|
||||
resolver
|
||||
}
|
||||
|
||||
#[cfg(feature = "rune")]
|
||||
fn load_script_resolver(path: &String) -> Arc<dyn ScriptResolver> {
|
||||
let mut builder =
|
||||
pkmn_lib::script_implementations::rune::script_resolver::RuneScriptResolverBuilder::new().unwrap();
|
||||
// Recursively load all scripts in the scripts folder
|
||||
for entry in walkdir::WalkDir::new(path.to_string() + "scripts/") {
|
||||
let entry = entry.unwrap();
|
||||
let path = entry.path();
|
||||
if path.is_file() {
|
||||
let file = File::open(&path).unwrap();
|
||||
let mut reader = BufReader::new(file);
|
||||
let mut buffer = Vec::new();
|
||||
reader.read_to_end(&mut buffer).unwrap();
|
||||
builder
|
||||
.insert_script(path, &path.to_string_lossy(), &String::from_utf8(buffer).unwrap())
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
let resolver = builder.build().unwrap();
|
||||
resolver
|
||||
}
|
||||
|
||||
fn parse_form(
|
||||
name: StringKey,
|
||||
value: &Value,
|
||||
|
||||
@@ -1,285 +1,292 @@
|
||||
{
|
||||
"adaptability": {
|
||||
"effect": "IncreasedStab"
|
||||
},
|
||||
"aerilate": {
|
||||
"effect": "ChangeMoveType",
|
||||
"parameters": ["normal", "flying"]
|
||||
},
|
||||
"aftermath": {
|
||||
"effect": "Aftermath"
|
||||
},
|
||||
"air_lock": {
|
||||
"effect": "SuppressWeather"
|
||||
},
|
||||
"analytic": {
|
||||
"effect": "Analytic"
|
||||
},
|
||||
"anger_point": {
|
||||
"effect": "AngerPoint"
|
||||
},
|
||||
"anticipation": {
|
||||
"effect": "Anticipation"
|
||||
},
|
||||
"arena_trap": {
|
||||
"effect": "ArenaTrap"
|
||||
},
|
||||
"aroma_veil": {
|
||||
"effect": "AromaVeil"
|
||||
},
|
||||
"aura_break": {
|
||||
"effect": "AuraBreal"
|
||||
},
|
||||
"bad_dreams": {
|
||||
"effect": "BadDreams"
|
||||
},
|
||||
"battery": {
|
||||
"effect": "Battery"
|
||||
},
|
||||
"battle_armor": {
|
||||
"effect": "PreventCritical"
|
||||
},
|
||||
"battle_bond": {
|
||||
"effect": "BattleBond"
|
||||
},
|
||||
"beast_boost": {
|
||||
"effect": "BeastBoost"
|
||||
},
|
||||
"berserk": {
|
||||
"effect": "Berserk"
|
||||
},
|
||||
"big_pecks": {
|
||||
"effect": "PreventDefLowering"
|
||||
},
|
||||
"blaze": {
|
||||
"effect": "PowerUpType",
|
||||
"parameters": ["fire"]
|
||||
},
|
||||
"bulletproof": {
|
||||
"effect": "Bulletproof"
|
||||
},
|
||||
"cheek_pouch": {
|
||||
"effect": "CheekPouch"
|
||||
},
|
||||
"chlorophyll": {
|
||||
"effect": "DoubleSpeedInWeather",
|
||||
"parameters": ["HarshSunlight"]
|
||||
},
|
||||
"clear_body": {
|
||||
"effect": "PreventStatLowering"
|
||||
},
|
||||
"cloud_nine": {
|
||||
"effect": "SuppressWeather"
|
||||
},
|
||||
"color_change": {
|
||||
"effect": "ColorChange"
|
||||
},
|
||||
"comatose": {},
|
||||
"competitive": {},
|
||||
"compound_eyes": {},
|
||||
"contrary": {},
|
||||
"corrosion": {},
|
||||
"cursed_body": {},
|
||||
"cute_charm": {},
|
||||
"damp": {},
|
||||
"dancer": {},
|
||||
"dark_aura": {},
|
||||
"dazzling": {},
|
||||
"defeatist": {},
|
||||
"defiant": {},
|
||||
"delta_stream": {},
|
||||
"desolate_land": {},
|
||||
"disguise": {},
|
||||
"download": {},
|
||||
"drizzle": {},
|
||||
"drought": {},
|
||||
"dry_skin": {},
|
||||
"early_bird": {},
|
||||
"effect_spore": {},
|
||||
"electric_surge": {},
|
||||
"emergency_exit": {},
|
||||
"fairy_aura": {},
|
||||
"filter": {},
|
||||
"flame_body": {},
|
||||
"flare_boost": {},
|
||||
"flash_fire": {},
|
||||
"flower_gift": {},
|
||||
"flower_veil": {},
|
||||
"fluffy": {},
|
||||
"forecast": {},
|
||||
"forewarn": {},
|
||||
"friend_guard": {},
|
||||
"frisk": {},
|
||||
"full_metal_body": {},
|
||||
"fur_coat": {},
|
||||
"gale_wings": {},
|
||||
"galvanize": {},
|
||||
"gluttony": {},
|
||||
"gooey": {},
|
||||
"grass_pelt": {},
|
||||
"grassy_surge": {},
|
||||
"guts": {},
|
||||
"harvest": {},
|
||||
"healer": {},
|
||||
"heatproof": {},
|
||||
"heavy_metal": {},
|
||||
"honey_gather": {},
|
||||
"huge_power": {},
|
||||
"hustle": {},
|
||||
"hydration": {},
|
||||
"hyper_cutter": {},
|
||||
"ice_body": {},
|
||||
"illuminate": {},
|
||||
"illusion": {},
|
||||
"immunity": {},
|
||||
"imposter": {},
|
||||
"infiltrator": {},
|
||||
"innards_out": {},
|
||||
"inner_focus": {},
|
||||
"insomnia": {},
|
||||
"intimidate": {},
|
||||
"iron_barbs": {},
|
||||
"iron_fist": {},
|
||||
"justified": {},
|
||||
"keen_eye": {},
|
||||
"klutz": {},
|
||||
"leaf_guard": {},
|
||||
"levitate": {},
|
||||
"light_metal": {},
|
||||
"lightning_rod": {},
|
||||
"limber": {},
|
||||
"liquid_ooze": {},
|
||||
"liquid_voice": {},
|
||||
"long_reach": {},
|
||||
"magic_bounce": {},
|
||||
"magic_guard": {},
|
||||
"magician": {},
|
||||
"magma_armor": {},
|
||||
"magnet_pull": {},
|
||||
"marvel_scale": {},
|
||||
"mega_launcher": {},
|
||||
"merciless": {},
|
||||
"minus": {},
|
||||
"misty_surge": {},
|
||||
"mold_breaker": {},
|
||||
"moody": {},
|
||||
"motor_drive": {},
|
||||
"moxie": {},
|
||||
"multiscale": {},
|
||||
"multitype": {},
|
||||
"mummy": {},
|
||||
"natural_cure": {},
|
||||
"no_guard": {},
|
||||
"normalize": {},
|
||||
"oblivious": {},
|
||||
"overcoat": {},
|
||||
"overgrow": {},
|
||||
"own_tempo": {},
|
||||
"parental_bond": {},
|
||||
"pickpocket": {},
|
||||
"pickup": {},
|
||||
"pixilate": {},
|
||||
"plus": {},
|
||||
"poison_heal": {},
|
||||
"poison_point": {},
|
||||
"poison_touch": {},
|
||||
"power_construct": {},
|
||||
"power_of_alchemy": {},
|
||||
"prankster": {},
|
||||
"pressure": {},
|
||||
"primordial_sea": {},
|
||||
"prism_armor": {},
|
||||
"protean": {},
|
||||
"psychic_surge": {},
|
||||
"pure_power": {},
|
||||
"queenly_majesty": {},
|
||||
"quick_feet": {},
|
||||
"rain_dish": {},
|
||||
"rattled": {},
|
||||
"receiver": {},
|
||||
"reckless": {},
|
||||
"refrigerate": {},
|
||||
"regenerator": {},
|
||||
"rivalry": {},
|
||||
"rks_system": {},
|
||||
"rock_head": {},
|
||||
"rough_skin": {},
|
||||
"run_away": {},
|
||||
"sand_force": {},
|
||||
"sand_rush": {},
|
||||
"sand_stream": {},
|
||||
"sand_veil": {},
|
||||
"sap_sipper": {},
|
||||
"schooling": {},
|
||||
"scrappy": {},
|
||||
"serene_grace": {},
|
||||
"shadow_shield": {},
|
||||
"shadow_tag": {},
|
||||
"shed_skin": {},
|
||||
"sheer_force": {},
|
||||
"shell_armor": {},
|
||||
"shield_dust": {},
|
||||
"shields_down": {},
|
||||
"simple": {},
|
||||
"skill_link": {},
|
||||
"slow_start": {},
|
||||
"slush_rush": {},
|
||||
"sniper": {},
|
||||
"snow_cloak": {},
|
||||
"snow_warning": {},
|
||||
"solar_power": {},
|
||||
"solid_rock": {},
|
||||
"soul_heart": {},
|
||||
"soundproof": {},
|
||||
"speed_boost": {},
|
||||
"stakeout": {},
|
||||
"stall": {},
|
||||
"stamina": {},
|
||||
"stance_change": {},
|
||||
"static": {},
|
||||
"steadfast": {},
|
||||
"steelworker": {},
|
||||
"stench": {},
|
||||
"sticky_hold": {},
|
||||
"storm_drain": {},
|
||||
"strong_jaw": {},
|
||||
"sturdy": {},
|
||||
"suction_cups": {},
|
||||
"super_luck": {},
|
||||
"surge_surfer": {},
|
||||
"swarm": {},
|
||||
"sweet_veil": {},
|
||||
"swift_swim": {},
|
||||
"symbiosis": {},
|
||||
"synchronize": {},
|
||||
"tangled_feet": {},
|
||||
"tangling_hair": {},
|
||||
"technician": {},
|
||||
"telepathy": {},
|
||||
"teravolt": {},
|
||||
"thick_fat": {},
|
||||
"tinted_lens": {},
|
||||
"torrent": {},
|
||||
"tough_claws": {},
|
||||
"toxic_boost": {},
|
||||
"trace": {},
|
||||
"triage": {},
|
||||
"truant": {},
|
||||
"turboblaze": {},
|
||||
"unaware": {},
|
||||
"unburden": {},
|
||||
"unnerve": {},
|
||||
"victory_star": {},
|
||||
"vital_spirit": {},
|
||||
"volt_absorb": {},
|
||||
"water_absorb": {},
|
||||
"water_bubble": {},
|
||||
"water_compaction": {},
|
||||
"water_veil": {},
|
||||
"weak_armor": {},
|
||||
"white_smoke": {},
|
||||
"wimp_out": {},
|
||||
"wonder_guard": {},
|
||||
"wonder_skin": {},
|
||||
"zen_mode": {}
|
||||
"adaptability": {
|
||||
"effect": "IncreasedStab"
|
||||
},
|
||||
"aerilate": {
|
||||
"effect": "ChangeMoveType",
|
||||
"parameters": {
|
||||
"from": "normal",
|
||||
"to": "flying"
|
||||
}
|
||||
},
|
||||
"aftermath": {
|
||||
"effect": "Aftermath"
|
||||
},
|
||||
"air_lock": {
|
||||
"effect": "SuppressWeather"
|
||||
},
|
||||
"analytic": {
|
||||
"effect": "Analytic"
|
||||
},
|
||||
"anger_point": {
|
||||
"effect": "AngerPoint"
|
||||
},
|
||||
"anticipation": {
|
||||
"effect": "Anticipation"
|
||||
},
|
||||
"arena_trap": {
|
||||
"effect": "ArenaTrap"
|
||||
},
|
||||
"aroma_veil": {
|
||||
"effect": "AromaVeil"
|
||||
},
|
||||
"aura_break": {
|
||||
"effect": "AuraBreal"
|
||||
},
|
||||
"bad_dreams": {
|
||||
"effect": "BadDreams"
|
||||
},
|
||||
"battery": {
|
||||
"effect": "Battery"
|
||||
},
|
||||
"battle_armor": {
|
||||
"effect": "PreventCritical"
|
||||
},
|
||||
"battle_bond": {
|
||||
"effect": "BattleBond"
|
||||
},
|
||||
"beast_boost": {
|
||||
"effect": "BeastBoost"
|
||||
},
|
||||
"berserk": {
|
||||
"effect": "Berserk"
|
||||
},
|
||||
"big_pecks": {
|
||||
"effect": "PreventDefLowering"
|
||||
},
|
||||
"blaze": {
|
||||
"effect": "PowerUpType",
|
||||
"parameters": {
|
||||
"type": "fire"
|
||||
}
|
||||
},
|
||||
"bulletproof": {
|
||||
"effect": "Bulletproof"
|
||||
},
|
||||
"cheek_pouch": {
|
||||
"effect": "CheekPouch"
|
||||
},
|
||||
"chlorophyll": {
|
||||
"effect": "DoubleSpeedInWeather",
|
||||
"parameters": {
|
||||
"weather": "HarshSunlight"
|
||||
}
|
||||
},
|
||||
"clear_body": {
|
||||
"effect": "PreventStatLowering"
|
||||
},
|
||||
"cloud_nine": {
|
||||
"effect": "SuppressWeather"
|
||||
},
|
||||
"color_change": {
|
||||
"effect": "ColorChange"
|
||||
},
|
||||
"comatose": {},
|
||||
"competitive": {},
|
||||
"compound_eyes": {},
|
||||
"contrary": {},
|
||||
"corrosion": {},
|
||||
"cursed_body": {},
|
||||
"cute_charm": {},
|
||||
"damp": {},
|
||||
"dancer": {},
|
||||
"dark_aura": {},
|
||||
"dazzling": {},
|
||||
"defeatist": {},
|
||||
"defiant": {},
|
||||
"delta_stream": {},
|
||||
"desolate_land": {},
|
||||
"disguise": {},
|
||||
"download": {},
|
||||
"drizzle": {},
|
||||
"drought": {},
|
||||
"dry_skin": {},
|
||||
"early_bird": {},
|
||||
"effect_spore": {},
|
||||
"electric_surge": {},
|
||||
"emergency_exit": {},
|
||||
"fairy_aura": {},
|
||||
"filter": {},
|
||||
"flame_body": {},
|
||||
"flare_boost": {},
|
||||
"flash_fire": {},
|
||||
"flower_gift": {},
|
||||
"flower_veil": {},
|
||||
"fluffy": {},
|
||||
"forecast": {},
|
||||
"forewarn": {},
|
||||
"friend_guard": {},
|
||||
"frisk": {},
|
||||
"full_metal_body": {},
|
||||
"fur_coat": {},
|
||||
"gale_wings": {},
|
||||
"galvanize": {},
|
||||
"gluttony": {},
|
||||
"gooey": {},
|
||||
"grass_pelt": {},
|
||||
"grassy_surge": {},
|
||||
"guts": {},
|
||||
"harvest": {},
|
||||
"healer": {},
|
||||
"heatproof": {},
|
||||
"heavy_metal": {},
|
||||
"honey_gather": {},
|
||||
"huge_power": {},
|
||||
"hustle": {},
|
||||
"hydration": {},
|
||||
"hyper_cutter": {},
|
||||
"ice_body": {},
|
||||
"illuminate": {},
|
||||
"illusion": {},
|
||||
"immunity": {},
|
||||
"imposter": {},
|
||||
"infiltrator": {},
|
||||
"innards_out": {},
|
||||
"inner_focus": {},
|
||||
"insomnia": {},
|
||||
"intimidate": {},
|
||||
"iron_barbs": {},
|
||||
"iron_fist": {},
|
||||
"justified": {},
|
||||
"keen_eye": {},
|
||||
"klutz": {},
|
||||
"leaf_guard": {},
|
||||
"levitate": {},
|
||||
"light_metal": {},
|
||||
"lightning_rod": {},
|
||||
"limber": {},
|
||||
"liquid_ooze": {},
|
||||
"liquid_voice": {},
|
||||
"long_reach": {},
|
||||
"magic_bounce": {},
|
||||
"magic_guard": {},
|
||||
"magician": {},
|
||||
"magma_armor": {},
|
||||
"magnet_pull": {},
|
||||
"marvel_scale": {},
|
||||
"mega_launcher": {},
|
||||
"merciless": {},
|
||||
"minus": {},
|
||||
"misty_surge": {},
|
||||
"mold_breaker": {},
|
||||
"moody": {},
|
||||
"motor_drive": {},
|
||||
"moxie": {},
|
||||
"multiscale": {},
|
||||
"multitype": {},
|
||||
"mummy": {},
|
||||
"natural_cure": {},
|
||||
"no_guard": {},
|
||||
"normalize": {},
|
||||
"oblivious": {},
|
||||
"overcoat": {},
|
||||
"overgrow": {},
|
||||
"own_tempo": {},
|
||||
"parental_bond": {},
|
||||
"pickpocket": {},
|
||||
"pickup": {},
|
||||
"pixilate": {},
|
||||
"plus": {},
|
||||
"poison_heal": {},
|
||||
"poison_point": {},
|
||||
"poison_touch": {},
|
||||
"power_construct": {},
|
||||
"power_of_alchemy": {},
|
||||
"prankster": {},
|
||||
"pressure": {},
|
||||
"primordial_sea": {},
|
||||
"prism_armor": {},
|
||||
"protean": {},
|
||||
"psychic_surge": {},
|
||||
"pure_power": {},
|
||||
"queenly_majesty": {},
|
||||
"quick_feet": {},
|
||||
"rain_dish": {},
|
||||
"rattled": {},
|
||||
"receiver": {},
|
||||
"reckless": {},
|
||||
"refrigerate": {},
|
||||
"regenerator": {},
|
||||
"rivalry": {},
|
||||
"rks_system": {},
|
||||
"rock_head": {},
|
||||
"rough_skin": {},
|
||||
"run_away": {},
|
||||
"sand_force": {},
|
||||
"sand_rush": {},
|
||||
"sand_stream": {},
|
||||
"sand_veil": {},
|
||||
"sap_sipper": {},
|
||||
"schooling": {},
|
||||
"scrappy": {},
|
||||
"serene_grace": {},
|
||||
"shadow_shield": {},
|
||||
"shadow_tag": {},
|
||||
"shed_skin": {},
|
||||
"sheer_force": {},
|
||||
"shell_armor": {},
|
||||
"shield_dust": {},
|
||||
"shields_down": {},
|
||||
"simple": {},
|
||||
"skill_link": {},
|
||||
"slow_start": {},
|
||||
"slush_rush": {},
|
||||
"sniper": {},
|
||||
"snow_cloak": {},
|
||||
"snow_warning": {},
|
||||
"solar_power": {},
|
||||
"solid_rock": {},
|
||||
"soul_heart": {},
|
||||
"soundproof": {},
|
||||
"speed_boost": {},
|
||||
"stakeout": {},
|
||||
"stall": {},
|
||||
"stamina": {},
|
||||
"stance_change": {},
|
||||
"static": {},
|
||||
"steadfast": {},
|
||||
"steelworker": {},
|
||||
"stench": {},
|
||||
"sticky_hold": {},
|
||||
"storm_drain": {},
|
||||
"strong_jaw": {},
|
||||
"sturdy": {},
|
||||
"suction_cups": {},
|
||||
"super_luck": {},
|
||||
"surge_surfer": {},
|
||||
"swarm": {},
|
||||
"sweet_veil": {},
|
||||
"swift_swim": {},
|
||||
"symbiosis": {},
|
||||
"synchronize": {},
|
||||
"tangled_feet": {},
|
||||
"tangling_hair": {},
|
||||
"technician": {},
|
||||
"telepathy": {},
|
||||
"teravolt": {},
|
||||
"thick_fat": {},
|
||||
"tinted_lens": {},
|
||||
"torrent": {},
|
||||
"tough_claws": {},
|
||||
"toxic_boost": {},
|
||||
"trace": {},
|
||||
"triage": {},
|
||||
"truant": {},
|
||||
"turboblaze": {},
|
||||
"unaware": {},
|
||||
"unburden": {},
|
||||
"unnerve": {},
|
||||
"victory_star": {},
|
||||
"vital_spirit": {},
|
||||
"volt_absorb": {},
|
||||
"water_absorb": {},
|
||||
"water_bubble": {},
|
||||
"water_compaction": {},
|
||||
"water_veil": {},
|
||||
"weak_armor": {},
|
||||
"white_smoke": {},
|
||||
"wimp_out": {},
|
||||
"wonder_guard": {},
|
||||
"wonder_skin": {},
|
||||
"zen_mode": {}
|
||||
}
|
||||
@@ -29,9 +29,9 @@
|
||||
"effect": {
|
||||
"name": "drain",
|
||||
"chance": -1,
|
||||
"parameters": [
|
||||
0.5
|
||||
]
|
||||
"parameters": {
|
||||
"drain_mod": 0.5
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -65,9 +65,9 @@
|
||||
"effect": {
|
||||
"name": "change_target_special_defense",
|
||||
"chance": 10,
|
||||
"parameters": [
|
||||
-1
|
||||
]
|
||||
"parameters": {
|
||||
"amount": -1
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -85,9 +85,9 @@
|
||||
"effect": {
|
||||
"name": "change_target_defense",
|
||||
"chance": -1,
|
||||
"parameters": [
|
||||
2
|
||||
]
|
||||
"parameters": {
|
||||
"amount": 2
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -129,9 +129,9 @@
|
||||
"effect": {
|
||||
"name": "change_target_special_defense",
|
||||
"chance": -1,
|
||||
"parameters": [
|
||||
-2
|
||||
]
|
||||
"parameters": {
|
||||
"amount": -2
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -233,9 +233,9 @@
|
||||
],
|
||||
"effect": {
|
||||
"name": "change_target_speed",
|
||||
"parameters": [
|
||||
2
|
||||
]
|
||||
"parameters": {
|
||||
"amount": 2
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -324,9 +324,9 @@
|
||||
],
|
||||
"effect": {
|
||||
"name": "change_target_special_defense",
|
||||
"parameters": [
|
||||
2
|
||||
]
|
||||
"parameters": {
|
||||
"amount": 2
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -363,9 +363,9 @@
|
||||
"effect": {
|
||||
"name": "change_all_target_stats",
|
||||
"chance": 10,
|
||||
"parameters": [
|
||||
1
|
||||
]
|
||||
"parameters": {
|
||||
"amount": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -397,9 +397,9 @@
|
||||
],
|
||||
"effect": {
|
||||
"name": "heal_each_end_of_turn",
|
||||
"parameters": [
|
||||
6.25
|
||||
]
|
||||
"parameters": {
|
||||
"percent": 6.25
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -466,9 +466,9 @@
|
||||
],
|
||||
"effect": {
|
||||
"name": "change_target_special_defense",
|
||||
"parameters": [
|
||||
1
|
||||
]
|
||||
"parameters": {
|
||||
"amount": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -592,9 +592,9 @@
|
||||
"effect": {
|
||||
"name": "change_target_attack",
|
||||
"chance": 10,
|
||||
"parameters": [
|
||||
-1
|
||||
]
|
||||
"parameters": {
|
||||
"amount": -1
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -660,9 +660,9 @@
|
||||
],
|
||||
"effect": {
|
||||
"name": "change_target_attack",
|
||||
"parameters": [
|
||||
-1
|
||||
]
|
||||
"parameters": {
|
||||
"amount": -1
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -3805,11 +3805,11 @@
|
||||
"ignore-substitute"
|
||||
],
|
||||
"effect": {
|
||||
"name": "ChangeTargetAtt",
|
||||
"name": "change_target_attack",
|
||||
"chance": -1,
|
||||
"parameters": [
|
||||
-1
|
||||
]
|
||||
"parameters": {
|
||||
"amount": -1
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -5082,11 +5082,11 @@
|
||||
"mirror"
|
||||
],
|
||||
"effect": {
|
||||
"name": "ChangeTargetDef",
|
||||
"name": "change_target_defense",
|
||||
"chance": -1,
|
||||
"parameters": [
|
||||
-1
|
||||
]
|
||||
"parameters": {
|
||||
"amount": -1
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
13
tests/data/scripts/moves/test.rn
Normal file
13
tests/data/scripts/moves/test.rn
Normal file
@@ -0,0 +1,13 @@
|
||||
mod moves {
|
||||
|
||||
struct TestMove;
|
||||
|
||||
impl TestMove {
|
||||
pub fn change_speed(self, choice, speed) {
|
||||
println(`change_speed: ${choice.speed()}`);
|
||||
println(`user level: ${choice.user().level()}`);
|
||||
speed.value = 100;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,8 +6,8 @@
|
||||
use std::sync::{Arc, LazyLock};
|
||||
|
||||
use pkmn_lib::dynamic_data::{
|
||||
Battle, BattleParty, DamageSource, DynamicLibrary, ExecutingMove, MoveChoice, PokemonBuilder, PokemonParty,
|
||||
ScriptCategory, ScriptContainer, ScriptOwnerData, TurnChoice, VolatileScriptsOwner,
|
||||
Battle, BattleParty, DamageSource, DynamicLibrary, ExecutingMove, MoveChoice, PassChoice, PokemonBuilder,
|
||||
PokemonParty, ScriptCategory, ScriptContainer, ScriptOwnerData, TurnChoice, VolatileScriptsOwner,
|
||||
};
|
||||
|
||||
use crate::common::library_loader;
|
||||
@@ -17,9 +17,7 @@ pub mod datatests;
|
||||
|
||||
static LIBRARY: LazyLock<Arc<dyn DynamicLibrary>> = LazyLock::new(|| library_loader::load_library().library);
|
||||
|
||||
fn get_library() -> Arc<dyn DynamicLibrary> {
|
||||
LIBRARY.clone()
|
||||
}
|
||||
fn get_library() -> Arc<dyn DynamicLibrary> { LIBRARY.clone() }
|
||||
|
||||
#[test]
|
||||
fn validate_library_load() {
|
||||
@@ -35,7 +33,7 @@ fn validate_library_load() {
|
||||
\n\t- Abilities load time: {} ms\
|
||||
\n\t- Moves load time: {} ms\
|
||||
\n\t- Species load time: {} ms\
|
||||
\n\t- WASM load time: {} ms\
|
||||
\n\t- Script load time: {} ms\
|
||||
",
|
||||
(end_time - start_time).num_milliseconds(),
|
||||
result.types_load_time.num_milliseconds(),
|
||||
@@ -49,6 +47,24 @@ fn validate_library_load() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rune_test() {
|
||||
let result = library_loader::load_library();
|
||||
let library = result.library;
|
||||
let script = library
|
||||
.load_script(ScriptOwnerData::None, ScriptCategory::Move, &"TestMove".into())
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
assert_eq!(script.name().unwrap().str(), "TestMove");
|
||||
let p1 = PokemonBuilder::new(library.clone(), "charizard".into(), 100)
|
||||
.build()
|
||||
.unwrap();
|
||||
let turn_choice = Arc::new(TurnChoice::Pass(PassChoice::new(p1)));
|
||||
let mut speed = 0;
|
||||
script.change_speed(&turn_choice, &mut speed).unwrap();
|
||||
assert_eq!(speed, 100);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn load_non_existing_wasm_script() {
|
||||
let start_time = chrono::Utc::now();
|
||||
@@ -63,7 +79,7 @@ fn load_non_existing_wasm_script() {
|
||||
\n\t- Abilities load time: {} ms\
|
||||
\n\t- Moves load time: {} ms\
|
||||
\n\t- Species load time: {} ms\
|
||||
\n\t- WASM load time: {} ms\
|
||||
\n\t- Script load time: {} ms\
|
||||
",
|
||||
(end_time - start_time).num_milliseconds(),
|
||||
result.types_load_time.num_milliseconds(),
|
||||
|
||||
Reference in New Issue
Block a user