diff --git a/db/schema.rb b/db/schema.rb index 3bf599a..c54e829 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -381,6 +381,20 @@ ActiveRecord::Schema[7.0].define(version: 2023_06_18_051638) do t.index ["user_id"], name: "index_sparks_on_user_id", unique: true end + create_table "sparks", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + t.string "user_id", null: false + t.string "guild_ids", null: false, array: true + t.integer "crystals", default: 0 + t.integer "tickets", default: 0 + t.integer "ten_tickets", default: 0 + t.string "target_type" + t.bigint "target_id" + t.datetime "updated_at", default: -> { "CURRENT_TIMESTAMP" }, null: false + t.string "target_memo" + t.index ["target_type", "target_id"], name: "index_sparks_on_target" + t.index ["user_id"], name: "index_sparks_on_user_id", unique: true + end + create_table "summons", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.string "name_en" t.string "name_jp" diff --git a/lib/tasks/download_images.rake b/lib/tasks/download_images.rake index ec61cb2..9079f89 100644 --- a/lib/tasks/download_images.rake +++ b/lib/tasks/download_images.rake @@ -106,7 +106,7 @@ namespace :granblue do puts "Summon #{id}" sizes.each do |size| - path = "#{Rails.root}/download/character-#{size}" + path = "#{Rails.root}/download/summon-#{size}" download_images(url[size.to_sym], size, path) end end @@ -125,7 +125,10 @@ namespace :granblue do elsif object == 'weapon' download_weapon_images(id) elsif object == 'summon' - download_summon_images(id) + download_summon_images("#{id}") + download_summon_images("#{id}_02") + download_summon_images("#{id}_03") + download_summon_images("#{id}_04") end end end diff --git a/lib/tasks/export_job.rake b/lib/tasks/export_job.rake index 87bdb4d..32f640d 100644 --- a/lib/tasks/export_job.rake +++ b/lib/tasks/export_job.rake @@ -1,33 +1,73 @@ namespace :granblue do namespace :export do def build_job_icon_url(id) - # Set up URL base_url = 'https://prd-game-a-granbluefantasy.akamaized.net/assets_en/img/sp/ui/icon/job' extension = '.png' "#{base_url}/#{id}#{extension}" end - desc 'Exports a list of weapon URLs for a given size' - task :job do |_t, _args| - # Include weapon model + def build_job_portrait_url(id, proficiency, gender) + base_url = 'https://prd-game-a1-granbluefantasy.akamaized.net/assets_en/img/sp/assets/leader/quest' + extension = '.jpg' + + prefix = "" + case proficiency + when 1 + prefix = "sw" + when 2 + prefix = "kn" + when 3 + prefix = "ax" + when 4 + prefix = "sp" + when 5 + prefix = "bw" + when 6 + prefix = "wa" + when 7 + prefix = "me" + when 8 + prefix = "mc" + when 9 + prefix = "gu" + when 10 + prefix = "kt" + end + + "#{base_url}/#{id}_#{prefix}_#{gender}_01#{extension}" + end + + # job-icon + def write_urls(size) + # Include model Dir.glob("#{Rails.root}/app/models/job.rb").each { |file| require file } # Set up filepath dir = "#{Rails.root}/export/" - filename = "#{dir}/job-icon.txt" + filename = "#{dir}job-#{size}.txt" FileUtils.mkdir(dir) unless Dir.exist?(dir) # Write to file File.open(filename, 'w') do |f| Job.all.each do |w| - f.write("#{build_job_icon_url(w.granblue_id.to_s)} \n") + if size == 'icon' + f.write("#{build_job_icon_url(w.granblue_id.to_s)} \n") + elsif size == 'portrait' + f.write("#{build_job_portrait_url(w.granblue_id.to_s, w.proficiency1, 0)} \n") + f.write("#{build_job_portrait_url(w.granblue_id.to_s, w.proficiency1, 1)} \n") + end end end # CLI output count = `wc -l #{filename}`.split.first.to_i - puts "Wrote #{count} job URLs for icon size" + puts "Wrote #{count} job URLs for #{size} size" + end + + desc 'Exports a list of job URLs for a given size' + task :job, [:size] => :environment do |_t, args| + write_urls(args[:size]) end end end