diff options
-rw-r--r-- | app/jobs/pokeviewer/extract_save_data_job.rb | 30 | ||||
-rw-r--r-- | app/models/pokeviewer/gift_ribbon.rb | 5 | ||||
-rw-r--r-- | app/models/pokeviewer/revision.rb | 14 | ||||
-rw-r--r-- | app/models/pokeviewer/trainer.rb | 18 | ||||
-rw-r--r-- | db/migrate/20170929221317_create_pokeviewer_gift_ribbons.rb | 9 | ||||
-rw-r--r-- | db/migrate/20170930021856_add_gift_ribbons_to_trainer.rb | 34 | ||||
-rw-r--r-- | db/seeds.rb | 65 | ||||
-rw-r--r-- | test/dummy/db/schema.rb | 22 |
8 files changed, 189 insertions, 8 deletions
diff --git a/app/jobs/pokeviewer/extract_save_data_job.rb b/app/jobs/pokeviewer/extract_save_data_job.rb index f7b8f8f..b60a8c5 100644 --- a/app/jobs/pokeviewer/extract_save_data_job.rb +++ b/app/jobs/pokeviewer/extract_save_data_job.rb | |||
@@ -22,6 +22,36 @@ module Pokeviewer | |||
22 | end | 22 | end |
23 | end | 23 | end |
24 | 24 | ||
25 | if args.key? "marineRibbon" | ||
26 | game.marine_ribbon = GiftRibbon.find_by_id(args["marineRibbon"]) | ||
27 | end | ||
28 | |||
29 | if args.key? "landRibbon" | ||
30 | game.land_ribbon = GiftRibbon.find_by_id(args["landRibbon"]) | ||
31 | end | ||
32 | |||
33 | if args.key? "skyRibbon" | ||
34 | game.sky_ribbon = GiftRibbon.find_by_id(args["skyRibbon"]) | ||
35 | end | ||
36 | |||
37 | if args.key? "countryRibbon" | ||
38 | game.country_ribbon = GiftRibbon.find_by_id(args["countryRibbon"]) | ||
39 | end | ||
40 | |||
41 | if args.key? "nationalRibbon" | ||
42 | game.national_ribbon = GiftRibbon.find_by_id(args["nationalRibbon"]) | ||
43 | end | ||
44 | |||
45 | if args.key? "earthRibbon" | ||
46 | game.earth_ribbon = GiftRibbon.find_by_id(args["earthRibbon"]) | ||
47 | end | ||
48 | |||
49 | if args.key? "worldRibbon" | ||
50 | game.world_ribbon = GiftRibbon.find_by_id(args["worldRibbon"]) | ||
51 | end | ||
52 | |||
53 | game.save! if game.changed? | ||
54 | |||
25 | args["boxes"].each_with_index do |box_name,index| | 55 | args["boxes"].each_with_index do |box_name,index| |
26 | box = Box.find_or_initialize_by(trainer: game, number: index) | 56 | box = Box.find_or_initialize_by(trainer: game, number: index) |
27 | box.name = box_name | 57 | box.name = box_name |
diff --git a/app/models/pokeviewer/gift_ribbon.rb b/app/models/pokeviewer/gift_ribbon.rb new file mode 100644 index 0000000..f8f4fa5 --- /dev/null +++ b/app/models/pokeviewer/gift_ribbon.rb | |||
@@ -0,0 +1,5 @@ | |||
1 | module Pokeviewer | ||
2 | class GiftRibbon < ApplicationRecord | ||
3 | validates :description, presence: true | ||
4 | end | ||
5 | end | ||
diff --git a/app/models/pokeviewer/revision.rb b/app/models/pokeviewer/revision.rb index 4481bf0..ab4dfd3 100644 --- a/app/models/pokeviewer/revision.rb +++ b/app/models/pokeviewer/revision.rb | |||
@@ -345,7 +345,7 @@ module Pokeviewer | |||
345 | result << { | 345 | result << { |
346 | filename: "marine-ribbon.png", | 346 | filename: "marine-ribbon.png", |
347 | name: "Marine Ribbon", | 347 | name: "Marine Ribbon", |
348 | description: "" | 348 | description: pokemon.trainer.gift_ribbon_description(:marine_ribbon) |
349 | } | 349 | } |
350 | end | 350 | end |
351 | 351 | ||
@@ -353,7 +353,7 @@ module Pokeviewer | |||
353 | result << { | 353 | result << { |
354 | filename: "land-ribbon.png", | 354 | filename: "land-ribbon.png", |
355 | name: "Land Ribbon", | 355 | name: "Land Ribbon", |
356 | description: "" | 356 | description: pokemon.trainer.gift_ribbon_description(:land_ribbon) |
357 | } | 357 | } |
358 | end | 358 | end |
359 | 359 | ||
@@ -361,7 +361,7 @@ module Pokeviewer | |||
361 | result << { | 361 | result << { |
362 | filename: "sky-ribbon.png", | 362 | filename: "sky-ribbon.png", |
363 | name: "Sky Ribbon", | 363 | name: "Sky Ribbon", |
364 | description: "" | 364 | description: pokemon.trainer.gift_ribbon_description(:sky_ribbon) |
365 | } | 365 | } |
366 | end | 366 | end |
367 | 367 | ||
@@ -369,7 +369,7 @@ module Pokeviewer | |||
369 | result << { | 369 | result << { |
370 | filename: "country-ribbon.png", | 370 | filename: "country-ribbon.png", |
371 | name: "Country Ribbon", | 371 | name: "Country Ribbon", |
372 | description: "" | 372 | description: pokemon.trainer.gift_ribbon_description(:country_ribbon) |
373 | } | 373 | } |
374 | end | 374 | end |
375 | 375 | ||
@@ -377,7 +377,7 @@ module Pokeviewer | |||
377 | result << { | 377 | result << { |
378 | filename: "national-ribbon.png", | 378 | filename: "national-ribbon.png", |
379 | name: "National Ribbon", | 379 | name: "National Ribbon", |
380 | description: "" | 380 | description: pokemon.trainer.gift_ribbon_description(:national_ribbon) |
381 | } | 381 | } |
382 | end | 382 | end |
383 | 383 | ||
@@ -385,7 +385,7 @@ module Pokeviewer | |||
385 | result << { | 385 | result << { |
386 | filename: "earth-ribbon.png", | 386 | filename: "earth-ribbon.png", |
387 | name: "Earth Ribbon", | 387 | name: "Earth Ribbon", |
388 | description: "" | 388 | description: pokemon.trainer.gift_ribbon_description(:earth_ribbon) |
389 | } | 389 | } |
390 | end | 390 | end |
391 | 391 | ||
@@ -393,7 +393,7 @@ module Pokeviewer | |||
393 | result << { | 393 | result << { |
394 | filename: "world-ribbon.png", | 394 | filename: "world-ribbon.png", |
395 | name: "World Ribbon", | 395 | name: "World Ribbon", |
396 | description: "" | 396 | description: pokemon.trainer.gift_ribbon_description(:world_ribbon) |
397 | } | 397 | } |
398 | end | 398 | end |
399 | 399 | ||
diff --git a/app/models/pokeviewer/trainer.rb b/app/models/pokeviewer/trainer.rb index f890d61..7862c1e 100644 --- a/app/models/pokeviewer/trainer.rb +++ b/app/models/pokeviewer/trainer.rb | |||
@@ -16,6 +16,14 @@ module Pokeviewer | |||
16 | enumerize :game, in: [:ruby, :sapphire, :firered, :leafgreen, :emerald], | 16 | enumerize :game, in: [:ruby, :sapphire, :firered, :leafgreen, :emerald], |
17 | predicates: true | 17 | predicates: true |
18 | 18 | ||
19 | belongs_to :marine_ribbon, class_name: "GiftRibbon", optional: true | ||
20 | belongs_to :land_ribbon, class_name: "GiftRibbon", optional: true | ||
21 | belongs_to :sky_ribbon, class_name: "GiftRibbon", optional: true | ||
22 | belongs_to :country_ribbon, class_name: "GiftRibbon", optional: true | ||
23 | belongs_to :national_ribbon, class_name: "GiftRibbon", optional: true | ||
24 | belongs_to :earth_ribbon, class_name: "GiftRibbon", optional: true | ||
25 | belongs_to :world_ribbon, class_name: "GiftRibbon", optional: true | ||
26 | |||
19 | def display_number | 27 | def display_number |
20 | number.to_s.rjust(5, '0') | 28 | number.to_s.rjust(5, '0') |
21 | end | 29 | end |
@@ -23,5 +31,15 @@ module Pokeviewer | |||
23 | def party | 31 | def party |
24 | pokemon.where(box: nil).order("slot ASC") | 32 | pokemon.where(box: nil).order("slot ASC") |
25 | end | 33 | end |
34 | |||
35 | def gift_ribbon_description(ribbon) | ||
36 | gift_ribbon = send ribbon | ||
37 | |||
38 | if gift_ribbon.nil? | ||
39 | "" | ||
40 | else | ||
41 | gift_ribbon.description | ||
42 | end | ||
43 | end | ||
26 | end | 44 | end |
27 | end | 45 | end |
diff --git a/db/migrate/20170929221317_create_pokeviewer_gift_ribbons.rb b/db/migrate/20170929221317_create_pokeviewer_gift_ribbons.rb new file mode 100644 index 0000000..deedc80 --- /dev/null +++ b/db/migrate/20170929221317_create_pokeviewer_gift_ribbons.rb | |||
@@ -0,0 +1,9 @@ | |||
1 | class CreatePokeviewerGiftRibbons < ActiveRecord::Migration[5.1] | ||
2 | def change | ||
3 | create_table :pokeviewer_gift_ribbons do |t| | ||
4 | t.string :description, null: false | ||
5 | |||
6 | t.timestamps | ||
7 | end | ||
8 | end | ||
9 | end | ||
diff --git a/db/migrate/20170930021856_add_gift_ribbons_to_trainer.rb b/db/migrate/20170930021856_add_gift_ribbons_to_trainer.rb new file mode 100644 index 0000000..2a5f9b3 --- /dev/null +++ b/db/migrate/20170930021856_add_gift_ribbons_to_trainer.rb | |||
@@ -0,0 +1,34 @@ | |||
1 | class AddGiftRibbonsToTrainer < ActiveRecord::Migration[5.1] | ||
2 | def change | ||
3 | change_table :pokeviewer_trainers do |t| | ||
4 | t.references :marine_ribbon, null: true | ||
5 | t.references :land_ribbon, null: true | ||
6 | t.references :sky_ribbon, null: true | ||
7 | t.references :country_ribbon, null: true | ||
8 | t.references :national_ribbon, null: true | ||
9 | t.references :earth_ribbon, null: true | ||
10 | t.references :world_ribbon, null: true | ||
11 | end | ||
12 | |||
13 | add_foreign_key :pokeviewer_trainers, :pokeviewer_gift_ribbons, | ||
14 | column: :marine_ribbon_id | ||
15 | |||
16 | add_foreign_key :pokeviewer_trainers, :pokeviewer_gift_ribbons, | ||
17 | column: :land_ribbon_id | ||
18 | |||
19 | add_foreign_key :pokeviewer_trainers, :pokeviewer_gift_ribbons, | ||
20 | column: :sky_ribbon_id | ||
21 | |||
22 | add_foreign_key :pokeviewer_trainers, :pokeviewer_gift_ribbons, | ||
23 | column: :country_ribbon_id | ||
24 | |||
25 | add_foreign_key :pokeviewer_trainers, :pokeviewer_gift_ribbons, | ||
26 | column: :national_ribbon_id | ||
27 | |||
28 | add_foreign_key :pokeviewer_trainers, :pokeviewer_gift_ribbons, | ||
29 | column: :earth_ribbon_id | ||
30 | |||
31 | add_foreign_key :pokeviewer_trainers, :pokeviewer_gift_ribbons, | ||
32 | column: :world_ribbon_id | ||
33 | end | ||
34 | end | ||
diff --git a/db/seeds.rb b/db/seeds.rb index 221538e..500e3c6 100644 --- a/db/seeds.rb +++ b/db/seeds.rb | |||
@@ -954,4 +954,69 @@ module Pokeviewer | |||
954 | Location.create(id: 210, name: "Altering Cave") | 954 | Location.create(id: 210, name: "Altering Cave") |
955 | Location.create(id: 211, name: "Navel Rock") | 955 | Location.create(id: 211, name: "Navel Rock") |
956 | Location.create(id: 212, name: "Trainer Hill") | 956 | Location.create(id: 212, name: "Trainer Hill") |
957 | |||
958 | GiftRibbon.create(id: 1, description: "2003 REGIONAL TOURNEY CHAMPION RIBBON") | ||
959 | GiftRibbon.create(id: 2, description: "2003 NATIONAL TOURNEY CHAMPION RIBBON") | ||
960 | GiftRibbon.create(id: 3, description: "2003 GLOBAL CUP CHAMPION RIBBON") | ||
961 | GiftRibbon.create(id: 4, description: "2003 REGIONAL TOURNEY Runner-up RIBBON") | ||
962 | GiftRibbon.create(id: 5, description: "2003 NATIONAL TOURNEY Runner-up RIBBON") | ||
963 | GiftRibbon.create(id: 6, description: "2003 GLOBAL CUP Runner-up RIBBON") | ||
964 | GiftRibbon.create(id: 7, description: "2003 REGIONAL TOURNEY Semifinalist RIBBON") | ||
965 | GiftRibbon.create(id: 8, description: "2003 NATIONAL TOURNEY Semifinalist RIBBON") | ||
966 | GiftRibbon.create(id: 9, description: "2003 GLOBAL CUP Semifinalist RIBBON") | ||
967 | GiftRibbon.create(id: 10, description: "2004 REGIONAL TOURNEY CHAMPION RIBBON") | ||
968 | GiftRibbon.create(id: 11, description: "2004 NATIONAL TOURNEY CHAMPION RIBBON") | ||
969 | GiftRibbon.create(id: 12, description: "2004 GLOBAL CUP CHAMPION RIBBON") | ||
970 | GiftRibbon.create(id: 13, description: "2004 REGIONAL TOURNEY Runner-up RIBBON") | ||
971 | GiftRibbon.create(id: 14, description: "2004 NATIONAL TOURNEY Runner-up RIBBON") | ||
972 | GiftRibbon.create(id: 15, description: "2004 GLOBAL CUP Runner-up RIBBON") | ||
973 | GiftRibbon.create(id: 16, description: "2004 REGIONAL TOURNEY Semifinalist RIBBON") | ||
974 | GiftRibbon.create(id: 17, description: "2004 NATIONAL TOURNEY Semifinalist RIBBON") | ||
975 | GiftRibbon.create(id: 18, description: "2004 GLOBAL CUP Semifinalist RIBBON") | ||
976 | GiftRibbon.create(id: 19, description: "2005 REGIONAL TOURNEY CHAMPION RIBBON") | ||
977 | GiftRibbon.create(id: 20, description: "2005 NATIONAL TOURNEY CHAMPION RIBBON") | ||
978 | GiftRibbon.create(id: 21, description: "2005 GLOBAL CUP CHAMPION RIBBON") | ||
979 | GiftRibbon.create(id: 22, description: "2005 REGIONAL TOURNEY Runner-up RIBBON") | ||
980 | GiftRibbon.create(id: 23, description: "2005 NATIONAL TOURNEY Runner-up RIBBON") | ||
981 | GiftRibbon.create(id: 24, description: "2005 GLOBAL CUP Runner-up RIBBON") | ||
982 | GiftRibbon.create(id: 25, description: "2005 REGIONAL TOURNEY Semifinalist RIBBON") | ||
983 | GiftRibbon.create(id: 26, description: "2005 NATIONAL TOURNEY Semifinalist RIBBON") | ||
984 | GiftRibbon.create(id: 27, description: "2005 GLOBAL CUP Semifinalist RIBBON") | ||
985 | GiftRibbon.create(id: 28, description: "POKéMON BATTLE CUP CHAMPION RIBBON") | ||
986 | GiftRibbon.create(id: 29, description: "POKéMON BATTLE CUP Runner-up RIBBON") | ||
987 | GiftRibbon.create(id: 30, description: "POKéMON BATTLE CUP Semifinalist RIBBON") | ||
988 | GiftRibbon.create(id: 31, description: "POKéMON BATTLE CUP Participation RIBBON") | ||
989 | GiftRibbon.create(id: 32, description: "POKéMON LEAGUE CHAMPION RIBBON") | ||
990 | GiftRibbon.create(id: 33, description: "POKéMON LEAGUE Runner-up RIBBON") | ||
991 | GiftRibbon.create(id: 34, description: "POKéMON LEAGUE Semifinalist RIBBON") | ||
992 | GiftRibbon.create(id: 35, description: "POKéMON LEAGUE Participation RIBBON") | ||
993 | GiftRibbon.create(id: 36, description: "ADVANCE CUP CHAMPION RIBBON") | ||
994 | GiftRibbon.create(id: 37, description: "ADVANCE CUP Runner-up RIBBON") | ||
995 | GiftRibbon.create(id: 38, description: "ADVANCE CUP Semifinalist RIBBON") | ||
996 | GiftRibbon.create(id: 39, description: "ADVANCE CUP Participation RIBBON") | ||
997 | GiftRibbon.create(id: 40, description: "POKéMON Tournament Participation RIBBON") | ||
998 | GiftRibbon.create(id: 41, description: "POKéMON Event Participation RIBBON") | ||
999 | GiftRibbon.create(id: 42, description: "POKéMON Festival Participation RIBBON") | ||
1000 | GiftRibbon.create(id: 43, description: "Difficulty-clearing Commemorative RIBBON") | ||
1001 | GiftRibbon.create(id: 44, description: "RIBBON awarded for clearing all difficulties.") | ||
1002 | GiftRibbon.create(id: 45, description: "100-straight Win Commemorative RIBBON") | ||
1003 | GiftRibbon.create(id: 46, description: "DARKNESS TOWER Clear Commemorative RIBBON") | ||
1004 | GiftRibbon.create(id: 47, description: "RED TOWER Clear Commemorative RIBBON") | ||
1005 | GiftRibbon.create(id: 48, description: "BLACKIRON TOWER Clear Commemorative RIBBON") | ||
1006 | GiftRibbon.create(id: 49, description: "FINAL TOWER Clear Commemorative RIBBON") | ||
1007 | GiftRibbon.create(id: 50, description: "Legend-making Commemorative RIBBON") | ||
1008 | GiftRibbon.create(id: 51, description: "POKéMON CENTER TOKYO Commemorative RIBBON") | ||
1009 | GiftRibbon.create(id: 52, description: "POKéMON CENTER OSAKA Commemorative RIBBON") | ||
1010 | GiftRibbon.create(id: 53, description: "POKéMON CENTER NAGOYA Commemorative RIBBON") | ||
1011 | GiftRibbon.create(id: 54, description: "POKéMON CENTER NY Commemorative RIBBON") | ||
1012 | GiftRibbon.create(id: 55, description: "Summer Holidays RIBBON") | ||
1013 | GiftRibbon.create(id: 56, description: "Winter Holidays RIBBON") | ||
1014 | GiftRibbon.create(id: 57, description: "Spring Holidays RIBBON") | ||
1015 | GiftRibbon.create(id: 58, description: "Evergreen RIBBON") | ||
1016 | GiftRibbon.create(id: 59, description: "Special Holiday RIBBON") | ||
1017 | GiftRibbon.create(id: 60, description: "Hard Worker RIBBON") | ||
1018 | GiftRibbon.create(id: 61, description: "Lots of Friends RIBBON") | ||
1019 | GiftRibbon.create(id: 62, description: "Full of Energy RIBBON") | ||
1020 | GiftRibbon.create(id: 63, description: "A commemorative RIBBON for a loved POKéMON.") | ||
1021 | GiftRibbon.create(id: 64, description: "RIBBON that shows love for POKéMON.") | ||
957 | end | 1022 | end |
diff --git a/test/dummy/db/schema.rb b/test/dummy/db/schema.rb index 1dfb59a..9530010 100644 --- a/test/dummy/db/schema.rb +++ b/test/dummy/db/schema.rb | |||
@@ -10,7 +10,7 @@ | |||
10 | # | 10 | # |
11 | # It's strongly recommended that you check this file into your version control system. | 11 | # It's strongly recommended that you check this file into your version control system. |
12 | 12 | ||
13 | ActiveRecord::Schema.define(version: 20170929211529) do | 13 | ActiveRecord::Schema.define(version: 20170930021856) do |
14 | 14 | ||
15 | create_table "pokeviewer_boxes", force: :cascade do |t| | 15 | create_table "pokeviewer_boxes", force: :cascade do |t| |
16 | t.integer "trainer_id", null: false | 16 | t.integer "trainer_id", null: false |
@@ -22,6 +22,12 @@ ActiveRecord::Schema.define(version: 20170929211529) do | |||
22 | t.index ["trainer_id"], name: "index_pokeviewer_boxes_on_trainer_id" | 22 | t.index ["trainer_id"], name: "index_pokeviewer_boxes_on_trainer_id" |
23 | end | 23 | end |
24 | 24 | ||
25 | create_table "pokeviewer_gift_ribbons", force: :cascade do |t| | ||
26 | t.string "description", null: false | ||
27 | t.datetime "created_at", null: false | ||
28 | t.datetime "updated_at", null: false | ||
29 | end | ||
30 | |||
25 | create_table "pokeviewer_locations", force: :cascade do |t| | 31 | create_table "pokeviewer_locations", force: :cascade do |t| |
26 | t.string "name", null: false | 32 | t.string "name", null: false |
27 | t.datetime "created_at", null: false | 33 | t.datetime "created_at", null: false |
@@ -129,7 +135,21 @@ ActiveRecord::Schema.define(version: 20170929211529) do | |||
129 | t.integer "number", null: false | 135 | t.integer "number", null: false |
130 | t.datetime "created_at", null: false | 136 | t.datetime "created_at", null: false |
131 | t.datetime "updated_at", null: false | 137 | t.datetime "updated_at", null: false |
138 | t.integer "marine_ribbon_id" | ||
139 | t.integer "land_ribbon_id" | ||
140 | t.integer "sky_ribbon_id" | ||
141 | t.integer "country_ribbon_id" | ||
142 | t.integer "national_ribbon_id" | ||
143 | t.integer "earth_ribbon_id" | ||
144 | t.integer "world_ribbon_id" | ||
145 | t.index ["country_ribbon_id"], name: "index_pokeviewer_trainers_on_country_ribbon_id" | ||
146 | t.index ["earth_ribbon_id"], name: "index_pokeviewer_trainers_on_earth_ribbon_id" | ||
147 | t.index ["land_ribbon_id"], name: "index_pokeviewer_trainers_on_land_ribbon_id" | ||
148 | t.index ["marine_ribbon_id"], name: "index_pokeviewer_trainers_on_marine_ribbon_id" | ||
132 | t.index ["name", "number"], name: "index_pokeviewer_trainers_on_name_and_number", unique: true | 149 | t.index ["name", "number"], name: "index_pokeviewer_trainers_on_name_and_number", unique: true |
150 | t.index ["national_ribbon_id"], name: "index_pokeviewer_trainers_on_national_ribbon_id" | ||
151 | t.index ["sky_ribbon_id"], name: "index_pokeviewer_trainers_on_sky_ribbon_id" | ||
152 | t.index ["world_ribbon_id"], name: "index_pokeviewer_trainers_on_world_ribbon_id" | ||
133 | end | 153 | end |
134 | 154 | ||
135 | end | 155 | end |