hensei-api/app/blueprints/api/v1/collection_weapon_blueprint.rb
Justin Edmund 1f80e4189f
Add weapon stat modifiers for AX skills and befoulments (#202)
* add weapon_stat_modifiers table for ax skills and befoulments

* add fk columns for ax modifiers and befoulments, replace has_ax_skills with augment_type

* update models for weapon_stat_modifier fks and befoulments

* update blueprints for weapon_stat_modifier serialization

* update import service for weapon_stat_modifier fks and befoulments

* add weapon_stat_modifiers controller and update params for fks

* update tests and factories for weapon_stat_modifier fks

* fix remaining has_ax_skills and ax_modifier references

* add ax_modifier and befoulment_modifier to eager loading

* fix ax modifier column naming and migration approach

* add game_skill_ids for befoulment modifiers
2025-12-31 22:20:00 -08:00

50 lines
No EOL
1.5 KiB
Ruby

module Api
module V1
class CollectionWeaponBlueprint < ApiBlueprint
identifier :id
fields :uncap_level, :transcendence_step, :element,
:created_at, :updated_at
field :ax, if: ->(_, obj, _) { obj.ax_modifier1.present? } do |obj|
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|
{
type: AwakeningBlueprint.render_as_hash(obj.awakening),
level: obj.awakening_level
}
end
association :weapon, blueprint: WeaponBlueprint
association :weapon_keys, blueprint: WeaponKeyBlueprint,
if: ->(_, obj, _) { obj.weapon_keys.any? }
view :full do
association :weapon, blueprint: WeaponBlueprint, view: :full
end
end
end
end