about summary refs log tree commit diff stats
path: root/app/jobs
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2017-09-24 12:39:17 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2017-09-24 12:39:17 -0400
commit012b083cbd74ab687d5529258ff045319265e594 (patch)
tree147d26ccd465fd0761863ca3ac1176bf865166ff /app/jobs
parent1ecba46a8cb0db962908f47ab4e054ee04804a4a (diff)
downloadpokeviewer-012b083cbd74ab687d5529258ff045319265e594.tar.gz
pokeviewer-012b083cbd74ab687d5529258ff045319265e594.tar.bz2
pokeviewer-012b083cbd74ab687d5529258ff045319265e594.zip
Added storage location information to Pokémon
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