Compare commits
2 commits
bb75ce1b6c
...
df7ca58c5e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df7ca58c5e | ||
|
|
d00dc5bba2 |
23
data/evolution_condition.gd
Normal file
23
data/evolution_condition.gd
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# data/evolution_condition.gd
|
||||
@tool
|
||||
class_name EvolutionCondition
|
||||
extends Resource
|
||||
|
||||
@export var trigger : String # "level-up", "trade", "use-item", "shed"...
|
||||
@export var min_level : int = 0 # 0 = pas de condition de niveau
|
||||
@export var item : String # objet à utiliser, "" si aucun
|
||||
@export var held_item : String # objet à tenir, "" si aucun
|
||||
@export var known_move : String # capacité requise, "" si aucune
|
||||
@export var known_move_type : String # type de capacité requis, "" si aucun
|
||||
@export var min_happiness : int = 0
|
||||
@export var min_beauty : int = 0
|
||||
@export var min_affection : int = 0
|
||||
@export var time_of_day : String # "day", "night", "" si indifférent
|
||||
@export var location : String # lieu requis, "" si aucun
|
||||
@export var trade_species : String # échange contre cette espèce précise, "" sinon
|
||||
@export var party_species : String # espèce requise dans l'équipe, "" si aucune
|
||||
@export var party_type : String # type requis dans l'équipe, "" si aucun
|
||||
@export var relative_physical_stats : int = 0 # -1, 0, 1 (atk<def, atk=def, atk>def) ; PokeAPI: null -> 0 par défaut, ambigu avec "égal"
|
||||
@export var needs_overworld_rain : bool = false
|
||||
@export var turn_upside_down : bool = false
|
||||
@export var gender : int = -1 # -1 = indifférent, 1 = femelle, 2 = mâle (valeurs de l'API PokeAPI)
|
||||
1
data/evolution_condition.gd.uid
Normal file
1
data/evolution_condition.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://81p3aw271qyx
|
||||
|
|
@ -3,12 +3,5 @@
|
|||
class_name EvolutionEdge
|
||||
extends Resource
|
||||
|
||||
@export var trigger : String # "level-up", "trade", "use-item", "shed"...
|
||||
@export var min_level : int = 0 # 0 = pas de condition de niveau
|
||||
@export var item : String # objet à utiliser, "" si aucun
|
||||
@export var held_item : String # objet à tenir, "" si aucun
|
||||
@export var known_move : String # capacité requise, "" si aucune
|
||||
@export var min_happiness : int = 0
|
||||
@export var time_of_day : String # "day", "night", "" si indifférent
|
||||
@export var trade_species : String # échange contre cette espèce précise, "" sinon
|
||||
@export var target : EvolutionNode
|
||||
@export var conditions : Array[EvolutionCondition] = [] # chaque condition suffit à elle seule
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
class_name TypeData
|
||||
extends Resource
|
||||
|
||||
@export var icon : Texture2D # illustration assignée à la main dans l'inspecteur, jamais touchée par l'import
|
||||
@export var id : int
|
||||
@export var api_name : String
|
||||
@export var names : Dictionary = {}
|
||||
|
|
|
|||
|
|
@ -36,17 +36,30 @@ func _build_node(link : Dictionary) -> EvolutionNode:
|
|||
node.species_name = link["species"]["name"]
|
||||
for evo in link["evolves_to"]:
|
||||
var edge := EvolutionEdge.new()
|
||||
var details : Array = evo["evolution_details"]
|
||||
if !details.is_empty():
|
||||
var det : Dictionary = details[0] # première méthode si plusieurs sont possibles
|
||||
edge.trigger = det["trigger"]["name"] if det["trigger"] != null else ""
|
||||
edge.min_level = int(det["min_level"]) if det["min_level"] != null else 0
|
||||
edge.item = det["item"]["name"] if det["item"] != null else ""
|
||||
edge.held_item = det["held_item"]["name"] if det["held_item"] != null else ""
|
||||
edge.known_move = det["known_move"]["name"] if det["known_move"] != null else ""
|
||||
edge.min_happiness = int(det["min_happiness"]) if det["min_happiness"] != null else 0
|
||||
edge.time_of_day = String(det["time_of_day"]) if det["time_of_day"] != null else ""
|
||||
edge.trade_species = det["trade_species"]["name"] if det["trade_species"] != null else ""
|
||||
edge.target = _build_node(evo)
|
||||
for det in evo["evolution_details"]:
|
||||
edge.conditions.append(_build_condition(det))
|
||||
node.evolves_to.append(edge)
|
||||
return node
|
||||
|
||||
func _build_condition(det : Dictionary) -> EvolutionCondition:
|
||||
var c := EvolutionCondition.new()
|
||||
c.trigger = det["trigger"]["name"] if det["trigger"] != null else ""
|
||||
c.min_level = int(det["min_level"]) if det["min_level"] != null else 0
|
||||
c.item = det["item"]["name"] if det["item"] != null else ""
|
||||
c.held_item = det["held_item"]["name"] if det["held_item"] != null else ""
|
||||
c.known_move = det["known_move"]["name"] if det["known_move"] != null else ""
|
||||
c.known_move_type = det["known_move_type"]["name"] if det["known_move_type"] != null else ""
|
||||
c.min_happiness = int(det["min_happiness"]) if det["min_happiness"] != null else 0
|
||||
c.min_beauty = int(det["min_beauty"]) if det["min_beauty"] != null else 0
|
||||
c.min_affection = int(det["min_affection"]) if det["min_affection"] != null else 0
|
||||
c.time_of_day = String(det["time_of_day"]) if det["time_of_day"] != null and det["time_of_day"] != "" else ""
|
||||
c.location = det["location"]["name"] if det["location"] != null else ""
|
||||
c.trade_species = det["trade_species"]["name"] if det["trade_species"] != null else ""
|
||||
c.party_species = det["party_species"]["name"] if det["party_species"] != null else ""
|
||||
c.party_type = det["party_type"]["name"] if det["party_type"] != null else ""
|
||||
c.relative_physical_stats = int(det["relative_physical_stats"]) if det["relative_physical_stats"] != null else 0
|
||||
c.needs_overworld_rain = det["needs_overworld_rain"]
|
||||
c.turn_upside_down = det["turn_upside_down"]
|
||||
c.gender = int(det["gender"]) if det["gender"] != null else -1
|
||||
return c
|
||||
|
|
|
|||
|
|
@ -41,7 +41,13 @@ func _import_type(entry : Dictionary) -> void:
|
|||
message.emit("[color=red]Échec : %s[/color]" % entry["name"])
|
||||
return
|
||||
|
||||
var t := TypeData.new()
|
||||
# recharge la ressource existante pour préserver l'icône assignée à la main
|
||||
var t : TypeData
|
||||
if FileAccess.file_exists(path):
|
||||
t = ResourceLoader.load(path, "", ResourceLoader.CACHE_MODE_REPLACE) as TypeData
|
||||
if t == null:
|
||||
t = TypeData.new()
|
||||
|
||||
t.id = j["id"]
|
||||
t.api_name = j["name"]
|
||||
t.names = PokeApiText.names(j["names"], _languages)
|
||||
|
|
@ -53,6 +59,7 @@ func _import_type(entry : Dictionary) -> void:
|
|||
t.half_damage_from = _names_of(rel["half_damage_from"])
|
||||
t.no_damage_to = _names_of(rel["no_damage_to"])
|
||||
t.no_damage_from = _names_of(rel["no_damage_from"])
|
||||
# t.icon n'est jamais touché ici
|
||||
ResourceSaver.save(t, path)
|
||||
|
||||
func _names_of(entries : Array) -> PackedStringArray:
|
||||
|
|
|
|||
Loading…
Reference in a new issue