From 012b083cbd74ab687d5529258ff045319265e594 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 24 Sep 2017 12:39:17 -0400 Subject: Added storage location information to Pokémon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/jobs/pokeviewer/extract_save_data_job.rb | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'app/jobs') 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 end end - pokemons = args["pokemon"].map do |param| + game.pokemon.clear + + args["pokemon"].each do |param| pk = Pokemon.find_or_create_by!(key: param["key"]) do |r| r.species_id = param["species"] r.ot_name = param["otName"] @@ -47,6 +49,18 @@ module Pokeviewer end end + pk.trainer = game + + if param["storage"] == "party" + pk.box = nil + elsif param["storage"] == "box" + pk.box = param["box"] + end + + pk.slot = param["slot"] + + pk.save! + rev = Revision.new(pokemon: pk) rev.nickname = param["nickname"] rev.experience = param["experience"] @@ -85,11 +99,7 @@ module Pokeviewer if pk.revisions.empty? or rev.diff?(pk.revisions.last) rev.save! end - - pk end - - game.pokemon = pokemons end end end -- cgit 1.4.1