Code: |
ajouter_oeuf_param({"ID" => A, "SHINY" => B, "GR" => C, "FORM" => D ,"MOVE" => ["a","b","c", "d"], "STAT" => [atk,def,vit,atks,defs] }) |
Code: |
# ------------------------------------------------------ # ajouter_oeuf # Ajoute un oeuf dont l'espèce est déterminée par id # ------------------------------------------------------ def ajouter_oeuf(mother, father = nil) egg = Pokemon.new.new_egg(mother, father) ajouter_pokemon_cree(egg) end |
Code: |
def ajouter_oeuf_param(hash_b) if hash_b["ID"] == nil mother(hash_b["ID"]) return end egg_parame = Pokemon.new.new_egg(hash_b["ID"], hash_b["SHINY"]) if hash_b["GR"] != nil and ["F", "M", "I"].include?(hash_b["GR"]) egg_parame.set_gender(hash_b["GR"]) end if hash_b["FORM"] != nil if hash_b["FORM"].type == Fixnum egg_parame.form = hash_b["FORM"] elsif hash_b["FORM"].type == Array egg_parame.form = hash_b["FORM"][rand(hash_b["FORM"].size)] end end if hash_b["MOVE"] != nil and hash_b["MOVE"].type == Array i = 0 for skill in hash_b["MOVE"] if skill != nil and skill != "AUCUN" egg_parame.skills_set[i] = Skill.new(Skill_Info.id(skill)) end if skill == "AUCUN" egg_parame.skills_set[i] = nil end i += 1 end egg_parame.skills_set.compact! end if hash_b["STAT"] != nil and hash_b["STAT"].type == Array and hash_b["STAT"].length == 6 egg_parame.dv_modifier(hash_b["STAT"]) end ajouter_pokemon_cree(egg_parame) end |