Refactor grid object blueprints
This commit is contained in:
parent
b71ca8e458
commit
4afccabaaf
3 changed files with 56 additions and 64 deletions
|
|
@ -3,56 +3,47 @@
|
||||||
module Api
|
module Api
|
||||||
module V1
|
module V1
|
||||||
class GridCharacterBlueprint < ApiBlueprint
|
class GridCharacterBlueprint < ApiBlueprint
|
||||||
|
fields :position, :uncap_level, :perpetuity
|
||||||
|
|
||||||
|
field :transcendence_step, if: ->(_field, gc, _options) { gc.character&.ulb } do |gc|
|
||||||
|
gc.transcendence_step
|
||||||
|
end
|
||||||
|
|
||||||
|
view :preview do
|
||||||
|
association :character, blueprint: CharacterBlueprint
|
||||||
|
end
|
||||||
|
|
||||||
|
view :nested do
|
||||||
|
include_view :mastery_bonuses
|
||||||
|
association :character, blueprint: CharacterBlueprint, view: :full
|
||||||
|
end
|
||||||
|
|
||||||
view :uncap do
|
view :uncap do
|
||||||
association :party, blueprint: PartyBlueprint, view: :minimal
|
association :party, blueprint: PartyBlueprint, view: :minimal
|
||||||
fields :position, :uncap_level
|
fields :position, :uncap_level
|
||||||
end
|
end
|
||||||
|
|
||||||
view :nested do
|
view :destroyed do
|
||||||
fields :position, :uncap_level, :perpetuity
|
fields :position, :created_at, :updated_at
|
||||||
|
end
|
||||||
|
|
||||||
field :transcendence_step, if: lambda { |_fn, obj, _opt|
|
view :mastery_bonuses do
|
||||||
obj.character.ulb
|
field :awakening, if: ->(_field_name, gc, _options) { gc.association(:awakening).loaded? } do |gc|
|
||||||
} do |c|
|
|
||||||
c.transcendence_step
|
|
||||||
end
|
|
||||||
|
|
||||||
field :awakening do |c|
|
|
||||||
{
|
{
|
||||||
type: AwakeningBlueprint.render_as_hash(c.awakening),
|
type: AwakeningBlueprint.render_as_hash(gc.awakening),
|
||||||
level: c.awakening_level
|
level: gc.awakening_level
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
field :over_mastery, if: lambda { |_fn, obj, _opt|
|
field :over_mastery, if: lambda { |_fn, obj, _opt|
|
||||||
!obj.ring1['modifier'].nil? && !obj.ring2['modifier'].nil?
|
!obj.ring1['modifier'].nil? && !obj.ring2['modifier'].nil?
|
||||||
} do |c|
|
} do |c|
|
||||||
rings = []
|
[c.ring1, c.ring2, c.ring3, c.ring4].reject { |ring| ring['modifier'].nil? }
|
||||||
|
|
||||||
rings.push(c.ring1) unless c.ring1['modifier'].nil?
|
|
||||||
rings.push(c.ring2) unless c.ring2['modifier'].nil?
|
|
||||||
rings.push(c.ring3) unless c.ring3['modifier'].nil?
|
|
||||||
rings.push(c.ring4) unless c.ring4['modifier'].nil?
|
|
||||||
|
|
||||||
rings
|
|
||||||
end
|
end
|
||||||
|
|
||||||
field :aetherial_mastery, if: lambda { |_fn, obj, _opt|
|
field :aetherial_mastery, if: lambda { |_fn, obj, _opt|
|
||||||
!obj.earring['modifier'].nil?
|
!obj.earring['modifier'].nil?
|
||||||
} do |c|
|
}, &:earring
|
||||||
c.earring
|
|
||||||
end
|
|
||||||
|
|
||||||
association :character, name: :object, blueprint: CharacterBlueprint
|
|
||||||
end
|
|
||||||
|
|
||||||
view :full do
|
|
||||||
include_view :nested
|
|
||||||
association :party, blueprint: PartyBlueprint, view: :minimal
|
|
||||||
end
|
|
||||||
|
|
||||||
view :destroyed do
|
|
||||||
fields :position, :created_at, :updated_at
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,14 @@
|
||||||
module Api
|
module Api
|
||||||
module V1
|
module V1
|
||||||
class GridSummonBlueprint < ApiBlueprint
|
class GridSummonBlueprint < ApiBlueprint
|
||||||
view :uncap do
|
fields :main, :friend, :position, :quick_summon, :uncap_level, :transcendence_step
|
||||||
association :party, blueprint: PartyBlueprint, view: :minimal
|
|
||||||
fields :position, :uncap_level, :transcendence_step
|
view :preview do
|
||||||
|
association :summon, blueprint: SummonBlueprint
|
||||||
end
|
end
|
||||||
|
|
||||||
view :nested do
|
view :nested do
|
||||||
fields :main, :friend, :position, :quick_summon, :uncap_level, :transcendence_step
|
association :summon, blueprint: SummonBlueprint, view: :full
|
||||||
association :summon, name: :object, blueprint: SummonBlueprint
|
|
||||||
end
|
end
|
||||||
|
|
||||||
view :full do
|
view :full do
|
||||||
|
|
@ -18,6 +18,11 @@ module Api
|
||||||
association :party, blueprint: PartyBlueprint, view: :minimal
|
association :party, blueprint: PartyBlueprint, view: :minimal
|
||||||
end
|
end
|
||||||
|
|
||||||
|
view :uncap do
|
||||||
|
association :party, blueprint: PartyBlueprint, view: :minimal
|
||||||
|
fields :position, :uncap_level, :transcendence_step
|
||||||
|
end
|
||||||
|
|
||||||
view :destroyed do
|
view :destroyed do
|
||||||
fields :main, :friend, :position, :created_at, :updated_at
|
fields :main, :friend, :position, :created_at, :updated_at
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -3,40 +3,31 @@
|
||||||
module Api
|
module Api
|
||||||
module V1
|
module V1
|
||||||
class GridWeaponBlueprint < ApiBlueprint
|
class GridWeaponBlueprint < ApiBlueprint
|
||||||
view :uncap do
|
fields :mainhand, :position, :uncap_level, :transcendence_step, :element
|
||||||
association :party, blueprint: PartyBlueprint, view: :minimal
|
|
||||||
fields :position, :uncap_level
|
view :preview do
|
||||||
|
association :weapon, blueprint: WeaponBlueprint
|
||||||
end
|
end
|
||||||
|
|
||||||
view :nested do
|
view :nested do
|
||||||
fields :mainhand, :position, :uncap_level, :transcendence_step, :element
|
|
||||||
association :weapon, name: :object, blueprint: WeaponBlueprint
|
|
||||||
|
|
||||||
association :weapon_keys,
|
|
||||||
blueprint: WeaponKeyBlueprint,
|
|
||||||
if: lambda { |_field_name, w, _options|
|
|
||||||
[2, 3, 17, 24, 34].include?(w.weapon.series)
|
|
||||||
}
|
|
||||||
|
|
||||||
field :ax, if: ->(_field_name, w, _options) { w.weapon.ax } do |w|
|
field :ax, if: ->(_field_name, w, _options) { w.weapon.ax } do |w|
|
||||||
[
|
[
|
||||||
{
|
{ modifier: w.ax_modifier1, strength: w.ax_strength1 },
|
||||||
modifier: w.ax_modifier1,
|
{ modifier: w.ax_modifier2, strength: w.ax_strength2 }
|
||||||
strength: w.ax_strength1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
modifier: w.ax_modifier2,
|
|
||||||
strength: w.ax_strength2
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
field :awakening, if: ->(_field_name, w, _options) { w.awakening_id } do |w|
|
field :awakening, if: ->(_field_name, w, _options) { w.association(:awakening).loaded? } do |w|
|
||||||
{
|
{
|
||||||
type: AwakeningBlueprint.render_as_hash(w.awakening),
|
type: AwakeningBlueprint.render_as_hash(w.awakening),
|
||||||
level: w.awakening_level
|
level: w.awakening_level
|
||||||
}
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
association :weapon, blueprint: WeaponBlueprint, view: :full
|
||||||
|
association :weapon_keys,
|
||||||
|
blueprint: WeaponKeyBlueprint,
|
||||||
|
if: ->(_field_name, w, _options) { [2, 3, 17, 24, 34].include?(w.weapon.series) }
|
||||||
end
|
end
|
||||||
|
|
||||||
view :full do
|
view :full do
|
||||||
|
|
@ -44,6 +35,11 @@ module Api
|
||||||
association :party, blueprint: PartyBlueprint, view: :minimal
|
association :party, blueprint: PartyBlueprint, view: :minimal
|
||||||
end
|
end
|
||||||
|
|
||||||
|
view :uncap do
|
||||||
|
association :party, blueprint: PartyBlueprint, view: :minimal
|
||||||
|
fields :position, :uncap_level
|
||||||
|
end
|
||||||
|
|
||||||
view :destroyed do
|
view :destroyed do
|
||||||
fields :mainhand, :position, :created_at, :updated_at
|
fields :mainhand, :position, :created_at, :updated_at
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue