diff --git a/data/move_data.gd b/data/move_data.gd index 70fa985..1179832 100644 --- a/data/move_data.gd +++ b/data/move_data.gd @@ -15,8 +15,50 @@ extends Resource @export var priority : int @export var target : String +@export_group("Effets") +## Probabilite (en %) de l'effet secondaire, telle que donnee par PokeAPI (0 = non precisee). +@export var effect_chance : int +## Categorie d'effet PokeAPI : "damage", "ailment", "net-good-stats", "heal", "damage+ailment", +## "swagger", "damage+lower", "damage+raise", "damage+heal", "ohko", "whole-field-effect", +## "field-effect", "force-switch", "unique". +@export var meta_category : String +## Statut inflige : "none", "paralysis", "burn", "freeze", "poison", "sleep", "confusion", +## "infatuation", "trap", "leech-seed", "yawn"... +@export var ailment : String = "none" +## Probabilite (en %) d'infliger le statut. 0 sur une capacite de statut = toujours (voir get_ailment_chance). +@export var ailment_chance : int +@export var flinch_chance : int +## Probabilite (en %) d'appliquer stat_changes. 0 sur une capacite de statut = toujours (voir get_stat_chance). +@export var stat_chance : int +@export var stat_changes : Array[StatChange] = [] +## Nombre de coups (capacites multi-coups) ; 0 = non precise (un seul coup). +@export var min_hits : int +@export var max_hits : int +## Duree en tours (capacites qui durent) ; 0 = non precise. +@export var min_turns : int +@export var max_turns : int +## % des degats infliges rendus a l'utilisateur (positif) ou subis en contrecoup (negatif). +@export var drain : int +## % des PV max soignes (positif) ou perdus (negatif). +@export var healing : int +## Bonus de taux de critique (0 = normal ; 1 = eleve ; 6 = toujours critique). +@export var crit_rate : int + func get_display_name() -> String: return L10n.pick(names, api_name.capitalize()) func get_description() -> String: return L10n.pick(descriptions) + +## Le statut est-il applique avec certitude ? (capacite de statut pure : PokeAPI laisse alors 0) +func get_ailment_chance() -> int: + if ailment == "none": return 0 + return 100 if (ailment_chance <= 0 and category == "status") else ailment_chance + +## Les changements de stats sont-ils appliques avec certitude ? +func get_stat_chance() -> int: + if stat_changes.is_empty(): return 0 + return 100 if (stat_chance <= 0 and category == "status") else stat_chance + +func is_multi_hit() -> bool: + return max_hits > 1 diff --git a/data/stat_change.gd b/data/stat_change.gd new file mode 100644 index 0000000..5b36a93 --- /dev/null +++ b/data/stat_change.gd @@ -0,0 +1,9 @@ +# data/stat_change.gd +@tool +class_name StatChange +extends Resource + +## Un changement de statistique provoque par une capacite (ex. Attaque +2, Vitesse -1). + +@export var stat : String # "attack", "defense", "special-attack", "special-defense", "speed", "accuracy", "evasion" +@export var change : int # positif = hausse, negatif = baisse diff --git a/data/stat_change.gd.uid b/data/stat_change.gd.uid new file mode 100644 index 0000000..6880ef6 --- /dev/null +++ b/data/stat_change.gd.uid @@ -0,0 +1 @@ +uid://ctw1mbfnw2jcr diff --git a/editor/move_importer.gd b/editor/move_importer.gd index 470f307..7c7c09c 100644 --- a/editor/move_importer.gd +++ b/editor/move_importer.gd @@ -53,4 +53,29 @@ func _import_move(entry : Dictionary) -> void: m.pp = PokeApiJson.get_int(j, "pp") m.priority = PokeApiJson.get_int(j, "priority") m.target = PokeApiJson.get_dict_name(j, "target") + m.effect_chance = PokeApiJson.get_int(j, "effect_chance") + + # effets : PokeAPI les range dans "meta" (absent sur certaines capacites) et "stat_changes" + var meta := PokeApiJson.get_dict(j, "meta") + m.meta_category = PokeApiJson.get_dict_name(meta, "category") + m.ailment = PokeApiJson.get_dict_name(meta, "ailment", "none") + m.ailment_chance = PokeApiJson.get_int(meta, "ailment_chance") + m.flinch_chance = PokeApiJson.get_int(meta, "flinch_chance") + m.stat_chance = PokeApiJson.get_int(meta, "stat_chance") + m.min_hits = PokeApiJson.get_int(meta, "min_hits") + m.max_hits = PokeApiJson.get_int(meta, "max_hits") + m.min_turns = PokeApiJson.get_int(meta, "min_turns") + m.max_turns = PokeApiJson.get_int(meta, "max_turns") + m.drain = PokeApiJson.get_int(meta, "drain") + m.healing = PokeApiJson.get_int(meta, "healing") + m.crit_rate = PokeApiJson.get_int(meta, "crit_rate") + + var changes : Array[StatChange] = [] + for move_entry in PokeApiJson.get_array(j, "stat_changes"): + var sc := StatChange.new() + sc.stat = PokeApiJson.get_dict_name(move_entry, "stat") + sc.change = PokeApiJson.get_int(move_entry, "change") + if sc.stat != "" and sc.change != 0: changes.append(sc) + m.stat_changes = changes + ResourceSaver.save(m, path)