Add support for weapon transcendence (#142)
* Add migrations * Add weapon key 4 column * Update schema.rb * Add transcendence date to weapon * Rename summon XLB to match weapon * Update blueprints * Update search * Accept weapon transcendence step * Update XLB to transcendence for summons * Add logic for transcending weapons * Add transcendence step to weapon blueprint
This commit is contained in:
parent
4cf6516fe5
commit
9cf8626752
16 changed files with 87 additions and 29 deletions
|
|
@ -9,7 +9,7 @@ module Api
|
||||||
end
|
end
|
||||||
|
|
||||||
view :nested do
|
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, name: :object, blueprint: WeaponBlueprint
|
||||||
|
|
||||||
association :weapon_keys,
|
association :weapon_keys,
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ module Api
|
||||||
{
|
{
|
||||||
flb: w.flb,
|
flb: w.flb,
|
||||||
ulb: w.ulb,
|
ulb: w.ulb,
|
||||||
xlb: w.xlb
|
transcendence: w.transcendence
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,8 @@ module Api
|
||||||
field :uncap do |w|
|
field :uncap do |w|
|
||||||
{
|
{
|
||||||
flb: w.flb,
|
flb: w.flb,
|
||||||
ulb: w.ulb
|
ulb: w.ulb,
|
||||||
|
transcendence: w.transcendence
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -39,7 +40,7 @@ module Api
|
||||||
}
|
}
|
||||||
end
|
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|
|
w.awakenings.map do |a|
|
||||||
AwakeningBlueprint.render_as_hash(a)
|
AwakeningBlueprint.render_as_hash(a)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ module Api
|
||||||
max_uncap_level = max_uncap_level(summon)
|
max_uncap_level = max_uncap_level(summon)
|
||||||
|
|
||||||
greater_than_max_uncap = summon_params[:uncap_level].to_i > max_uncap_level
|
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
|
uncap_level = if greater_than_max_uncap || can_be_transcended
|
||||||
max_uncap_level
|
max_uncap_level
|
||||||
|
|
@ -44,7 +44,7 @@ module Api
|
||||||
summon_params[:uncap_level]
|
summon_params[:uncap_level]
|
||||||
end
|
end
|
||||||
|
|
||||||
transcendence_step = if summon.xlb && summon_params[:transcendence_step]
|
transcendence_step = if summon.transcendence && summon_params[:transcendence_step]
|
||||||
summon_params[:transcendence_step]
|
summon_params[:transcendence_step]
|
||||||
else
|
else
|
||||||
0
|
0
|
||||||
|
|
@ -114,11 +114,11 @@ module Api
|
||||||
private
|
private
|
||||||
|
|
||||||
def max_uncap_level(summon)
|
def max_uncap_level(summon)
|
||||||
if summon.flb && !summon.ulb && !summon.xlb
|
if summon.flb && !summon.ulb && !summon.transcendence
|
||||||
4
|
4
|
||||||
elsif summon.ulb && !summon.xlb
|
elsif summon.ulb && !summon.transcendence
|
||||||
5
|
5
|
||||||
elsif summon.xlb
|
elsif summon.transcendence
|
||||||
6
|
6
|
||||||
else
|
else
|
||||||
3
|
3
|
||||||
|
|
|
||||||
|
|
@ -73,18 +73,50 @@ module Api
|
||||||
|
|
||||||
def update_uncap_level
|
def update_uncap_level
|
||||||
weapon = GridWeapon.find(weapon_params[:id])
|
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)
|
render_unauthorized_response if current_user && (weapon.party.user != current_user)
|
||||||
|
|
||||||
weapon.uncap_level = weapon_params[:uncap_level]
|
greater_than_max_uncap = weapon_params[:uncap_level].to_i > max_uncap_level
|
||||||
return unless weapon.save!
|
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),
|
uncap_level = if greater_than_max_uncap || can_be_transcended
|
||||||
status: :created
|
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
|
end
|
||||||
|
|
||||||
private
|
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
|
def check_weapon_compatibility
|
||||||
return if compatible_with_position?(incoming_weapon, weapon_params[:position])
|
return if compatible_with_position?(incoming_weapon, weapon_params[:position])
|
||||||
|
|
||||||
|
|
@ -204,7 +236,7 @@ module Api
|
||||||
def weapon_params
|
def weapon_params
|
||||||
params.require(:weapon).permit(
|
params.require(:weapon).permit(
|
||||||
:id, :party_id, :weapon_id,
|
: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,
|
:weapon_key1_id, :weapon_key2_id, :weapon_key3_id,
|
||||||
:ax_modifier1, :ax_modifier2, :ax_strength1, :ax_strength2,
|
:ax_modifier1, :ax_modifier2, :ax_strength1, :ax_strength2,
|
||||||
:awakening_id, :awakening_level
|
:awakening_id, :awakening_level
|
||||||
|
|
|
||||||
|
|
@ -405,7 +405,7 @@ module Api
|
||||||
summons_attributes: %i[id party_id summon_id position main friend
|
summons_attributes: %i[id party_id summon_id position main friend
|
||||||
quick_summon uncap_level transcendence_step],
|
quick_summon uncap_level transcendence_step],
|
||||||
weapons_attributes: %i[id party_id weapon_id
|
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
|
weapon_key1_id weapon_key2_id weapon_key3_id
|
||||||
ax_modifier1 ax_modifier2 ax_strength1 ax_strength2
|
ax_modifier1 ax_modifier2 ax_strength1 ax_strength2
|
||||||
awakening_id awakening_level]
|
awakening_id awakening_level]
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ module Api
|
||||||
Weapon.en_search(search_params[:query]).where(conditions)
|
Weapon.en_search(search_params[:query]).where(conditions)
|
||||||
end
|
end
|
||||||
else
|
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
|
end
|
||||||
|
|
||||||
count = weapons.length
|
count = weapons.length
|
||||||
|
|
@ -149,7 +149,7 @@ module Api
|
||||||
Summon.en_search(search_params[:query]).where(conditions)
|
Summon.en_search(search_params[:query]).where(conditions)
|
||||||
end
|
end
|
||||||
else
|
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
|
end
|
||||||
|
|
||||||
count = summons.length
|
count = summons.length
|
||||||
|
|
|
||||||
|
|
@ -179,7 +179,7 @@ class SummonParser
|
||||||
|
|
||||||
info[:flb] = hash['evo_max'].to_i >= 4
|
info[:flb] = hash['evo_max'].to_i >= 4
|
||||||
info[:ulb] = hash['evo_max'].to_i >= 5
|
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[:rarity] = rarity_from_hash(hash['rarity'])
|
||||||
info[:series] = hash['series']
|
info[:series] = hash['series']
|
||||||
|
|
@ -205,7 +205,7 @@ class SummonParser
|
||||||
release_date: parse_date(hash['release_date']),
|
release_date: parse_date(hash['release_date']),
|
||||||
flb_date: parse_date(hash['4star_date']),
|
flb_date: parse_date(hash['4star_date']),
|
||||||
ulb_date: parse_date(hash['5star_date']),
|
ulb_date: parse_date(hash['5star_date']),
|
||||||
xlb_date: parse_date(hash['6star_date'])
|
transcendence_date: parse_date(hash['6star_date'])
|
||||||
}
|
}
|
||||||
|
|
||||||
info[:links] = {
|
info[:links] = {
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ class GridWeapon < ApplicationRecord
|
||||||
belongs_to :weapon_key1, class_name: 'WeaponKey', foreign_key: :weapon_key1_id, optional: true
|
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_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_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
|
belongs_to :awakening, optional: true
|
||||||
|
|
||||||
|
|
|
||||||
6
db/migrate/20240113175218_add_transcendence_to_weapon.rb
Normal file
6
db/migrate/20240113175218_add_transcendence_to_weapon.rb
Normal 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
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddTranscendenceLevelToGridWeapon < ActiveRecord::Migration[7.0]
|
||||||
|
def change
|
||||||
|
add_column :grid_weapons, :transcendence_step, :integer, default: 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddWeaponKey4ToGridWeapon < ActiveRecord::Migration[7.0]
|
||||||
|
def change
|
||||||
|
add_column :grid_weapons, :weapon_key4_id, :string
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -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
|
||||||
17
db/schema.rb
17
db/schema.rb
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# 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
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "btree_gin"
|
enable_extension "btree_gin"
|
||||||
enable_extension "pg_trgm"
|
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 "release_date"
|
||||||
t.date "flb_date"
|
t.date "flb_date"
|
||||||
t.date "ulb_date"
|
t.date "ulb_date"
|
||||||
t.string "wiki_ja", default: "", null: false
|
t.string "wiki_ja", default: ""
|
||||||
t.string "gamewith", default: "", null: false
|
t.string "gamewith", default: ""
|
||||||
t.string "kamigame", default: "", null: false
|
t.string "kamigame", default: ""
|
||||||
t.string "nicknames_en", default: [], null: false, array: true
|
t.string "nicknames_en", default: [], null: false, array: true
|
||||||
t.string "nicknames_jp", 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
|
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 "element"
|
||||||
t.integer "awakening_level", default: 1, null: false
|
t.integer "awakening_level", default: 1, null: false
|
||||||
t.uuid "awakening_id"
|
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 ["awakening_id"], name: "index_grid_weapons_on_awakening_id"
|
||||||
t.index ["party_id"], name: "index_grid_weapons_on_party_id"
|
t.index ["party_id"], name: "index_grid_weapons_on_party_id"
|
||||||
t.index ["weapon_id"], name: "index_grid_weapons_on_weapon_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.integer "max_atk_ulb"
|
||||||
t.boolean "subaura", default: false, null: false
|
t.boolean "subaura", default: false, null: false
|
||||||
t.boolean "limit", 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_atk_xlb"
|
||||||
t.integer "max_hp_xlb"
|
t.integer "max_hp_xlb"
|
||||||
t.integer "summon_id"
|
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 "wiki_ja", default: ""
|
||||||
t.string "gamewith", default: ""
|
t.string "gamewith", default: ""
|
||||||
t.string "kamigame", 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_en", default: [], null: false, array: true
|
||||||
t.string "nicknames_jp", 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
|
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 "kamigame", default: ""
|
||||||
t.string "nicknames_en", default: [], null: false, array: true
|
t.string "nicknames_en", default: [], null: false, array: true
|
||||||
t.string "nicknames_jp", 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 ["name_en"], name: "index_weapons_on_name_en", opclass: :gin_trgm_ops, using: :gin
|
||||||
t.index ["recruits_id"], name: "index_weapons_on_recruits_id"
|
t.index ["recruits_id"], name: "index_weapons_on_recruits_id"
|
||||||
end
|
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: "skill2_id"
|
||||||
add_foreign_key "parties", "job_skills", column: "skill3_id"
|
add_foreign_key "parties", "job_skills", column: "skill3_id"
|
||||||
add_foreign_key "parties", "jobs"
|
add_foreign_key "parties", "jobs"
|
||||||
add_foreign_key "parties", "parties", column: "source_party_id"
|
|
||||||
add_foreign_key "parties", "raids"
|
add_foreign_key "parties", "raids"
|
||||||
add_foreign_key "parties", "users"
|
add_foreign_key "parties", "users"
|
||||||
add_foreign_key "raids", "raid_groups", column: "group_id"
|
add_foreign_key "raids", "raid_groups", column: "group_id"
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ def seed_summons
|
||||||
s.series = row['series']
|
s.series = row['series']
|
||||||
s.flb = row['flb']
|
s.flb = row['flb']
|
||||||
s.ulb = row['ulb']
|
s.ulb = row['ulb']
|
||||||
s.xlb = row['xlb']
|
s.transcendence = row['transcendence']
|
||||||
s.subaura = row['subaura']
|
s.subaura = row['subaura']
|
||||||
s.limit = row['limit']
|
s.limit = row['limit']
|
||||||
s.max_level = row['max_level']
|
s.max_level = row['max_level']
|
||||||
|
|
@ -176,7 +176,6 @@ def seed_jobs
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "There are now #{Job.count} rows in the jobs table."
|
puts "There are now #{Job.count} rows in the jobs table."
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def seed_job_skills
|
def seed_job_skills
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ namespace :granblue do
|
||||||
size)} \n")
|
size)} \n")
|
||||||
end
|
end
|
||||||
|
|
||||||
if s.xlb
|
if s.transcendence
|
||||||
f.write("#{build_summon_url("#{s.granblue_id}_03",
|
f.write("#{build_summon_url("#{s.granblue_id}_03",
|
||||||
size)} \n")
|
size)} \n")
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue