Compare commits

...

11 commits

16 changed files with 87 additions and 29 deletions

View file

@ -9,7 +9,7 @@ module Api
end
view :nested do
fields :mainhand, :position, :uncap_level, :element
fields :mainhand, :position, :uncap_level, :transcendence_step, :element
association :weapon, name: :object, blueprint: WeaponBlueprint
association :weapon_keys,

View file

@ -16,7 +16,7 @@ module Api
{
flb: w.flb,
ulb: w.ulb,
xlb: w.xlb
transcendence: w.transcendence
}
end

View file

@ -17,7 +17,8 @@ module Api
field :uncap do |w|
{
flb: w.flb,
ulb: w.ulb
ulb: w.ulb,
transcendence: w.transcendence
}
end
@ -39,7 +40,7 @@ module Api
}
end
field :awakenings, if: lambda { |_fn, obj, _opt| obj.awakenings.length.positive? } do |w|
field :awakenings, if: ->(_fn, obj, _opt) { obj.awakenings.length.positive? } do |w|
w.awakenings.map do |a|
AwakeningBlueprint.render_as_hash(a)
end

View file

@ -36,7 +36,7 @@ module Api
max_uncap_level = max_uncap_level(summon)
greater_than_max_uncap = summon_params[:uncap_level].to_i > max_uncap_level
can_be_transcended = summon.xlb && summon_params[:transcendence_step] && summon_params[:transcendence_step]&.to_i&.positive?
can_be_transcended = summon.transcendence && summon_params[:transcendence_step] && summon_params[:transcendence_step]&.to_i&.positive?
uncap_level = if greater_than_max_uncap || can_be_transcended
max_uncap_level
@ -44,7 +44,7 @@ module Api
summon_params[:uncap_level]
end
transcendence_step = if summon.xlb && summon_params[:transcendence_step]
transcendence_step = if summon.transcendence && summon_params[:transcendence_step]
summon_params[:transcendence_step]
else
0
@ -114,11 +114,11 @@ module Api
private
def max_uncap_level(summon)
if summon.flb && !summon.ulb && !summon.xlb
if summon.flb && !summon.ulb && !summon.transcendence
4
elsif summon.ulb && !summon.xlb
elsif summon.ulb && !summon.transcendence
5
elsif summon.xlb
elsif summon.transcendence
6
else
3

View file

@ -73,18 +73,50 @@ module Api
def update_uncap_level
weapon = GridWeapon.find(weapon_params[:id])
object = weapon.weapon
max_uncap_level = max_uncap_level(object)
render_unauthorized_response if current_user && (weapon.party.user != current_user)
weapon.uncap_level = weapon_params[:uncap_level]
return unless weapon.save!
greater_than_max_uncap = weapon_params[:uncap_level].to_i > max_uncap_level
can_be_transcended = object.transcendence && weapon_params[:transcendence_step] && weapon_params[:transcendence_step]&.to_i&.positive?
render json: GridWeaponBlueprint.render(weapon, view: :nested, root: :grid_weapon),
status: :created
uncap_level = if greater_than_max_uncap || can_be_transcended
max_uncap_level
else
weapon_params[:uncap_level]
end
transcendence_step = if object.transcendence && weapon_params[:transcendence_step]
weapon_params[:transcendence_step]
else
0
end
weapon.update!(
uncap_level: uncap_level,
transcendence_step: transcendence_step
)
return unless weapon.persisted?
render json: GridWeaponBlueprint.render(weapon, view: :nested, root: :grid_weapon)
end
private
def max_uncap_level(weapon)
if weapon.flb && !weapon.ulb && !weapon.transcendence
4
elsif weapon.ulb && !weapon.transcendence
5
elsif weapon.transcendence
6
else
3
end
end
def check_weapon_compatibility
return if compatible_with_position?(incoming_weapon, weapon_params[:position])
@ -204,7 +236,7 @@ module Api
def weapon_params
params.require(:weapon).permit(
:id, :party_id, :weapon_id,
:position, :mainhand, :uncap_level, :element,
:position, :mainhand, :uncap_level, :transcendence_step, :element,
:weapon_key1_id, :weapon_key2_id, :weapon_key3_id,
:ax_modifier1, :ax_modifier2, :ax_strength1, :ax_strength2,
:awakening_id, :awakening_level

View file

@ -405,7 +405,7 @@ module Api
summons_attributes: %i[id party_id summon_id position main friend
quick_summon uncap_level transcendence_step],
weapons_attributes: %i[id party_id weapon_id
position mainhand uncap_level element
position mainhand uncap_level transcendence_step element
weapon_key1_id weapon_key2_id weapon_key3_id
ax_modifier1 ax_modifier2 ax_strength1 ax_strength2
awakening_id awakening_level]

View file

@ -116,7 +116,7 @@ module Api
Weapon.en_search(search_params[:query]).where(conditions)
end
else
Weapon.where(conditions).order(Arel.sql('greatest(release_date, flb_date, ulb_date) desc'))
Weapon.where(conditions).order(Arel.sql('greatest(release_date, flb_date, ulb_date, transcendence_date) desc'))
end
count = weapons.length
@ -149,7 +149,7 @@ module Api
Summon.en_search(search_params[:query]).where(conditions)
end
else
Summon.where(conditions).order(release_date: :desc).order(Arel.sql('greatest(release_date, flb_date, ulb_date, xlb_date) desc'))
Summon.where(conditions).order(release_date: :desc).order(Arel.sql('greatest(release_date, flb_date, ulb_date, transcendence_date) desc'))
end
count = summons.length

View file

@ -179,7 +179,7 @@ class SummonParser
info[:flb] = hash['evo_max'].to_i >= 4
info[:ulb] = hash['evo_max'].to_i >= 5
info[:xlb] = hash['evo_max'].to_i == 6
info[:transcendence] = hash['evo_max'].to_i == 6
info[:rarity] = rarity_from_hash(hash['rarity'])
info[:series] = hash['series']
@ -205,7 +205,7 @@ class SummonParser
release_date: parse_date(hash['release_date']),
flb_date: parse_date(hash['4star_date']),
ulb_date: parse_date(hash['5star_date']),
xlb_date: parse_date(hash['6star_date'])
transcendence_date: parse_date(hash['6star_date'])
}
info[:links] = {

View file

@ -11,6 +11,7 @@ class GridWeapon < ApplicationRecord
belongs_to :weapon_key1, class_name: 'WeaponKey', foreign_key: :weapon_key1_id, optional: true
belongs_to :weapon_key2, class_name: 'WeaponKey', foreign_key: :weapon_key2_id, optional: true
belongs_to :weapon_key3, class_name: 'WeaponKey', foreign_key: :weapon_key3_id, optional: true
belongs_to :weapon_key4, class_name: 'WeaponKey', foreign_key: :weapon_key4_id, optional: true
belongs_to :awakening, optional: true

View file

@ -0,0 +1,6 @@
class AddTranscendenceToWeapon < ActiveRecord::Migration[7.0]
def change
add_column :weapons, :transcendence, :boolean, default: false
add_column :weapons, :transcendence_date, :datetime
end
end

View file

@ -0,0 +1,5 @@
class AddTranscendenceLevelToGridWeapon < ActiveRecord::Migration[7.0]
def change
add_column :grid_weapons, :transcendence_step, :integer, default: 0
end
end

View file

@ -0,0 +1,5 @@
class AddWeaponKey4ToGridWeapon < ActiveRecord::Migration[7.0]
def change
add_column :grid_weapons, :weapon_key4_id, :string
end
end

View file

@ -0,0 +1,6 @@
class RenameSummonXlbToTranscendence < ActiveRecord::Migration[7.0]
def change
rename_column :summons, :xlb, :transcendence
rename_column :summons, :xlb_date, :transcendence_date
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 2023_11_19_051231) do
ActiveRecord::Schema[7.0].define(version: 2024_01_13_181526) do
# These are extensions that must be enabled in order to support this database
enable_extension "btree_gin"
enable_extension "pg_trgm"
@ -61,9 +61,9 @@ ActiveRecord::Schema[7.0].define(version: 2023_11_19_051231) do
t.date "release_date"
t.date "flb_date"
t.date "ulb_date"
t.string "wiki_ja", default: "", null: false
t.string "gamewith", default: "", null: false
t.string "kamigame", default: "", null: false
t.string "wiki_ja", default: ""
t.string "gamewith", default: ""
t.string "kamigame", default: ""
t.string "nicknames_en", default: [], null: false, array: true
t.string "nicknames_jp", default: [], null: false, array: true
t.index ["name_en"], name: "index_characters_on_name_en", opclass: :gin_trgm_ops, using: :gin
@ -155,6 +155,8 @@ ActiveRecord::Schema[7.0].define(version: 2023_11_19_051231) do
t.integer "element"
t.integer "awakening_level", default: 1, null: false
t.uuid "awakening_id"
t.integer "transcendence_step", default: 0
t.string "weapon_key4_id"
t.index ["awakening_id"], name: "index_grid_weapons_on_awakening_id"
t.index ["party_id"], name: "index_grid_weapons_on_party_id"
t.index ["weapon_id"], name: "index_grid_weapons_on_weapon_id"
@ -369,7 +371,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_11_19_051231) do
t.integer "max_atk_ulb"
t.boolean "subaura", default: false, null: false
t.boolean "limit", default: false, null: false
t.boolean "xlb", default: false, null: false
t.boolean "transcendence", default: false, null: false
t.integer "max_atk_xlb"
t.integer "max_hp_xlb"
t.integer "summon_id"
@ -380,7 +382,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_11_19_051231) do
t.string "wiki_ja", default: ""
t.string "gamewith", default: ""
t.string "kamigame", default: ""
t.date "xlb_date"
t.date "transcendence_date"
t.string "nicknames_en", default: [], null: false, array: true
t.string "nicknames_jp", default: [], null: false, array: true
t.index ["name_en"], name: "index_summons_on_name_en", opclass: :gin_trgm_ops, using: :gin
@ -455,6 +457,8 @@ ActiveRecord::Schema[7.0].define(version: 2023_11_19_051231) do
t.string "kamigame", default: ""
t.string "nicknames_en", default: [], null: false, array: true
t.string "nicknames_jp", default: [], null: false, array: true
t.boolean "transcendence", default: false
t.datetime "transcendence_date"
t.index ["name_en"], name: "index_weapons_on_name_en", opclass: :gin_trgm_ops, using: :gin
t.index ["recruits_id"], name: "index_weapons_on_recruits_id"
end
@ -482,7 +486,6 @@ ActiveRecord::Schema[7.0].define(version: 2023_11_19_051231) do
add_foreign_key "parties", "job_skills", column: "skill2_id"
add_foreign_key "parties", "job_skills", column: "skill3_id"
add_foreign_key "parties", "jobs"
add_foreign_key "parties", "parties", column: "source_party_id"
add_foreign_key "parties", "raids"
add_foreign_key "parties", "users"
add_foreign_key "raids", "raid_groups", column: "group_id"

View file

@ -91,7 +91,7 @@ def seed_summons
s.series = row['series']
s.flb = row['flb']
s.ulb = row['ulb']
s.xlb = row['xlb']
s.transcendence = row['transcendence']
s.subaura = row['subaura']
s.limit = row['limit']
s.max_level = row['max_level']
@ -176,7 +176,6 @@ def seed_jobs
end
puts "There are now #{Job.count} rows in the jobs table."
end
def seed_job_skills

View file

@ -37,7 +37,7 @@ namespace :granblue do
size)} \n")
end
if s.xlb
if s.transcendence
f.write("#{build_summon_url("#{s.granblue_id}_03",
size)} \n")
end