hensei-api/app/models/weapon_series.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

35 lines
1.2 KiB
Ruby

# frozen_string_literal: true
class WeaponSeries < ApplicationRecord
has_many :weapons, dependent: :restrict_with_error
has_many :weapon_key_series, dependent: :destroy
has_many :weapon_keys, through: :weapon_key_series
enum :augment_type, { none: 0, ax: 1, befoulment: 2 }, default: :none
validates :name_en, presence: true
validates :name_jp, presence: true
validates :slug, presence: true, uniqueness: true
validates :order, numericality: { only_integer: true }
scope :ordered, -> { order(:order) }
scope :extra_allowed, -> { where(extra: true) }
scope :element_changeable, -> { where(element_changeable: true) }
scope :with_weapon_keys, -> { where(has_weapon_keys: true) }
scope :with_awakening, -> { where(has_awakening: true) }
scope :with_ax_skills, -> { where(augment_type: :ax) }
scope :with_befoulments, -> { where(augment_type: :befoulment) }
# Slug constants for commonly referenced series
DARK_OPUS = 'dark-opus'
DRACONIC = 'draconic'
DRACONIC_PROVIDENCE = 'draconic-providence'
REVENANT = 'revenant'
ULTIMA = 'ultima'
SUPERLATIVE = 'superlative'
CLASS_CHAMPION = 'class-champion'
def blueprint
WeaponSeriesBlueprint
end
end