update blueprints for weapon_stat_modifier serialization
This commit is contained in:
parent
7647f5f1d6
commit
62450304dc
5 changed files with 57 additions and 11 deletions
|
|
@ -7,10 +7,28 @@ module Api
|
|||
:created_at, :updated_at
|
||||
|
||||
field :ax, if: ->(_, obj, _) { obj.ax_modifier1.present? } do |obj|
|
||||
[
|
||||
{ modifier: obj.ax_modifier1, strength: obj.ax_strength1 },
|
||||
{ modifier: obj.ax_modifier2, strength: obj.ax_strength2 }
|
||||
].compact_blank
|
||||
skills = []
|
||||
if obj.ax_modifier1.present?
|
||||
skills << {
|
||||
modifier: WeaponStatModifierBlueprint.render_as_hash(obj.ax_modifier1),
|
||||
strength: obj.ax_strength1
|
||||
}
|
||||
end
|
||||
if obj.ax_modifier2.present?
|
||||
skills << {
|
||||
modifier: WeaponStatModifierBlueprint.render_as_hash(obj.ax_modifier2),
|
||||
strength: obj.ax_strength2
|
||||
}
|
||||
end
|
||||
skills
|
||||
end
|
||||
|
||||
field :befoulment, if: ->(_, obj, _) { obj.befoulment_modifier.present? } do |obj|
|
||||
{
|
||||
modifier: WeaponStatModifierBlueprint.render_as_hash(obj.befoulment_modifier),
|
||||
strength: obj.befoulment_strength,
|
||||
exorcism_level: obj.exorcism_level
|
||||
}
|
||||
end
|
||||
|
||||
field :awakening, if: ->(_, obj, _) { obj.awakening.present? } do |obj|
|
||||
|
|
|
|||
|
|
@ -15,11 +15,29 @@ module Api
|
|||
end
|
||||
|
||||
view :nested do
|
||||
field :ax, if: ->(_field_name, w, _options) { w.weapon.present? && w.weapon.ax } do |w|
|
||||
[
|
||||
{ modifier: w.ax_modifier1, strength: w.ax_strength1 },
|
||||
{ modifier: w.ax_modifier2, strength: w.ax_strength2 }
|
||||
]
|
||||
field :ax, if: ->(_field_name, w, _options) { w.ax_modifier1.present? } do |w|
|
||||
skills = []
|
||||
if w.ax_modifier1.present?
|
||||
skills << {
|
||||
modifier: WeaponStatModifierBlueprint.render_as_hash(w.ax_modifier1),
|
||||
strength: w.ax_strength1
|
||||
}
|
||||
end
|
||||
if w.ax_modifier2.present?
|
||||
skills << {
|
||||
modifier: WeaponStatModifierBlueprint.render_as_hash(w.ax_modifier2),
|
||||
strength: w.ax_strength2
|
||||
}
|
||||
end
|
||||
skills
|
||||
end
|
||||
|
||||
field :befoulment, if: ->(_field_name, w, _options) { w.befoulment_modifier.present? } do |w|
|
||||
{
|
||||
modifier: WeaponStatModifierBlueprint.render_as_hash(w.befoulment_modifier),
|
||||
strength: w.befoulment_strength,
|
||||
exorcism_level: w.exorcism_level
|
||||
}
|
||||
end
|
||||
|
||||
field :awakening, if: ->(_field_name, w, _options) { w.awakening.present? } do |w|
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ module Api
|
|||
},
|
||||
has_weapon_keys: w.weapon_series.has_weapon_keys,
|
||||
has_awakening: w.weapon_series.has_awakening,
|
||||
has_ax_skills: w.weapon_series.has_ax_skills,
|
||||
augment_type: w.weapon_series.augment_type,
|
||||
extra: w.weapon_series.extra,
|
||||
element_changeable: w.weapon_series.element_changeable
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ module Api
|
|||
end
|
||||
|
||||
fields :slug, :order, :extra, :element_changeable, :has_weapon_keys,
|
||||
:has_awakening, :has_ax_skills
|
||||
:has_awakening, :augment_type
|
||||
|
||||
view :full do
|
||||
field :weapon_count do |ws|
|
||||
|
|
|
|||
10
app/blueprints/api/v1/weapon_stat_modifier_blueprint.rb
Normal file
10
app/blueprints/api/v1/weapon_stat_modifier_blueprint.rb
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Api
|
||||
module V1
|
||||
class WeaponStatModifierBlueprint < Blueprinter::Base
|
||||
identifier :id
|
||||
fields :slug, :name_en, :name_jp, :category, :stat, :polarity, :suffix
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue