about summary refs log tree commit diff stats
path: root/app/jobs
diff options
context:
space:
mode:
Diffstat (limited to 'app/jobs')
-rw-r--r--app/jobs/pokeviewer/extract_save_data_job.rb20
1 files changed, 15 insertions, 5 deletions
diff --git a/app/jobs/pokeviewer/extract_save_data_job.rb b/app/jobs/pokeviewer/extract_save_data_job.rb index 0a9b790..404716a 100644 --- a/app/jobs/pokeviewer/extract_save_data_job.rb +++ b/app/jobs/pokeviewer/extract_save_data_job.rb
@@ -22,7 +22,9 @@ module Pokeviewer
22 end 22 end
23 end 23 end
24 24
25 pokemons = args["pokemon"].map do |param| 25 game.pokemon.clear
26
27 args["pokemon"].each do |param|
26 pk = Pokemon.find_or_create_by!(key: param["key"]) do |r| 28 pk = Pokemon.find_or_create_by!(key: param["key"]) do |r|
27 r.species_id = param["species"] 29 r.species_id = param["species"]
28 r.ot_name = param["otName"] 30 r.ot_name = param["otName"]
@@ -47,6 +49,18 @@ module Pokeviewer
47 end 49 end
48 end 50 end
49 51
52 pk.trainer = game
53
54 if param["storage"] == "party"
55 pk.box = nil
56 elsif param["storage"] == "box"
57 pk.box = param["box"]
58 end
59
60 pk.slot = param["slot"]
61
62 pk.save!
63
50 rev = Revision.new(pokemon: pk) 64 rev = Revision.new(pokemon: pk)
51 rev.nickname = param["nickname"] 65 rev.nickname = param["nickname"]
52 rev.experience = param["experience"] 66 rev.experience = param["experience"]
@@ -85,11 +99,7 @@ module Pokeviewer
85 if pk.revisions.empty? or rev.diff?(pk.revisions.last) 99 if pk.revisions.empty? or rev.diff?(pk.revisions.last)
86 rev.save! 100 rev.save!
87 end 101 end
88
89 pk
90 end 102 end
91
92 game.pokemon = pokemons
93 end 103 end
94 end 104 end
95end 105end